/
wscript
161 lines (126 loc) · 5.09 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
#!/usr/bin/env python
# coding: utf-8
top = '.'
out = 'build'
from waflib import Utils
import imp
def waftool(name):
return imp.load_module('waf_' + name, *imp.find_module(name, ['./latticetester/waftools']))
version = waftool('version')
compiler = waftool('compiler')
deps = waftool('deps')
def options(ctx):
ctx.recurse('latticetester')
ctx.add_option('--boost', action='store', help='prefix under which Boost is installed')
ctx.add_option('--fftw', action='store', help='prefix under which FFTW is installed')
ctx.add_option('--build-docs', action='store_true', default=False, help='build documentation')
ctx.add_option('--build-examples', action='store_true', default=False, help='build examples (and tests them)')
ctx.add_option('--build-light-conda', action='store_true', default=False, help='build conda package without embedding LatNetBuilder inside')
ctx.add_option('--build-conda', action='store_true', default=False, help='build conda package, and embed LatNetBuilder inside')
def configure(ctx):
ctx.options.nested = True
ctx.recurse('latticetester')
if ctx.options.fftw:
deps.add_deps_path(ctx, 'FFTW', ctx.options.fftw)
if ctx.options.boost:
deps.add_deps_path(ctx, 'boost', ctx.options.boost)
ctx_check = deps.shared_or_static(ctx, ctx.check)
# realtime (required for Boost chrono on Linux)
# ctx.check(features='cxx cxxprogram',
# lib='rt',
# uselib_store='RT',
# mandatory=False)
# Boost Program Options
ctx_check(features='cxx cxxprogram',
header_name='boost/program_options.hpp')
ctx_check(features='cxx cxxprogram',
lib='boost_program_options',
uselib_store='PROGRAM_OPTIONS')
ctx_check(features='cxx cxxprogram',
lib='boost_system',
uselib_store='SYSTEM')
ctx_check(features='cxx cxxprogram',
lib='boost_filesystem',
uselib_store='FILESYSTEM')
#ctx_check(features='cxx cxxprogram',
# header_name='boost/filesystem.hpp',
# lib=['boost_system', 'boost_filesystem'])
# Boost Chrono
# ctx_check(features='cxx cxxprogram',
# header_name='boost/chrono/chrono_io.hpp',
# lib=['boost_chrono', 'boost_system'],
# shlib=ctx.env.LIB_RT,
# uselib_store='CHRONO',
# mandatory=False)
# FFTW
ctx_check(features='cxx cxxprogram', header_name='fftw3.h')
ctx_check(features='cxx cxxprogram', lib='fftw3', uselib_store='FFTW')
# NTL
# ctx_check(features='cxx cxxprogram',
# header_name='NTL/vector.h',
# lib=['ntl', 'gmp'],
# shlib=ctx.env.LIB_NTL,
# uselib_store='NTL',
# mandatory=True)
# 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/')
if ctx.options.build_light_conda or ctx.options.build_conda:
if not ctx.find_program('conda', var='CONDA', mandatory=False):
ctx.fatal('Conda is required for building conda package.\n' +
'Get it from https://www.anaconda.com/download/')
ctx.env.BUILD_CONDA = True
if ctx.options.build_conda:
ctx.env.EMBED_LATNET_CONDA = True
else:
ctx.env.EMBED_LATNET_CONDA = False
# examples
if ctx.options.build_examples:
ctx.env.BUILD_EXAMPLES = True
# version
ctx.version_file('latnetbuilder')
version_tag = ctx.set_version('latnetbuilder')
ctx.define('LATNETBUILDER_VERSION', version_tag)
ctx.msg("Setting LatNet Builder version", version_tag)
# 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):
ctx.recurse('latticetester')
verfile = ctx.path.find_node('latnetbuilder-version.txt')
if verfile:
verfile.delete()
from waflib import Scripting
Scripting.distclean(ctx)
def build(ctx):
if ctx.variant:
print("Building variant `%s'" % (ctx.variant,))
ctx.options.nested = True
ctx.recurse('latticetester')
ctx.recurse('src')
ctx.recurse('progs')
ctx.recurse('data')
if ctx.env.BUILD_DOCS:
ctx.recurse('doc')
if ctx.env.BUILD_EXAMPLES:
ctx.recurse('examples')
# jupyter notebook
ctx.install_files("${PREFIX}/share/latnetbuilder", ["python-wrapper/notebooks/Interface.ipynb"])
# Docker file for no GUI
ctx.install_files("${PREFIX}/share/latnetbuilder", ["DockerfileLight"])
if ctx.env.BUILD_CONDA: # must be done at the end to copy installed files to conda package
ctx.recurse('python-wrapper')
# build variants
from waflib.Build import BuildContext
class debug(BuildContext):
cmd = 'debug'
variant = 'debug'