1 # handle substitution of variables in .in files
6 from waflib import Build, Logs
7 from samba_utils import SUBST_VARS_RECURSIVE
9 def subst_at_vars(task):
10 '''substiture @VAR@ style variables in a file'''
13 s = task.inputs[0].read()
16 a = re.split('(@\w+@)', s)
19 if re.match('@\w+@', v):
21 if not vname in task.env and vname.upper() in task.env:
23 if not vname in task.env:
24 Logs.error("Unknown substitution %s in %s" % (v, task.name))
26 v = SUBST_VARS_RECURSIVE(task.env[vname], task.env)
28 contents = ''.join(out)
29 task.outputs[0].write(contents)
32 def CONFIGURE_FILE(bld, in_file, **kwargs):
35 base=os.path.basename(in_file)
36 t = bld.SAMBA_GENERATOR('INFILE_%s' % base,
38 source = in_file + '.in',
41 Build.BuildContext.CONFIGURE_FILE = CONFIGURE_FILE