-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwscript
135 lines (100 loc) · 4.24 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
#! /usr/bin/env python
# encoding: utf-8
top = '.'
out = 'build'
from waflib import Utils
import imp
def waftool(name):
return imp.load_module('waf_' + name, *imp.find_module(name, ['./waftools', './latticetester/waftools']))
version = waftool('version')
compiler = waftool('compiler')
deps = waftool('deps')
def options(ctx):
ctx.load('compiler_c compiler_cxx gnu_dirs waf_unit_test')
ctx.add_option('--link-static', action='store_true', help='statically link with dependencies')
ctx.add_option('--build-docs', action='store_true', default=False, help='build documentation')
ctx.add_option('--ntl', action='store', help='prefix under which NTL is installed')
ctx.add_option('--gmp', action='store', help='prefix under which GMP is installed')
def configure(ctx):
build_platform = Utils.unversioned_sys_platform()
ctx.msg("Build platform", build_platform)
ctx.load('compiler_c compiler_cxx gnu_dirs waf_unit_test')
ctx.check(features='cxx', cxxflags='-std=c++14')
ctx.env.append_unique('CXXFLAGS', ['-std=c++14', '-Wall'])
ctx.check(features='c', cflags='-std=c99')
ctx.env.append_unique('CFLAGS', ['-std=c99', '-Wall'])
# suppress Boost ublas warnings
compiler.add_cxx_flag_if_supported(ctx, '-Wno-unused-local-typedefs')
compiler.add_cxx_flag_if_supported(ctx, '-Wno-unused-function')
compiler.add_cxx_flag_if_supported(ctx, '-Wnon-virtual-dtor')
compiler.add_cxx_flag_if_supported(ctx, '-Wshorten-64-to-32') # clang
if ctx.options.link_static:
#flags = ['-static', '-static-libgcc', '-static-libstdc++']
flags = ['-static-libgcc', '-static-libstdc++']
if ctx.check(features='cxx cxxprogram',
linkflags=flags,
mandatory=False):
ctx.env.append_unique('LINKFLAGS', flags)
# options
if ctx.options.ntl:
deps.add_deps_path(ctx, 'NTL', ctx.options.ntl)
if ctx.options.gmp:
deps.add_deps_path(ctx, 'GMP', ctx.options.gmp)
ctx_check = deps.shared_or_static(ctx, ctx.check)
# NTL
# if ctx.options.ntltypes: # ntlttypes are now mandatory
ctx_check(features='cxx cxxprogram', header_name='NTL/vector.h')
ctx_check(features='cxx cxxprogram', lib='ntl', uselib_store='NTL')
# GMP
ctx_check(features='cxx cxxprogram', header_name='gmp.h')
ctx_check(features='cxx cxxprogram', lib='gmp', uselib_store='GMP')
# Doxygen
if ctx.options.build_docs:
ctx.env.BUILD_DOCS = True
if not ctx.find_program('doxygen', var='DOXYGEN', mandatory=False):
ctx.fatal('Doxygen is required for building documentation.\n' +
'Get it from http://www.stack.nl/~dimitri/doxygen/')
ctx.version_file('latticetester')
version_tag = ctx.set_version('latticetester')
ctx.define('LATTICETESTER_VERSION', version_tag)
ctx.msg("Setting LatticeTester version", version_tag)
# definitions of DEBUG and NDEBUG flags: not used in this version
# if not hasattr(ctx.options, 'nested') or not ctx.options.nested:
# # build variants
# env = ctx.env.derive()
# env.detach()
# # release (default)
# ctx.env.append_unique('CXXFLAGS', ['-O2'])
# ctx.define('NDEBUG', 1)
# ctx.setenv('debug', env)
# ctx.env.append_unique('CXXFLAGS', ['-g'])
# ctx.define('DEBUG', 1)
def distclean(ctx):
verfile = ctx.path.find_node('VERSION')
if verfile:
verfile.delete()
from waflib import Scripting
Scripting.distclean(ctx)
def build(ctx):
ctx.add_group('group1')
ctx.add_group('group2')
if ctx.variant:
print("Building variant `%s'" % (ctx.variant,))
ctx.set_group('group1')
ctx.recurse('src')
ctx.recurse('data')
ctx.set_group('group2')
ctx.recurse('examples')
ctx.add_group('group6')
ctx.set_group('group6')
if not hasattr(ctx.options, 'nested') or not ctx.options.nested:
ctx.recurse('progs')
if ctx.env.BUILD_DOCS:
ctx.recurse('doc')
ctx.recurse('data')
# ctx.recurse('analysis') # probably broken, not used in the current version
# # build variants not used in this version
# from waflib.Build import BuildContext
# class debug(BuildContext):
# cmd = 'debug'
# variant = 'debug'