Repository navigation
Expand file tree
/
Copy pathSConstruct
More file actions
150 lines (125 loc) · 4.4 KB
/
Copy pathSConstruct
File metadata and controls
150 lines (125 loc) · 4.4 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
MY_SCONS_HELP = """\
SCons build rules for the libdiffpy C++ library
Usage: scons [target] [var=value]
Targets:
lib build the shared library object [default]
install install everything under prefix directory
install-lib install the shared library object
install-include install the C++ header files
install-data install data files used by the library
alltests build the unit test program "alltests"
test execute unit tests (requires the cxxtest framework)
sdist create source distribution tarball from git repository
zerocounters remove cumulative coverage-count data
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 platform
from os.path import join as pjoin
from SCons.Script import *
def subdictionary(d, keyset):
return dict(kv for kv in d.items() if kv[0] in keyset)
# copy system environment variables related to compilation
DefaultEnvironment(ENV=subdictionary(os.environ, '''
PATH CPATH CPLUS_INCLUDE_PATH LIBRARY_PATH LD_RUN_PATH
LD_LIBRARY_PATH DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH
MACOSX_DEPLOYMENT_TARGET
HOME USERPROFILE HOMEDRIVE HOMEPATH APPDATA LOCALAPPDATA
'''.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')
# Set PATHs
if 'PREFIX' in os.environ:
vars.Add(PathVariable(
'prefix',
'installation prefix directory',
os.environ['PREFIX']))
vars.Update(env)
elif 'CONDA_PREFIX' in os.environ:
vars.Add(PathVariable(
'prefix',
'installation prefix directory',
os.environ['CONDA_PREFIX']))
vars.Update(env)
else:
vars.Add(PathVariable(
'prefix',
'installation prefix directory',
'/usr/local'))
vars.Update(env)
if env['PLATFORM'] == "win32":
include_path = pjoin(env['prefix'], 'Library', 'include')
lib_path = pjoin(env['prefix'], 'Library', 'lib')
shared_path = pjoin(env['prefix'], 'Library', 'share')
# Windows programs started by SCons, such as python for cxxtestgen,
# fail without these system variables.
for k in ('SYSTEMROOT', 'SYSTEMDRIVE', 'COMSPEC', 'PATHEXT', 'TEMP', 'TMP'):
if k in os.environ:
env['ENV'][k] = os.environ[k]
else:
include_path = pjoin(env['prefix'], 'include')
lib_path = pjoin(env['prefix'], 'lib')
shared_path = pjoin(env['prefix'], 'share')
vars.Add(PathVariable(
'libdir',
'installation directory for compiled programs',
lib_path,
PathVariable.PathAccept))
vars.Add(PathVariable(
'includedir',
'installation directory for C++ header files',
include_path,
PathVariable.PathAccept))
vars.Add(PathVariable(
'datadir',
'installation directory for architecture independent data',
shared_path,
PathVariable.PathAccept))
env.AppendUnique(CPPPATH=[include_path])
env.AppendUnique(LIBPATH=[lib_path])
# Customizable build variables
vars.Add(EnumVariable(
'build',
'compiler settings',
'fast', allowed_values=('fast', 'debug', 'develop', 'coverage')))
vars.Add(EnumVariable(
'tool',
'C++ compiler toolkit to be used',
'default', allowed_values=('default', 'clang', 'gcc', 'intelc')))
vars.Add(BoolVariable(
'enable_objcryst',
'enable objcryst support, when installed', None))
vars.Add(BoolVariable(
'profile',
'build with profiling information', False))
vars.Add(
'tests',
'fixed-string patterns for selecting unit tests', None)
vars.Add(BoolVariable(
'test_installed',
'build tests using the installed library.', False))
vars.Update(env)
env.Help(MY_SCONS_HELP % vars.GenerateHelpText(env))
env['has_objcryst'] = None
btags = [env['build'], platform.machine()]
if env['profile']: btags.append('profile')
builddir = env.Dir('build/' + '-'.join(btags))
Export('env')
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', variant_dir=builddir)
# vim: ft=python