-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
85 lines (72 loc) · 4.77 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
import os
from subprocess import call
import multiprocessing
#================================================================================================================================================
# General setup
#================================================================================================================================================
# Create Scons environment
env=Environment(CPPPATH=[],
CPPDEFINES=[],
LIBS=[])
# Relevant directories
project_root = os.path.dirname(os.path.abspath('SConstruct'))
project_include = project_root + '/include'
project_dependencies_sgpp = project_root + '/external_dependencies/SGpp'
#================================================================================================================================================
# Setup and build SGpp as a dependency of the actual application project
#================================================================================================================================================
# Add option to build sgpp
AddOption('--build-sgpp',
dest='build-sgpp',
nargs=1, type='string',
action='store',
metavar='DIR',
help='installation prefix')
# Does the SGpp submodule directory exist? If not, print error and exit
if not os.path.exists(project_dependencies_sgpp):
print("FATAL_ERROR! Could not find the SConstruct file within the SGpp directory!\n"\
"To fix this error, clone to SGpp submodule by running the following command"\
"within the project root directory:\n"\
"git submodule update --init external_dependencies/SGpp")
quit()
# If build-sgpp flag is set to True, build SGpp again
if GetOption('build-sgpp') == 'True':
# Get processor count for parallel builds
parallel_builds = multiprocessing.cpu_count()
# Build SGpp
# We build all modules to demonstrate how it is done - to save compile time you might want to deactivate some modules
call(["scons", "SG_BASE=1", "SG_DATADRIVEN=1", "SG_COMBIGRID=1", "SG_OPTIMIZATION=1", # Flags for which SGpp modules to build
"SG_QUADRATURE=1", "SG_SOLVER=1", "SG_PDE=1", "SG_MISC=1", # Flags for which SGpp modules to build
"SG_JAVA=0", "SG_PYTHON=0", "SG_MATLAB=0", # Which language wrappers should be created
"RUN_BOOST_TESTS=0", "RUN_PYTHON_TESTS=0", # Do not run any unit tests
"OPT=1", # Create optimized build
"PRINT_INSTRUCTIONS=0", "VERBOSE=0", "-j" + str(parallel_builds)], # Convienience flags for silent and fast build
cwd=project_dependencies_sgpp) # Working directory (submodule folder)
# Add SGpp Header paths, one path per SGpp Module
env.Append(CPPPATH=[project_dependencies_sgpp + "/base/src"])
env.Append(CPPPATH=[project_dependencies_sgpp + "/datadriven/src"])
env.Append(CPPPATH=[project_dependencies_sgpp + "/combigrid/src"])
env.Append(CPPPATH=[project_dependencies_sgpp + "/optimization/src"])
env.Append(CPPPATH=[project_dependencies_sgpp + "/quadrature/src"])
env.Append(CPPPATH=[project_dependencies_sgpp + "/solver/src"])
env.Append(CPPPATH=[project_dependencies_sgpp + "/pde/src"])
env.Append(CPPPATH=[project_dependencies_sgpp + "/misc/src"])
# Add SGpp Module Libraries - if you deactivate one SG++ module, you have to remove the respective line as well
# since the library file won't be there
env.Append(LIBS=[File(project_dependencies_sgpp + "/lib/libsgppbase.so")])
env.Append(LIBS=[File(project_dependencies_sgpp + "/lib/libsgppdatadriven.so")])
env.Append(LIBS=[File(project_dependencies_sgpp + "/lib/libsgppcombigrid.so")])
env.Append(LIBS=[File(project_dependencies_sgpp + "/lib/libsgppoptimization.so")])
env.Append(LIBS=[File(project_dependencies_sgpp + "/lib/libsgppquadrature.so")])
env.Append(LIBS=[File(project_dependencies_sgpp + "/lib/libsgppsolver.so")])
env.Append(LIBS=[File(project_dependencies_sgpp + "/lib/libsgpppde.so")])
env.Append(LIBS=[File(project_dependencies_sgpp + "/lib/libsgppmisc.so")])
#================================================================================================================================================
# Setup and build application
#================================================================================================================================================
# We want to have at least C++11
env.Append(CXXFLAGS="-std=c++11")
# Include application headers
env.Append(CPPPATH=[project_include])
# Call Sconscript in the src directory -> do the build in the build directory with variant_dir
env.SConscript('src/SConscript', variant_dir='build', exports='env', duplicate=0, CPPPATH='include')