This repository has been archived by the owner on Dec 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwscript
202 lines (162 loc) · 6.64 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
# -*- mode: python -*-
# @begin:license
#
# Copyright (c) 2015-2019, Benjamin Niemann <pink@odahoda.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# @end:license
import distutils.version
import contextlib
import glob
import os
import os.path
import sys
from waflib.Configure import conf
from waflib.Build import BuildContext
if sys.version_info < (3, 5):
sys.stderr.write("At least python V3.5 required.\n")
sys.exit(1)
if 'VIRTUAL_ENV' not in os.environ or 'LD_LIBRARY_PATH' not in os.environ:
venv_marker = '.venv'
if os.path.isfile(venv_marker):
venv_path = open(venv_marker, 'r').readline().strip()
py_path = os.path.join(venv_path, 'bin', 'python')
if os.path.isfile(py_path):
env = dict(os.environ)
env['VIRTUAL_ENV'] = venv_path
env['LD_LIBRARY_PATH'] = os.path.join(venv_path, 'lib')
env['PATH'] = os.pathsep.join(
[os.path.join(venv_path, 'bin')] + os.environ.get('PATH', '').split(os.pathsep))
argv = [py_path] + sys.argv
os.execve(argv[0], argv, env)
# Properly format command lines when using -v
os.environ['WAF_CMD_FORMAT'] = 'string'
top = '.'
out = 'build'
Version = distutils.version.LooseVersion
def options(ctx):
ctx.load('build_utils.waf.virtenv', tooldir='.')
ctx.load('build_utils.waf.test', tooldir='.')
ctx.load('compiler_cxx')
ctx.load('compiler_c')
@conf
def pkg_config(ctx, store, package, minver):
ctx.check_cfg(
package=package,
args=['%s >= %s' % (package, minver), '--cflags', '--libs'],
uselib_store=store,
pkg_config_path=os.path.join(
ctx.env.VIRTUAL_ENV, 'lib', 'pkgconfig'))
@conf
@contextlib.contextmanager
def group(ctx, grp):
old_grp = ctx.current_group
ctx.set_group(grp)
try:
yield
finally:
ctx.set_group(old_grp)
@conf
def in_group(ctx, grp):
return ctx.get_group_name(ctx.current_group) == grp
def configure(ctx):
# This one must come first, because it sets up the virtual environment where everything else
# below should search for dependencies.
ctx.load('build_utils.waf.virtenv', tooldir='.')
os_dist = ctx.env.OS_DIST
os_release = Version(ctx.env.OS_RELEASE)
ctx.load('compiler_cxx')
ctx.load('compiler_c')
ctx.load('python')
ctx.load('build_utils.waf.install', tooldir='.')
ctx.load('build_utils.waf.test', tooldir='.')
ctx.load('build_utils.waf.local_rpath', tooldir='.')
ctx.load('build_utils.waf.proto', tooldir='.')
ctx.load('build_utils.waf.cpp', tooldir='.')
ctx.load('build_utils.waf.python', tooldir='.')
ctx.load('build_utils.waf.cython', tooldir='.')
ctx.load('build_utils.waf.model', tooldir='.')
ctx.load('build_utils.waf.static', tooldir='.')
ctx.load('build_utils.waf.csound', tooldir='.')
ctx.load('build_utils.waf.sf2', tooldir='.')
ctx.load('build_utils.waf.plugins', tooldir='.')
ctx.load('build_utils.waf.svg', tooldir='.')
ctx.load('build_utils.waf.faust', tooldir='.')
ctx.load('build_utils.waf.ffmpeg', tooldir='.')
ctx.check_python_version(minver=(3, 5))
ctx.check_python_headers(features=['pyext'])
ctx.pkg_config('GTK2', 'gtk+-2.0', '2.24')
ctx.pkg_config('PROTOBUF', 'protobuf', '3.7')
ctx.pkg_config('UNWIND', 'libunwind-generic', '1.1')
ctx.pkg_config('SRATOM', 'sratom-0', '0.4')
ctx.pkg_config('LILV', 'lilv-0', '0.22')
ctx.pkg_config('SUIL', 'suil-0', '0.10.0')
ctx.pkg_config('SNDFILE', 'sndfile', '1.0')
ctx.pkg_config('FLUIDSYNTH', 'fluidsynth', '1.1.6')
ctx.pkg_config('AVUTIL', 'libavutil', '54')
ctx.pkg_config('SWRESAMPLE', 'libswresample', '1.2')
ctx.pkg_config('PORTAUDIO', 'portaudio-2.0', '19')
if os_dist == 'ubuntu' and os_release < Version('18.04'):
# libgoogle-perftools-dev in xenial does not contain libprofiler.pc
ctx.check(header_name='gperftools/profiler.h', features='cxx cxxprogram')
ctx.check(lib='profiler', features='cxx cxxprogram')
else:
ctx.pkg_config('PROFILER', 'libprofiler', '2.4')
ctx.env.LIB_CSOUND = ['csound64']
ctx.env.CFLAGS_CSOUND = ['-DHAVE_PTHREAD_SPIN_LOCK']
ctx.env.CXXFLAGS_CSOUND = ['-DHAVE_PTHREAD_SPIN_LOCK']
ctx.env.append_value('CXXFLAGS', ['-g', '-O2', '-std=c++11', '-w'])
ctx.env.append_value('CFLAGS', ['-g', '-O2'])
ctx.env.append_value('LIBPATH', [os.path.join(ctx.env.VIRTUAL_ENV, 'lib')])
ctx.env.append_value('LIB', ['pthread'])
ctx.env.append_value('INCLUDES', [ctx.srcnode.abspath(), ctx.bldnode.abspath(), os.path.join(ctx.env.VIRTUAL_ENV, 'include')])
ctx.env.DATADIR = os.path.join(ctx.env.PREFIX, 'share', 'noisicaa')
ctx.env.LIBDIR = os.path.join(ctx.env.PREFIX, 'lib', 'noisicaa')
ctx.write_config_header('config.h')
def build(ctx):
ctx.init_test()
ctx.GRP_BUILD_TOOLS = 'build:tools'
ctx.GRP_BUILD_MAIN = 'build:main'
ctx.GRP_BUILD_TESTS = 'build:tests'
ctx.GRP_RUN_TESTS = 'run:tests'
ctx.add_group(ctx.GRP_BUILD_TOOLS)
ctx.add_group(ctx.GRP_BUILD_MAIN)
ctx.add_group(ctx.GRP_BUILD_TESTS)
ctx.add_group(ctx.GRP_RUN_TESTS)
ctx.set_group(ctx.GRP_BUILD_MAIN)
with ctx.group(ctx.GRP_BUILD_TOOLS):
ctx.recurse('build_utils')
ctx.recurse('noisicaa')
ctx.recurse('misc')
ctx.recurse('data')
if ctx.env.ENABLE_TEST:
with ctx.group(ctx.GRP_BUILD_TESTS):
ctx.recurse('noisidev')
ctx.recurse('testdata')
for lib in ['libprotobuf', 'libcsound64', 'liblilv-0', 'libsuil-0']:
for path in glob.glob(os.path.join(ctx.env.VIRTUAL_ENV, 'lib', lib + '.so*')):
if os.path.islink(path):
ctx.symlink_as(
os.path.join(ctx.env.LIBDIR, os.path.basename(path)),
os.path.basename(os.path.realpath(path)))
else:
ctx.install_files(
ctx.env.LIBDIR,
ctx.root.make_node(path))
ctx.install_post_func()
class TestContext(BuildContext):
"""run unittests"""
cmd = 'test'