forked from wdas/partio
-
Notifications
You must be signed in to change notification settings - Fork 4
/
SConstruct
83 lines (61 loc) · 2.47 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
import os
import platform
def kernel_version():
return os.popen("uname -r").read().strip().split('-')[0]
default_cxx="g++"
options=Variables("SConstruct.options")
uos = platform.system()
ver = kernel_version()
arch = platform.machine()
options.AddVariables(
('CXX','C++ compiler',default_cxx),
('mac','Is a mac', uos == 'Darwin'),
EnumVariable("TYPE",
"Type of build (e.g. optimize,debug)",
"optimize",
allowed_values=("profile","optimize","debug")),
)
variant_basename = '%s-%s-%s' % (uos, ver, arch)
AddOption('--prefix',
dest='prefix',
type='string',
nargs=1,
action='store',
default='',
metavar='DIR',
help='installation prefix')
env=Environment(options=options,
prefix=GetOption('prefix'))
type=env["TYPE"]
variant_basename += "-%s"%type
env.Append(CPPDEFINES=["PARTIO_USE_ZLIB"])
# --prefix is typically an absolute path, but we
# should also allow relative paths for convenience.
# prefix is the installation prefix, e.g. /usr
# variant_install_abs is the path to the install root.
prefix = GetOption('prefix') or os.path.join('dist', variant_basename)
if os.path.isabs(prefix):
variant_install_abs = prefix
else:
variant_install_abs = os.path.join(Dir(".").abspath, prefix)
# variant_build_abs is the path to the temporary build directory.
variant_build = os.path.join('build', variant_basename)
variant_build_abs = os.path.join(Dir(".").abspath, variant_build)
if env["mac"]==True:
env.Append(CPPDEFINES=["__DARWIN__"])
#env.Append(LINKFLAGS=["-m32"])
if env["TYPE"]=="optimize":
env.Append(CXXFLAGS="-fPIC -DNDEBUG -O3 -fno-strict-aliasing -Wall -Werror -Wstrict-aliasing=0 -mfpmath=sse -msse3".split())
if env["TYPE"]=="profile":
env.Append(CXXFLAGS="-fPIC -fno-strict-aliasing -DNDEBUG -g -fno-omit-frame-pointer -O3 -Wall -Werror -Wstrict-aliasing=0 -mfpmath=sse -msse3".split())
elif env["TYPE"]=="debug":
env.Append(CXXFLAGS=" -fPIC -g -Wall -Werror -Wstrict-aliasing=0")
VariantDir(variant_build, '.', duplicate=0)
def GetInstallPath():
return variant_install_abs
Export("env variant_build variant_build_abs variant_install_abs GetInstallPath")
env.SConscript(variant_build+"/src/lib/SConscript")
env.SConscript(variant_build+"/src/tools/SConscript")
env.SConscript(variant_build+"/src/tests/SConscript")
env.SConscript(variant_build+"/src/doc/SConscript")
env.SConscript(variant_build+"/src/py/SConscript")