1 # handle substitution of variables in .in files
3 import Build
, sys
, Logs
4 from samba_utils
import *
6 def subst_at_vars(task
):
7 '''substiture @VAR@ style variables in a file'''
10 src
= task
.inputs
[0].srcpath(env
)
11 tgt
= task
.outputs
[0].bldpath(env
)
17 a
= re
.split('(@\w+@)', s
)
20 if re
.match('@\w+@', v
):
22 if not vname
in task
.env
and vname
.upper() in task
.env
:
24 if not vname
in task
.env
:
25 Logs
.error("Unknown substitution %s in %s" % (v
, task
.name
))
27 v
= SUBST_VARS_RECURSIVE(task
.env
[vname
], task
.env
)
29 contents
= ''.join(out
)
35 def CONFIGURE_FILE(bld
, in_file
, **kwargs
):
38 base
=os
.path
.basename(in_file
)
39 t
= bld
.SAMBA_GENERATOR('INFILE_%s' % base
,
41 source
= in_file
+ '.in',
44 Build
.BuildContext
.CONFIGURE_FILE
= CONFIGURE_FILE