-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwscript
More file actions
278 lines (245 loc) · 7.98 KB
/
wscript
File metadata and controls
278 lines (245 loc) · 7.98 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
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
import os.path
import glob
srcdir="."
APPNAME = "qctool"
VERSION = "2.2.0"
variants = {
"release": {
"command": "{command}",
"cxxflags": [ '-O3' ],
"linkflags": []
},
"debug": {
"command": "{command}_debug",
"cxxflags": [ '-g' ],
"linkflags": []
}
} ;
subdirs = [
'genfile', 'statfile', 'appcontext',
'worker',
'3rd_party', 'components', 'qcdb', 'metro',
'apps'
]
def options( opt ):
opt.load( 'compiler_cxx' )
opt.load( 'compiler_c' )
opt.add_option( "--all_targets", action='store_true', default=False, help='Create all targets, not just qctool.')
opt.add_option( "--vectorise", action='store_true', default=False, help='Use aggresive vectorisation options for maximum performance.')
opt.add_option( '--variant', action='store', default='release', help='set the variant name' )
#-----------------------------------
# CONFIGURE
#-----------------------------------
def configure( cfg ):
configure_variant( cfg, 'release' )
configure_variant( cfg, 'debug' )
def configure_variant( cfg, variant ):
cfg.setenv( variant )
cfg.env[ 'VERSION' ] = VERSION ;
cfg.load( 'compiler_c' )
cfg.load( 'compiler_cxx' )
print( "Using prefix\t\t\t\t :", cfg.env[ 'PREFIX' ] )
cxxflags = cfg.env[ 'CXXFLAGS' ]
linkflags = cfg.env[ 'LINKFLAGS' ]
# We now require C++11.
if cfg.check( cxxflags = '-std=c++11' ):
cxxflags.append( '-std=c++11' )
cxxflags.append( '-Wno-deprecated-declarations' )
else:
raise( "QCTOOL now requires a C++11-enabled compiler." )
cxxflags.extend(
[
"-mavx", "-mssse3", "-msse2", "-msse4.1", "-msse4.2",
'-Wall',
'-pedantic',
'-Wno-long-long', # suppress warnings in Eigen and Boost.
# The following are to suppress many warnings in boost
'-Wno-unused-local-typedefs',
'-Wno-c++11-long-long',
'-Wno-keyword-macro',
'-Wno-unused-const-variable',
'-Wno-deprecated-register',
'-Wno-unused-function',
'-Wno-redeclared-class-member'
]
)
if cfg.options.vectorise:
# These are disabled by default as not always safe.
for flag in [ '-msse2', '-mavx', '-mssse3']:
if cfg.check( cxxflags = flag ):
cxxflags.append( flag )
cxxflags.extend( variants[ variant ][ "cxxflags" ] )
linkflags.extend( variants[ variant ][ "linkflags" ] )
configure_blas( cfg )
configure_time( cfg )
import platform
if platform.system() == 'Darwin':
configure_darwin( cfg, cxxflags, linkflags )
else:
configure_linux( cfg, cxxflags, linkflags )
# Now check for libraries
if check_cxx( cfg, lib = 'm', uselib_store = 'M' ):
cfg.define( 'HAVE_M', 1 )
if check_cxx( cfg, lib='z', uselib_store='ZLIB' ):
cfg.define( 'HAVE_ZLIB', 1 )
# disable support for some things
cfg.define( 'HAVE_BZIP2', 0 )
cfg.define( 'HAVE_MGL', 0 )
cfg.define( 'HAVE_CAIRO', 0 )
# sqlite3, eigen, zstd are part of this repo
cfg.define( 'HAVE_SQLITE3', 1 )
cfg.define( 'HAVE_EIGEN', 1 )
cfg.define( 'HAVE_ZSTD', 1 )
# Boost libs are now contained in the repo
cfg.define( "HAVE_BOOST_IOSTREAMS", 1 )
cfg.define( "HAVE_BOOST_FILESYSTEM", 1 )
cfg.define( "HAVE_BOOST_SYSTEM", 1 )
cfg.define( "HAVE_BOOST_THREAD", 1 )
cfg.define( "HAVE_BOOST_DATE_TIME", 1 )
cfg.define( "HAVE_BOOST_UNIT_TEST_FRAMEWORK", 1 )
cfg.define( "HAVE_BOOST_TIMER", 1 )
cfg.define( "HAVE_BOOST_REGEX", 1 )
cfg.define( "HAVE_BOOST_MATH", 1 )
cfg.define( "HAVE_BOOST_FUNCTION", 1 )
cfg.define( "HAVE_BOOST_SPIRIT", 1 )
cfg.define( "BOOST_FILESYSTEM_VERSION", 3 )
cfg.define( 'EIGEN_NO_DEBUG', 1 )
cxxflags.append( "-I." )
cfg.env[ 'CXXFLAGS' ] = cxxflags
cfg.env[ 'LINKFLAGS' ] = linkflags
cfg.write_config_header( '%s/config/config.hpp' % variant )
def check_cxx( cfg, **kwargs ):
try:
cfg.check_cxx( **kwargs )
return True
except:
return False
def configure_blas( cfg ):
import platform
if platform.system() == 'Darwin':
if cfg.check_cxx(
lib = 'cblas',
fragment = '#include "cblas.h"\nint main() {}',
cxxflags = '-I/System/Library/Frameworks/vecLib.framework/Headers',
uselib_store = 'CBLAS'
):
cfg.define( 'HAVE_CBLAS', 1 )
if check_cxx(
cfg,
header_name = 'clapack.h',
lib = 'clapack',
cxxflags = '-I/System/Library/Frameworks/vecLib.framework/Headers',
uselib_store = 'CLAPACK'
):
cfg.define( 'HAVE_CLAPACK', 1 )
cfg.define( 'HAVE_LAPACK', 1 )
else:
blasCode = """#include "cblas.h"
int main() {
float v[10] ;
float result = cblas_snrm2( 1, v, 1 ) ;
return int(result) ;
}
"""
if check_cxx( cfg, lib = 'cblas', fragment = blasCode, uselib_store = 'CBLAS' ):
cfg.define( 'HAVE_CBLAS', 1 ) ;
elif check_cxx( cfg, lib = 'blas', fragment = blasCode, uselib_store = 'CBLAS' ):
cfg.define( 'HAVE_CBLAS', 1 ) ;
elif check_cxx( cfg, lib = 'openblas', fragment = blasCode, uselib_store = 'CBLAS' ):
cfg.define( 'HAVE_CBLAS', 1 ) ;
if check_cxx(
cfg,
lib = 'lapack',
uselib_store = 'LAPACK'
):
cfg.define( 'HAVE_LAPACK', 1 )
def configure_time( cfg ):
if check_cxx( cfg, header_name='mach/mach_time.h', uselib_store = 'MACH_TIME' ):
cfg.define( 'HAVE_MACH_TIME', 1 )
if check_cxx( cfg, header_name = 'sys/time.h', fragment = '#include "sys/time.h"\nint main(int argc, char** argv ) { struct timeval current_time ; gettimeofday( ¤t_time, 0 ) ; return 0 ; }' ):
cfg.define( 'HAVE_GETTIMEOFDAY', 1 )
def configure_darwin( cfg, cxxflags, linkflags ):
linkflags.extend( [ '-framework', 'CoreFoundation' ])
def configure_linux( cfg, cxxflags, linkflags ):
check_cxx( cfg, lib='rt', uselib_store='rt', msg = 'rt' )
check_cxx( cfg, lib='pthread', uselib_store='pthread', msg = 'pthread' )
check_cxx( cfg, lib='dl', uselib_store='dl', msg = 'dl' )
# This piece of code comes from
# https://gitlab.com/ita1024/waf/-/blob/master/demos/variants/wscript
# It makes the --variant command-line option work.
def init(ctx):
from waflib.Options import options
from waflib.Build import BuildContext, CleanContext, InstallContext, UninstallContext
from waflib.Configure import ConfigurationContext
for y in (BuildContext, CleanContext, InstallContext, UninstallContext, ConfigurationContext):
name = y.__name__.replace('Context','').lower()
class tmp(y):
cmd = name
variant = options.variant
#-----------------------------------
# BUILD
#-----------------------------------
def create_app( bld, name, use = '' ):
bld.program(
target = '%s_v%s' % ( name, VERSION ),
source = 'apps/' + name + '.cpp',
includes = './ include',
use = use,
install_path = os.path.join( bld.env[ 'PREFIX' ], 'bin' )
)
def build( bld ):
print( "Building %s variant..." % bld.variant )
bld.env[ 'VERSION' ] = VERSION
bld(
name = 'package_revision',
target = "config/package_revision_autogenerated.hpp",
always = True,
on_result = True,
rule = compute_revision,
)
bld.stlib(
target = "qctool-lib",
source = bld.path.ant_glob( "src/*.cpp" ),
includes = "./include",
export_includes = "./include",
use = "genfile statfile appcontext"
)
for subdir in subdirs:
bld.recurse( subdir )
def compute_revision(task):
import os, sqlite3
revision = "unknown"
filename = "../.fslckout"
if os.path.exists( filename ):
db = sqlite3.connect( filename )
c = db.cursor()
c.execute( "SELECT value FROM vvar WHERE name == 'checkout-hash'" )
result = c.fetchone()
revision = result[0][0:10]
target = open( task.outputs[0].abspath(), "w" )
target.write(
"""
#ifndef PACKAGE_REVISION_HPP
#define PACKAGE_REVISION_HPP
namespace globals {
char const* const package_version = "%s" ;
char const* const package_revision = "%s" ;
}
#endif
""" % ( VERSION, revision ) )
return 0 # success
def release( bld ):
import sys
from waflib.Options import options
sys.path.append( "release" )
import Release.TestHarness
import Release.ReleaseBuilder
if options.all_targets:
apps = [ 'qctool', 'inthinnerator', 'ldbird', 'hptest' ]
else:
apps = [ 'qctool' ]
for app in apps:
executable = "build/release/apps/%s_v%s" % ( app, VERSION )
builder = Release.ReleaseBuilder.ReleaseBuilder( app, VERSION, executable )
release = builder.build()
print( "++ %s release tarball created in", release[ "release_tarball" ] )