-
Notifications
You must be signed in to change notification settings - Fork 8
/
SConstruct
117 lines (104 loc) · 3.95 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import os, sys, glob
## Prefic for install(ed) files
## prefix="/usr/local"
## Library version
lib_version="0.1.0"
## Library name
lib_name="iers2010"
## Include dir (following prefix) if any
inc_dir="iers2010"
## the rootdir of the project
root_dir=os.path.abspath(os.getcwd())
## get number of CPUs and use for parallel builds
num_cpu = int(os.environ.get('NUM_CPU', 2))
SetOption('num_jobs', num_cpu)
print("running with -j %s" % GetOption('num_jobs'))
## user can specify the --prefix variables (expanded to $PREFIX)
AddOption('--prefix',
dest='prefix',
type='string',
nargs=1,
action='store',
metavar='DIR',
help='installation prefix',
default='/usr/local')
AddOption('--cxx',
dest='cxx',
type='string',
nargs=1,
action='store',
metavar='CXX',
help='C++ Compiler',
default=None)
AddOption('--std',
dest='std',
type='string',
nargs=1,
action='store',
metavar='STD',
help='C++ Standard [11/14/17/20]',
default='17')
## Source files (for lib)
lib_src_files = glob.glob(r"src/*.cpp")
lib_src_files += glob.glob(r"src/iau/*.cpp")
lib_src_files += glob.glob(r"src/ch5/*.cpp")
lib_src_files += glob.glob(r"src/ch7/*.cpp")
lib_src_files += glob.glob(r"src/ch8/*.cpp")
lib_src_files += glob.glob(r"src/ch9/*.cpp")
lib_src_files += glob.glob(r"src/ch10/*.cpp")
lib_src_files += glob.glob(r"src/hardisp/*.cpp")
lib_src_files += glob.glob(r"src/dehanttideinel/*.cpp")
lib_src_files += glob.glob(r"src/extra/atmosphere/*.cpp")
lib_src_files += glob.glob(r"src/interpf/*.cpp")
lib_src_files += glob.glob(r"src/eop/*.cpp")
## Headers (for lib)
hdr_src_files = glob.glob(r"src/*.hpp")
## Environments ...
denv = Environment(PREFIX=GetOption(
'prefix'), CXXFLAGS='-std=c++17 -g -pg -Wall -Wextra -Werror -pedantic -W -Wshadow -Winline -Wdisabled-optimization -DDEBUG -DEIGEN_NO_AUTOMATIC_RESIZING')
penv = Environment(PREFIX=GetOption(
'prefix'), CXXFLAGS='-std=c++17 -Wall -Wextra -Werror -pedantic -W -Wshadow -Winline -O2 -march=native -DEIGEN_NO_AUTOMATIC_RESIZING')
## Command line arguments ...
debug = ARGUMENTS.get('debug', 0)
make_test = ARGUMENTS.get('make-test', 0)
## Construct the build enviroment
env = denv.Clone() if int(debug) else penv.Clone()
## What compiler should we be using ?
if GetOption('cxx') is not None: env['CXX'] = GetOption('cxx')
## Set the C++ standard
cxxstd = GetOption('std')
env.Append(CXXFLAGS=' --std=c++{}'.format(cxxstd))
## (shared) library ...
vlib = env.SharedLibrary(source=lib_src_files, target=lib_name, CPPPATH=[
'src/'], SHLIBVERSION=lib_version)
## Build ....
env.Program(source='src/hardisp.cpp',
target='bin/hardisp',
LIBS=vlib+['geodesy', 'datetime', 'sofa_c'],
LIBPATH='.',
CPPPATH=['src/'])
env.Alias(target='install', source=env.Install(dir=os.path.join(
GetOption('prefix'), 'include', inc_dir), source=hdr_src_files))
env.Alias(target='install', source=env.InstallVersionedLib(
dir=os.path.join(GetOption('prefix'), 'lib'), source=vlib))
## Tests ...
if make_test:
#tests_sources = glob.glob(r"test/*.cpp")
#tests_sources = glob.glob(r"test/cel2ter/*.cpp")
#tests_sources = glob.glob(r"test/parsers/*.cpp")
tests_sources = glob.glob(r"test/fortran_unit_tests/test_*.cpp")
tests_sources += glob.glob(r"test/internal/internal_*.cpp")
tests_sources += glob.glob(r"test/sofa_unit_tests/sofa_*.cpp")
tests_sources += glob.glob(r"test/eop/*.cpp")
link_w = "test/sofa_unit_tests/unit_test_help.cpp"
env.Append(RPATH=root_dir)
for tsource in tests_sources:
pth = os.path.dirname(tsource)
bsn = os.path.basename(tsource)
ttarget = os.path.join(pth, bsn.replace(
'_', '-').replace('.cpp', '.out'))
env.Program(target=ttarget,
source=[tsource, link_w],
CPPPATH='src/',
LIBS=vlib+['geodesy', 'datetime', 'sofa_c'],
LIBPATH=root_dir, RPATH=["."])