forked from daos-stack/daos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSConstruct
More file actions
123 lines (98 loc) · 4.05 KB
/
SConstruct
File metadata and controls
123 lines (98 loc) · 4.05 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
"""Build DAOS"""
import sys
import os
import platform
from SCons.Script import BUILD_TARGETS
sys.path.insert(0, os.path.join(Dir('#').abspath, 'utils'))
DESIRED_FLAGS = ['-Wno-gnu-designator',
'-Wno-missing-braces',
'-Wno-gnu-zero-variadic-macro-arguments',
'-Wno-tautological-constant-out-of-range-compare',
'-Wframe-larger-than=4096']
PP_ONLY_FLAGS = ['-Wno-parentheses-equality', '-Wno-builtin-requires-header',
'-Wno-unused-function']
DAOS_VERSION = "0.0.2"
def is_platform_arm():
"""Detect if platform is ARM"""
processor = platform.machine()
arm_list = ["arm", "aarch64", "arm64"]
if processor.lower() in arm_list:
return True
return False
def set_defaults(env):
"""set compiler defaults"""
AddOption('--preprocess',
dest='preprocess',
action='store_true',
default=False,
help='Preprocess selected files for profiling')
env.Append(CCFLAGS=['-g', '-Wshadow', '-Wall', '-Wno-missing-braces',
'-fpic', '-D_GNU_SOURCE'])
env.Append(CCFLAGS=['-O2', '-DDAOS_VERSION=\\"' + DAOS_VERSION + '\\"'])
env.AppendIfSupported(CCFLAGS=DESIRED_FLAGS)
if GetOption("preprocess"):
#could refine this but for now, just assume these warnings are ok
env.AppendIfSupported(CCFLAGS=PP_ONLY_FLAGS)
def preload_prereqs(prereqs):
"""Preload prereqs specific to platform"""
prereqs.define('cmocka', libs=['cmocka'], package='libcmocka-devel')
prereqs.define('readline', libs=['readline', 'history'],
package='readline')
reqs = ['cart', 'argobots', 'pmdk', 'cmocka',
'uuid', 'crypto', 'fuse', 'protobufc']
if not is_platform_arm():
reqs.extend(['spdk', 'isal'])
prereqs.load_definitions(prebuild=reqs)
def scons():
"""Execute build"""
BUILD_TARGETS.append('fixtest')
if os.path.exists('scons_local'):
try:
sys.path.insert(0, os.path.join(Dir('#').abspath, 'scons_local'))
from prereq_tools import PreReqComponent
print ('Using scons_local build')
except ImportError:
print ('Using traditional build')
env = Environment(TOOLS=['extra', 'default'])
opts_file = os.path.join(Dir('#').abspath, 'daos_m.conf')
opts = Variables(opts_file)
commits_file = os.path.join(Dir('#').abspath, 'utils/build.config')
if not os.path.exists(commits_file):
commits_file = None
prereqs = PreReqComponent(env, opts, commits_file)
preload_prereqs(prereqs)
opts.Save(opts_file, env)
env.Alias('install', '$PREFIX')
platform_arm = is_platform_arm()
Export('DAOS_VERSION', 'env', 'prereqs', 'platform_arm')
if env['PLATFORM'] == 'darwin':
# generate .so on OSX instead of .dylib
env.Replace(SHLIBSUFFIX='.so')
set_defaults(env)
# generate targets in specific build dir to avoid polluting the source code
VariantDir('build', '.', duplicate=0)
SConscript('build/src/SConscript')
buildinfo = prereqs.get_build_info()
buildinfo.gen_script('.build_vars.sh')
buildinfo.save('.build_vars.json')
env.InstallAs("$PREFIX/TESTING/.build_vars.sh", ".build_vars.sh")
env.InstallAs("$PREFIX/TESTING/.build_vars.json", ".build_vars.json")
# install the test_runner code from scons_local
SConscript('build/scons_local/test_runner/SConscript')
# install the build verification tests
SConscript('utils/bvtest/scripts/SConscript')
# install the configuration files
SConscript('utils/config/SConscript')
env.Command("fixtest", "./utils/bvtest/OrteRunner.py",
[Copy("$PREFIX/TESTING/test_runner/",
"./utils/bvtest/OrteRunner.py")])
Default('build')
Depends('install', 'build')
Depends('fixtest', 'install')
try:
#if using SCons 2.4+, provide a more complete help
Help(opts.GenerateHelpText(env), append=True)
except TypeError:
Help(opts.GenerateHelpText(env))
if __name__ == "SCons.Script":
scons()