1 # handle substitution of variables in .in files
4 import Build
, sys
, Logs
5 from samba_utils
import SUBST_VARS_RECURSIVE
7 def subst_at_vars(task
):
8 '''substiture @VAR@ style variables in a file'''
11 s
= task
.inputs
[0].read()
14 a
= re
.split('(@\w+@)', s
)
17 if re
.match('@\w+@', v
):
19 if not vname
in task
.env
and vname
.upper() in task
.env
:
21 if not vname
in task
.env
:
22 Logs
.error("Unknown substitution %s in %s" % (v
, task
.name
))
24 v
= SUBST_VARS_RECURSIVE(task
.env
[vname
], task
.env
)
26 contents
= ''.join(out
)
27 task
.outputs
[0].write(contents
)
30 def CONFIGURE_FILE(bld
, in_file
, **kwargs
):
33 base
=os
.path
.basename(in_file
)
34 t
= bld
.SAMBA_GENERATOR('INFILE_%s' % base
,
36 source
= in_file
+ '.in',
39 Build
.BuildContext
.CONFIGURE_FILE
= CONFIGURE_FILE