summaryrefslogtreecommitdiffstats
path: root/extras/bjam.py
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-03-17 17:31:05 +0100
committerDavid Robillard <d@drobilla.net>2019-03-17 17:31:05 +0100
commit406f89271452fdb573c7e28113b1ed08ff2b4eda (patch)
treed2dcbaf61f3749f73dc7a5e10d3fc6cd5e6e129a /extras/bjam.py
parent7983a5aae615290d04fd43cbc2752f8cf4a46d10 (diff)
downloadsuil-406f89271452fdb573c7e28113b1ed08ff2b4eda.tar.gz
suil-406f89271452fdb573c7e28113b1ed08ff2b4eda.tar.bz2
suil-406f89271452fdb573c7e28113b1ed08ff2b4eda.zip
Squashed 'waflib/' changes from 915dcb1..e7a29b6
e7a29b6 Upgrade to waf 2.0.15 8280f9d Add command for running executables from the build directory 8073c1a Make make_simple_dox() safe in case of exception 70d03b8 Avoid use of global counter hacks for configuration display b7d689a Rewrite test framework 94deadf Automatically add options and move add_flags() to options context f4259ee Reduce system include path noise 927b608 Automatically display configuration header c44b8f3 Set line justification from a constant in the wscript a48e26f Automatically detect if wscript has a test hook ef66724 Save runtime variables in the environment 63bcbcd Clean up TestContext b1d9505 Add ExecutionContext for setting runtime environment 387c1df Add show_diff() and test_file_equals() utilities 29d4d29 Fix in-tree library paths 9fde01f Add custom configuration context 6d3612f Add lib_path_name constant git-subtree-dir: waflib git-subtree-split: e7a29b6b9b2f842314244c23c14d8f8f560904e1
Diffstat (limited to 'extras/bjam.py')
-rw-r--r--extras/bjam.py128
1 files changed, 128 insertions, 0 deletions
diff --git a/extras/bjam.py b/extras/bjam.py
new file mode 100644
index 0000000..8e04d3a
--- /dev/null
+++ b/extras/bjam.py
@@ -0,0 +1,128 @@
+#! /usr/bin/env python
+# per rosengren 2011
+
+from os import sep, readlink
+from waflib import Logs
+from waflib.TaskGen import feature, after_method
+from waflib.Task import Task, always_run
+
+def options(opt):
+ grp = opt.add_option_group('Bjam Options')
+ grp.add_option('--bjam_src', default=None, help='You can find it in <boost root>/tools/jam/src')
+ grp.add_option('--bjam_uname', default='linuxx86_64', help='bjam is built in <src>/bin.<uname>/bjam')
+ grp.add_option('--bjam_config', default=None)
+ grp.add_option('--bjam_toolset', default=None)
+
+def configure(cnf):
+ if not cnf.env.BJAM_SRC:
+ cnf.env.BJAM_SRC = cnf.options.bjam_src
+ if not cnf.env.BJAM_UNAME:
+ cnf.env.BJAM_UNAME = cnf.options.bjam_uname
+ try:
+ cnf.find_program('bjam', path_list=[
+ cnf.env.BJAM_SRC + sep + 'bin.' + cnf.env.BJAM_UNAME
+ ])
+ except Exception:
+ cnf.env.BJAM = None
+ if not cnf.env.BJAM_CONFIG:
+ cnf.env.BJAM_CONFIG = cnf.options.bjam_config
+ if not cnf.env.BJAM_TOOLSET:
+ cnf.env.BJAM_TOOLSET = cnf.options.bjam_toolset
+
+@feature('bjam')
+@after_method('process_rule')
+def process_bjam(self):
+ if not self.bld.env.BJAM:
+ self.create_task('bjam_creator')
+ self.create_task('bjam_build')
+ self.create_task('bjam_installer')
+ if getattr(self, 'always', False):
+ always_run(bjam_creator)
+ always_run(bjam_build)
+ always_run(bjam_installer)
+
+class bjam_creator(Task):
+ ext_out = 'bjam_exe'
+ vars=['BJAM_SRC', 'BJAM_UNAME']
+ def run(self):
+ env = self.env
+ gen = self.generator
+ bjam = gen.bld.root.find_dir(env.BJAM_SRC)
+ if not bjam:
+ Logs.error('Can not find bjam source')
+ return -1
+ bjam_exe_relpath = 'bin.' + env.BJAM_UNAME + '/bjam'
+ bjam_exe = bjam.find_resource(bjam_exe_relpath)
+ if bjam_exe:
+ env.BJAM = bjam_exe.srcpath()
+ return 0
+ bjam_cmd = ['./build.sh']
+ Logs.debug('runner: ' + bjam.srcpath() + '> ' + str(bjam_cmd))
+ result = self.exec_command(bjam_cmd, cwd=bjam.srcpath())
+ if not result == 0:
+ Logs.error('bjam failed')
+ return -1
+ bjam_exe = bjam.find_resource(bjam_exe_relpath)
+ if bjam_exe:
+ env.BJAM = bjam_exe.srcpath()
+ return 0
+ Logs.error('bjam failed')
+ return -1
+
+class bjam_build(Task):
+ ext_in = 'bjam_exe'
+ ext_out = 'install'
+ vars = ['BJAM_TOOLSET']
+ def run(self):
+ env = self.env
+ gen = self.generator
+ path = gen.path
+ bld = gen.bld
+ if hasattr(gen, 'root'):
+ build_root = path.find_node(gen.root)
+ else:
+ build_root = path
+ jam = bld.srcnode.find_resource(env.BJAM_CONFIG)
+ if jam:
+ Logs.debug('bjam: Using jam configuration from ' + jam.srcpath())
+ jam_rel = jam.relpath_gen(build_root)
+ else:
+ Logs.warn('No build configuration in build_config/user-config.jam. Using default')
+ jam_rel = None
+ bjam_exe = bld.srcnode.find_node(env.BJAM)
+ if not bjam_exe:
+ Logs.error('env.BJAM is not set')
+ return -1
+ bjam_exe_rel = bjam_exe.relpath_gen(build_root)
+ cmd = ([bjam_exe_rel] +
+ (['--user-config=' + jam_rel] if jam_rel else []) +
+ ['--stagedir=' + path.get_bld().path_from(build_root)] +
+ ['--debug-configuration'] +
+ ['--with-' + lib for lib in self.generator.target] +
+ (['toolset=' + env.BJAM_TOOLSET] if env.BJAM_TOOLSET else []) +
+ ['link=' + 'shared'] +
+ ['variant=' + 'release']
+ )
+ Logs.debug('runner: ' + build_root.srcpath() + '> ' + str(cmd))
+ ret = self.exec_command(cmd, cwd=build_root.srcpath())
+ if ret != 0:
+ return ret
+ self.set_outputs(path.get_bld().ant_glob('lib/*') + path.get_bld().ant_glob('bin/*'))
+ return 0
+
+class bjam_installer(Task):
+ ext_in = 'install'
+ def run(self):
+ gen = self.generator
+ path = gen.path
+ for idir, pat in (('${LIBDIR}', 'lib/*'), ('${BINDIR}', 'bin/*')):
+ files = []
+ for n in path.get_bld().ant_glob(pat):
+ try:
+ t = readlink(n.srcpath())
+ gen.bld.symlink_as(sep.join([idir, n.name]), t, postpone=False)
+ except OSError:
+ files.append(n)
+ gen.bld.install_files(idir, files, postpone=False)
+ return 0
+