-
Notifications
You must be signed in to change notification settings - Fork 3
/
SConstruct
96 lines (77 loc) · 2.91 KB
/
SConstruct
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
MY_SCONS_HELP = """\
SCons build rules for the mpbcliga program
Usage: scons [target] [var=value]
Targets:
mpbcliga the Liga structure solver program
mpbccost program for calculating cost of a given structure
install install mpbcliga and mpbccost under prefix/bin
alltests build the unit test program "alltests"
test execute functional and unit tests for mpbcliga
Build configuration variables:
%s
Variables can be also assigned in a user-written script sconsvars.py.
SCons construction environment can be customized in sconscript.local script.
"""
import os
import subprocess
import platform
def subdictionary(d, keyset):
return dict(kv for kv in d.items() if kv[0] in keyset)
def pyoutput(cmd):
proc = subprocess.Popen([env['python'], '-c', cmd],
stdout=subprocess.PIPE,
universal_newlines=True)
out = proc.communicate()[0]
return out.rstrip()
def pyconfigvar(name):
cmd = ('from distutils.sysconfig import get_config_var\n'
'print(get_config_var(%r))\n') % name
return pyoutput(cmd)
# copy system environment variables related to compilation
DefaultEnvironment(ENV=subdictionary(os.environ, '''
PATH PYTHONPATH
CPATH CPLUS_INCLUDE_PATH LIBRARY_PATH LD_RUN_PATH
LD_LIBRARY_PATH DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH
MACOSX_DEPLOYMENT_TARGET LANG
'''.split())
)
# Create construction environment
env = DefaultEnvironment().Clone()
# Variables definitions below work only with 0.98.1 or later.
env.EnsureSConsVersion(0, 98, 1)
# Customizable compile variables
vars = Variables('sconsvars.py')
vars.Add('tests',
'Fixed-string patterns for selecting unit test sources.', None)
vars.Add(EnumVariable('build',
'compiler settings', 'fast',
allowed_values=('debug', 'fast')))
vars.Add(EnumVariable('tool',
'C++ compiler toolkit to be used', 'default',
allowed_values=('default', 'intelc')))
vars.Add(BoolVariable('profile',
'build with profiling information', False))
vars.Add('python',
'Python executable to use for installation.', 'python3')
vars.Add(PathVariable('prefix',
'installation prefix directory', '/usr/local'))
vars.Update(env)
vars.Add(PathVariable('bindir',
'installation directory for executable [prefix/bin]',
env['prefix'] + '/bin'))
vars.Update(env)
env.Help(MY_SCONS_HELP % vars.GenerateHelpText(env))
btags = [env['build'], platform.machine()]
if env['profile']: btags.append('profile')
builddir = env.Dir('build/' + '-'.join(btags))
Export('env', 'pyoutput', 'pyconfigvar')
def GlobSources(pattern):
"""Same as Glob but also require that source node is a valid file.
"""
rv = [f for f in Glob(pattern) if f.srcnode().isfile()]
return rv
Export('GlobSources')
if os.path.isfile('sconscript.local'):
env.SConscript('sconscript.local')
env.SConscript('src/SConscript.main', variant_dir=builddir)
# vim: ft=python