summaryrefslogtreecommitdiff
path: root/buildtools
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-11-03 11:14:40 +1100
committerAndrew Tridgell <tridge@samba.org>2010-11-03 01:34:04 +0000
commitdfa20fcd485b4b3a6b2a9d975374419129e647a4 (patch)
treebf17605582fd9bfd66e12763cc5a10c41cdc392b /buildtools
parent553029b88b470362b533bbd17d028e6e61e4b8b9 (diff)
downloadsamba-dfa20fcd485b4b3a6b2a9d975374419129e647a4.tar.gz
samba-dfa20fcd485b4b3a6b2a9d975374419129e647a4.tar.bz2
samba-dfa20fcd485b4b3a6b2a9d975374419129e647a4.zip
waf: split pkgconfig logic into a separate module
Diffstat (limited to 'buildtools')
-rw-r--r--buildtools/wafsamba/pkgconfig.py61
-rw-r--r--buildtools/wafsamba/wafsamba.py57
2 files changed, 62 insertions, 56 deletions
diff --git a/buildtools/wafsamba/pkgconfig.py b/buildtools/wafsamba/pkgconfig.py
new file mode 100644
index 0000000000..51d559416d
--- /dev/null
+++ b/buildtools/wafsamba/pkgconfig.py
@@ -0,0 +1,61 @@
+# handle substitution of variables in pc files
+
+import Build
+from samba_utils import *
+
+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 = []
+ done_var = {}
+ back_sub = [ ('PREFIX', '${prefix}'), ('EXEC_PREFIX', '${exec_prefix}')]
+ 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:
+ Logs.error("Unknown substitution %s in %s" % (v, task.name))
+ sys.exit(1)
+ v = SUBST_VARS_RECURSIVE(task.env[vname], task.env)
+ # now we back substitute the allowed pc vars
+ for (b, m) in back_sub:
+ s = task.env[b]
+ if s == v[0:len(s)]:
+ if not b in done_var:
+ # we don't want to substitute the first usage
+ done_var[b] = True
+ else:
+ v = m + v[len(s):]
+ break
+ 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, vnum=None):
+ '''install some pkg_config pc files'''
+ dest = '${PKGCONFIGDIR}'
+ dest = bld.EXPAND_VARIABLES(dest)
+ for f in TO_LIST(pc_files):
+ base=os.path.basename(f)
+ t = bld.SAMBA_GENERATOR('PKGCONFIG_%s' % base,
+ rule=subst_at_vars,
+ source=f+'.in',
+ target=f)
+ if vnum:
+ t.env.PACKAGE_VERSION = vnum
+ bld.INSTALL_FILES(dest, f, flat=True, destname=base)
+Build.BuildContext.PKG_CONFIG_FILES = PKG_CONFIG_FILES
+
+
diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py
index 6d09aedb6e..daab00c33c 100644
--- a/buildtools/wafsamba/wafsamba.py
+++ b/buildtools/wafsamba/wafsamba.py
@@ -28,6 +28,7 @@ import samba_dist
import samba_wildcard
import stale_files
import symbols
+import pkgconfig
# some systems have broken threading in python
if os.environ.get('WAF_NOTHREADS') == '1':
@@ -819,62 +820,6 @@ 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 = []
- done_var = {}
- back_sub = [ ('PREFIX', '${prefix}'), ('EXEC_PREFIX', '${exec_prefix}')]
- 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:
- Logs.error("Unknown substitution %s in %s" % (v, task.name))
- sys.exit(1)
- v = SUBST_VARS_RECURSIVE(task.env[vname], task.env)
- # now we back substitute the allowed pc vars
- for (b, m) in back_sub:
- s = task.env[b]
- if s == v[0:len(s)]:
- if not b in done_var:
- # we don't want to substitute the first usage
- done_var[b] = True
- else:
- v = m + v[len(s):]
- break
- 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, vnum=None):
- '''install some pkg_config pc files'''
- dest = '${PKGCONFIGDIR}'
- dest = bld.EXPAND_VARIABLES(dest)
- for f in TO_LIST(pc_files):
- base=os.path.basename(f)
- t = bld.SAMBA_GENERATOR('PKGCONFIG_%s' % base,
- rule=subst_at_vars,
- source=f+'.in',
- target=f)
- if vnum:
- t.env.PACKAGE_VERSION = vnum
- INSTALL_FILES(bld, dest, f, flat=True, destname=base)
-Build.BuildContext.PKG_CONFIG_FILES = PKG_CONFIG_FILES
-
-
def MANPAGES(bld, manpages):
'''build and install manual pages'''
bld.env.MAN_XSL = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'