summaryrefslogtreecommitdiff
path: root/buildtools/wafsamba
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-03-27 20:00:01 +1100
committerAndrew Tridgell <tridge@samba.org>2010-04-06 20:27:11 +1000
commit91d604add3691e05c0ac1e96d3e2ab223e0b28d5 (patch)
treec365c31970387d13abb974795f7731fd821cec27 /buildtools/wafsamba
parent5b572f1bd8505b0e2d1758d868ae0dec80c5719d (diff)
downloadsamba-91d604add3691e05c0ac1e96d3e2ab223e0b28d5.tar.gz
samba-91d604add3691e05c0ac1e96d3e2ab223e0b28d5.tar.bz2
samba-91d604add3691e05c0ac1e96d3e2ab223e0b28d5.zip
build: substitute @VAR@ variables in pkgconfig .pc.in files
Diffstat (limited to 'buildtools/wafsamba')
-rw-r--r--buildtools/wafsamba/wafsamba.py42
1 files changed, 37 insertions, 5 deletions
diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py
index 1d0b1ba3c1..1fc7f8ca54 100644
--- a/buildtools/wafsamba/wafsamba.py
+++ b/buildtools/wafsamba/wafsamba.py
@@ -1,7 +1,7 @@
# a waf tool to add autoconf-like macros to the configure section
# and for SAMBA_ macros for building libraries, binaries etc
-import Build, os, Options, Task, Utils, cc, TaskGen, fnmatch
+import Build, os, Options, Task, Utils, cc, TaskGen, fnmatch, re
from Configure import conf
from Logs import debug
from samba_utils import SUBST_VARS_RECURSIVE
@@ -475,7 +475,7 @@ def SAMBA_GENERATOR(bld, name, rule, source, target,
rule=rule,
source=bld.EXPAND_VARIABLES(source, vars=vars),
target=target,
- shell=True,
+ shell=isinstance(rule, str),
on_results=True,
before='cc',
ext_out='.c',
@@ -713,12 +713,44 @@ def PUBLIC_HEADERS(bld, public_headers, header_path=None):
Build.BuildContext.PUBLIC_HEADERS = PUBLIC_HEADERS
+def subst_at_vars(task):
+ '''substiture @VAR@ style variables in a file'''
+ src = task.inputs[0].srcpath(task.env)
+ tgt = task.outputs[0].bldpath(task.env)
+
+ f = open(src, 'r')
+ s = f.read()
+ f.close()
+ # split on the vars
+ a = re.split('(@\w+@)', s)
+ out = []
+ for v in a:
+ if re.match('@\w+@', v):
+ vname = v[1:-1]
+ if not vname in task.env and vname.upper() in task.env:
+ vname = vname.upper()
+ if not vname in task.env:
+ print "Unknown substitution %s in %s" % (v, task.name)
+ raise
+ v = task.env[vname]
+ out.append(v)
+ contents = ''.join(out)
+ f = open(tgt, 'w')
+ s = f.write(contents)
+ f.close()
+ return 0
+
+
+
def PKG_CONFIG_FILES(bld, pc_files):
'''install some pkg_config pc files'''
- # TODO: replace the @VAR@ variables
dest = '${PKGCONFIGDIR}'
dest = bld.EXPAND_VARIABLES(dest)
for f in TO_LIST(pc_files):
- INSTALL_FILES(bld, dest, f+'.in', flat=True,
- destname=os.path.basename(f))
+ base=os.path.basename(f)
+ bld.SAMBA_GENERATOR('PKGCONFIG_%s' % base,
+ rule=subst_at_vars,
+ source=f+'.in',
+ target=f)
+ INSTALL_FILES(bld, dest, f, flat=True, destname=base)
Build.BuildContext.PKG_CONFIG_FILES = PKG_CONFIG_FILES