]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/python/SConstruct
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / python / SConstruct
1 # -*- python -*-
2 #
3 # Copyright (c) 2016 Stefan Seefeld
4 # All rights reserved.
5 #
6 # Distributed under the Boost Software License, Version 1.0.
7 # (See accompanying file LICENSE_1_0.txt or copy at
8 # http://www.boost.org/LICENSE_1_0.txt)
9
10 import SCons.Script.Main
11 import config
12 import config.ui
13 import platform
14 import os
15 import subprocess
16 import re
17
18 #
19 # We try to mimic the typical autotools-workflow.
20 #
21 # * In a 'configure' step all the essential build parameters are established
22 # (either by explicit command-line arguments or from configure checks)
23 # * A subsequent build step can then simply read the cached variables, so
24 # users don't have to memorize and re-issue the arguments on each subsequent
25 # invocation, and neither do the config checks need to be re-run.
26 #
27 # The essential part here is to define a 'config' target, which removes any
28 # caches that may still be lingering around, then runs the checks.
29
30 if 'config' in COMMAND_LINE_TARGETS:
31 # Clear the cache
32 try: os.remove('bin.SCons/config.py')
33 except: pass
34 if not os.path.exists('bin.SCons/'):
35 os.mkdir('bin.SCons/')
36 vars = Variables('bin.SCons/config.py', ARGUMENTS)
37 config.add_options(vars)
38 arch = ARGUMENTS.get('arch', platform.machine())
39 env_vars = {}
40 if 'CXX' in os.environ: env_vars['CXX'] = os.environ['CXX']
41 if 'CXXFLAGS' in os.environ: env_vars['CXXFLAGS'] = os.environ['CXXFLAGS'].split()
42 env_vars['ENV'] = os.environ #{'PATH': os.environ['PATH'], 'TMP' : os.environ['TMP']}
43 env = Environment(toolpath=['config/tools'],
44 tools=['default', 'libs', 'tests', 'doc', 'sphinx4scons'],
45 variables=vars,
46 TARGET_ARCH=arch,
47 **env_vars)
48 if 'gcc' in env['TOOLS']:
49 # Earlier SCons versions (~ 2.3.0) can't handle CXX=clang++.
50 version = subprocess.check_output([env['CXX'], '--version'])
51 match = re.search(r'[0-9]+(\.[0-9]+)+', version)
52 if match:
53 version = match.group(0)
54 else:
55 version = 'unknown'
56 env['CXXVERSION'] = version
57
58 Help(config.ui.help(vars, env) + """
59 Variables are saved in bin.SCons/config.py and persist between scons invocations.
60 """)
61
62 if GetOption('help'):
63 Return()
64
65 build_dir = config.prepare_build_dir(env)
66 config_log = '{}/config.log'.format(build_dir)
67
68 # configure
69 SConsignFile('{}/.sconsign'.format(build_dir))
70 #env.Decider('MD5-timestamp')
71 env.Decider('timestamp-newer')
72 checks = config.get_checks(env)
73 if 'config' in COMMAND_LINE_TARGETS:
74 conf=env.Configure(custom_tests=checks, log_file=config_log, conf_dir=build_dir)
75 if False in (getattr(conf, c)() for c in checks):
76 Exit(1)
77 env = conf.Finish()
78 vars.Save('bin.SCons/config.py', env)
79
80 if not os.path.exists(config_log):
81 print('Please run `scons config` first. (See `scons -h` for available options.)')
82 Exit(1)
83
84 if not GetOption('verbose'):
85 config.ui.pretty_output(env)
86
87 # build
88 env['BPL_VERSION'] = '1.65'
89 for e in config.variants(env):
90 variant_dir=e.subst("$BOOST_CURRENT_VARIANT_DIR")
91 e.SConscript('src/SConscript', variant_dir=variant_dir + '/src',
92 exports = { 'env' : e.Clone(BOOST_LIB = 'python') })
93 if 'test' in COMMAND_LINE_TARGETS:
94 test_env = e.Clone(BOOST_LIB = 'python', BOOST_TEST = True)
95 test_env.BoostUseLib('python')
96 e.SConscript('test/SConscript', variant_dir=variant_dir + '/test',
97 exports = { 'env' : test_env })
98
99 if 'doc' in COMMAND_LINE_TARGETS:
100 env.SConscript('doc/SConscript', variant_dir='bin.SCons/doc',
101 exports = { 'env' : e.Clone(BOOST_LIB = 'python') })