-
Notifications
You must be signed in to change notification settings - Fork 19
/
wscript
281 lines (231 loc) · 7.72 KB
/
wscript
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# -*- python -*-
# Top-level build-script for Gkyl
## _______ ___
## + 6 @ |||| # P ||| +
import datetime
import os
import platform
import sys
APPNAME = 'gkyl'
VER = "0.1"
now = datetime.datetime.now()
VERSION = VER + "-"+now.strftime("%Y-%m-%d")
top = '.'
out = 'build'
# extra flags to pass to linker
EXTRA_LINK_FLAGS = []
from waflib import TaskGen
from waflib.Options import options
def options(opt):
opt.load('compiler_c compiler_cxx')
opt.load('gkyl luajit mpi adios sqlite3 cutools nccl gkylzero superlu openblas',
tooldir='waf_tools')
def configure(conf):
r"""Configure Gkyl build"""
# load tools
conf.load('compiler_c compiler_cxx')
conf.load('cutools', tooldir='waf_tools')
conf.check_gkyl()
conf.check_luajit()
conf.check_mpi()
conf.check_adios()
conf.check_sqlite3()
conf.check_cutools()
conf.check_nccl()
conf.check_superlu()
conf.check_openblas()
conf.check_gkylzero()
# standard install location for dependencies
gkydepsDir = os.path.expandvars('$HOME/gkylsoft')
# add current build directory to pick up config header
conf.env.append_value('INCLUDES', ['.'])
# load options for math and dynamic library
conf.env.LIB_M = ['m']
conf.env.LIB_DL = ['dl']
# write out configuration info into header
conf.write_config_header('gkylconfig.h')
from waflib import Task
class GitTip(Task.Task):
always_run = True # need to force running every time
run_str = r'echo \#define GKYL_GIT_CHANGESET \"`git describe --abbrev=12 --always --dirty=+`\" > ${TGT}'
def build(bld):
gitTip = GitTip(env=bld.env)
gitTip.set_outputs(bld.path.find_or_declare('gkylgittip.h'))
bld.add_to_group(gitTip)
if bld.jobs > 16:
bld.jobs = 16
# recurse down directories and build C++ code
bld.recurse("Comm")
bld.recurse("Eq")
bld.recurse("Grid")
bld.recurse("Lib")
bld.recurse("Proto")
bld.recurse("Tool")
bld.recurse("Unit")
bld.recurse("Updater")
if bld.env['CUTOOLS_FOUND']:
bld.recurse("Cuda")
# Sometimes there is an issue with an existing build of sqlite on
# a Linux machine. In that case, sqlite support can be
# disabled. WARNING: This means the regression testing system
# won't work.
if bld.env['USE_SQLITE']:
bld.recurse("sqlite3")
# build executable
buildExec(bld)
### install LuaJIT code
# - xsys
xsys_dir = bld.path.find_dir('xsys')
bld.install_files(
"${PREFIX}/bin/xsys",
xsys_dir.ant_glob('**/*.lua'),
cwd=xsys_dir, relative_trick=True)
# - sci
sci_dir = bld.path.find_dir('sci')
bld.install_files(
"${PREFIX}/bin/sci",
sci_dir.ant_glob('**/*.lua'),
cwd=sci_dir, relative_trick=True)
# - Unit
Unit_dir = bld.path.find_dir('Unit')
bld.install_files(
"${PREFIX}/bin/Unit",
Unit_dir.ant_glob('**/*.lua'),
cwd=Unit_dir, relative_trick=True)
# - Regression
Regression_dir = bld.path.find_dir('Regression')
bld.install_files(
"${PREFIX}/bin/Regression",
Regression_dir.ant_glob('**/*.lua'),
cwd=Regression_dir, relative_trick=True)
# - Tool
Tool_dir = bld.path.find_dir('Tool')
bld.install_files(
"${PREFIX}/bin/Tool",
Tool_dir.ant_glob('**/*.lua'),
cwd=Tool_dir, relative_trick=True)
bld.install_files(
"${PREFIX}/bin/Tool",
Tool_dir.ant_glob('**/*.md'),
cwd=Tool_dir, relative_trick=True)
# - Sqlite3
Sqlite_dir = bld.path.find_dir('sqlite3')
bld.install_files(
"${PREFIX}/bin/sqlite3",
Sqlite_dir.ant_glob('**/*.lua'),
cwd=Sqlite_dir, relative_trick=True)
# - Lib
Lib_dir = bld.path.find_dir('Lib')
bld.install_files(
"${PREFIX}/bin/Lib",
Lib_dir.ant_glob('**/*.lua'),
cwd=Lib_dir, relative_trick=True)
# - Grid
Grid_dir = bld.path.find_dir('Grid')
bld.install_files(
"${PREFIX}/bin/Grid",
Grid_dir.ant_glob('**/*.lua'),
cwd=Grid_dir, relative_trick=True)
# - DataStruct
DataStruct_dir = bld.path.find_dir('DataStruct')
bld.install_files(
"${PREFIX}/bin/DataStruct",
DataStruct_dir.ant_glob('**/*.lua'),
cwd=DataStruct_dir, relative_trick=True)
# - Eq
Eq_dir = bld.path.find_dir('Eq')
bld.install_files(
"${PREFIX}/bin/Eq",
Eq_dir.ant_glob('**/*.lua'),
cwd=Eq_dir, relative_trick=True)
# - Updater
Updater_dir = bld.path.find_dir('Updater')
bld.install_files(
"${PREFIX}/bin/Updater",
Updater_dir.ant_glob('**/*.lua'),
cwd=Updater_dir, relative_trick=True)
# - App
App_dir = bld.path.find_dir('App')
bld.install_files(
"${PREFIX}/bin/App",
App_dir.ant_glob('**/*.lua'),
cwd=App_dir, relative_trick=True)
# - Cuda
Cuda_dir = bld.path.find_dir('Cuda')
bld.install_files(
"${PREFIX}/bin/Cuda",
Cuda_dir.ant_glob('**/*.lua'),
cwd=Cuda_dir, relative_trick=True)
# - Comm
Comm_dir = bld.path.find_dir('Comm')
bld.install_files(
"${PREFIX}/bin/Comm",
Comm_dir.ant_glob('**/*.lua'),
cwd=Comm_dir, relative_trick=True)
# - Io
Io_dir = bld.path.find_dir('Io')
bld.install_files(
"${PREFIX}/bin/Io",
Io_dir.ant_glob('**/*.lua'),
cwd=Io_dir, relative_trick=True)
# - Basis
Basis_dir = bld.path.find_dir('Basis')
bld.install_files(
"${PREFIX}/bin/Basis",
Basis_dir.ant_glob('**/*.lua'),
cwd=Basis_dir, relative_trick=True)
# - Proto/
Proto_dir = bld.path.find_dir('Proto')
bld.install_files(
"${PREFIX}/bin/Proto",
Proto_dir.ant_glob('**/*.lua'),
cwd=Proto_dir, relative_trick=True)
def appendToList(target, val):
if type(val) == list:
target.extend(val)
else:
target.append(val)
def buildExec(bld):
r"""Build top-level executable"""
# Link flags on Linux
if platform.system() == 'Linux':
bld.env.LINKFLAGS_cstlib = ['-Wl,-Bstatic,-E']
bld.env.LINKFLAGS_cxxstlib = ['-Wl,-Bstatic,-E']
bld.env.STLIB_MARKER = '-Wl,-Bstatic,-E'
bld.env.SHLIB_MARKER = '-Wl,-Bdynamic,--no-as-needed'
# list of objects to use
useList = 'lib datastruct eq unit comm updater tool proto basis grid gkylzero LUAJIT ADIOS MPI SUPERLU OPENBLAS M DL'
if bld.env['USE_SQLITE']:
useList = ' sqlite3 ' + useList
if bld.env['CUTOOLS_FOUND']:
useListCuda = ' cuda CUTOOLS unit_cu updater_cu NCCL comm_cu '
useList = useListCuda + useList
# set RPATH
fullRpath = []
appendToList(fullRpath, bld.env.RPATH) # user specified RPATH
appendToList(fullRpath, bld.env.LIBDIR)
appendToList(fullRpath, bld.env.LIBPATH_LUAJIT)
appendToList(fullRpath, bld.env.LIBPATH_gkylzero)
appendToList(fullRpath, bld.env.LIBPATH_ADIOS)
# build gkyl executable
source = ['gkyl.cxx']
if bld.env['CUTOOLS_FOUND']:
bld(
target='culink',
use = useListCuda,
features = 'cxx culink',
name = 'culink'
)
bld.add_group()
appendToList(source, 'culink.o')
bld.program(
source = source, target='gkyl',
includes = 'Unit Lib Comm',
use = useList,
linkflags = EXTRA_LINK_FLAGS,
rpath = fullRpath,
lib = 'pthread ' + bld.env.EXTRALIBS,
)
def dist(ctx):
ctx.algo = "zip" # use ZIP instead of tar.bz2
ctx.excl = " **/.waf* **/*~ **/*.pyc **/*.swp **/.lock-w* configure-par.sh **/.hg **/.hgignore install-deps/build-opts.sh install-deps/luajit-2.0 install-deps/adios2-2.* install-deps/luarocks-2.4.3* install-deps/openmpi-* build build-par build-ser"