-
Notifications
You must be signed in to change notification settings - Fork 6
/
meson.build
420 lines (352 loc) · 10.3 KB
/
meson.build
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
project('tokonoma', ['cpp', 'c'],
license: 'BSD',
version: '0.1.0',
meson_version: '>=0.51',
default_options: [
'cpp_std=c++17',
'c_std=c11',
'warning_level=3',
'werror=false'])
# options
profiling = get_option('profiling')
with_playground = get_option('playground')
if profiling
add_global_arguments('-pg', language: 'cpp')
endif
# dummy/playground projects use this dependency.
# quick way to disable building them at all
if with_playground
dep_playground = []
else
dep_playground = disabler()
endif
cc = meson.get_compiler('cpp')
android = (cc.get_define('__ANDROID__') != '')
exetarget = 'executable'
if android
aapiv = cc.get_define('__ANDROID_API__')
# Make sure that we dispatch vulkan dynamically, that is needed
# on android. I guess libvulkan are just stubs for everything
# but instance creation proc address loading
add_global_arguments('-DVKPP_DYNAMIC_DISPATCH', language: ['cpp', 'c'])
# See https://github.com/android/ndk/issues/289
add_global_link_arguments([
'-lgcc',
'-Wl,--exclude-libs,libgcc_real.a',
'-Wl,--exclude-libs,libunwind.a',
], language: ['cpp', 'c'])
# there are no native executables for apk's on android
# shared_module instead of shared_library so that they export 'main'
# which is needed by ny
exetarget = 'shared_module'
endif
# warnings
warnings = [
'-Wpedantic',
'-Wduplicated-cond',
'-Wrestrict',
'-Wnull-dereference',
'-Wundef',
'-Wlogical-op',
# for clang
'-Wno-missing-braces',
# woraround for asio
'-Wno-undef'
]
# default arrguments
# warnings and stuff
add_project_arguments(
cc.get_supported_arguments(warnings),
language: 'cpp')
# mainly needed for shaders and assets and stuff
source_root = '/'.join(meson.source_root().split('\\'))
add_project_arguments(
'-DTKN_BASE_DIR="@0@"'.format(source_root),
language: 'cpp')
# project-specific stuff
defs = [
'-DDLG_BASE_PATH="' + source_root + '/"',
# '-DNYTL_BYTES_ASSERT(x)=dlg_assert(x)',
]
add_project_arguments(defs, language: 'cpp')
add_project_arguments('-DASIO_STANDALONE', language: 'cpp')
# required dependencies
# TODO: remove ugly MASTER hacks that prevent installed version to be found
# should probably just use 'subproject' instead in those cases
dep_vpp = dependency('vpp', fallback: ['vpp', 'vpp_dep'])
dep_nytl = dependency('nytl MASTER', fallback: ['nytl', 'nytl_dep'])
dep_dlg = dependency('dlg MASTER', fallback: ['dlg', 'dlg_dep'])
dep_rvg = dependency('rvg', fallback: ['rvg', 'rvg_dep'])
dep_vui = dependency('vui', fallback: ['vui', 'vui_dep'])
dep_vulkan = dependency('vulkan')
dep_png = dependency('libpng', fallback: ['png', 'png_dep'])
dep_swa = dependency('swa', fallback: ['swa', 'swa_dep'])
dep_glslang = dependency('glslang', fallback: ['glslang', 'glslang_dep'])
# wayland protocols
dep_wl_client = dependency('wayland-client', required: false)
dep_wl_protos = dependency('wayland-protocols',
version: '>=1.17',
required: false)
wl_protocol_dir = dep_wl_protos.get_variable(pkgconfig: 'pkgdatadir')
dep_wl_scanner = dependency('wayland-scanner', required: false, native: true)
if dep_wl_scanner.found()
wl_scanner = find_program(
dep_wl_scanner.get_variable(pkgconfig: 'wayland_scanner'),
requireds: false,
native: true)
else
wl_scanner = find_program('wayland-scanner', native: true, required: false)
endif
# Needed for fuen/vil
dep_dl = cc.find_library('dl', required: false)
# turbojpeg is optional, there exists no meson wrap for it.
# if we can't find it, we just fall back to the stbi loader, i.e. make
# tkn::JpegLoader a dummy that never works.
# fall back to default libjpeg, add (non-turbo) libjpeg loader?
dep_turbojpeg = dependency('libturbojpeg',
required: false,
fallback: ['turbojpeg', 'jpeg_dep'])
# box2D is not required, we simply don't build 2D physics stuff if not found
# We don't pass 'Box2D' as name to dependency because we don't to use
# the system-installed version. We use features that were added since
# the last release (which was 2014 as of now)
dep_b2d = dependency('b2d',
fallback: ['b2d', 'b2d_dep'],
disabler: true,
required: get_option('b2d'))
with_b2d = dep_b2d.found()
# bullet for 3D physics
# optional as well, the wrap i wrote ships pre-built binaries (since
# writing meson.build files for it would be quite some work i guess)
# but not for every platform.
dep_bullet = dependency('bullet',
fallback: ['bullet', 'bullet_dep'],
disabler: true,
required: get_option('bullet'))
with_bullet = dep_bullet.found()
# cubeb for audio
# when not available (e.g. not possible to build), the audio
# projects simply won't be built
dep_cubeb = dependency('cubeb',
fallback: ['cubeb', 'cubeb_dep'],
disabler: true,
required: get_option('audio'))
with_audio = dep_cubeb.found()
# steamaudio, optional, for 3D audio processing
# the library isn't free/libre or open source!
# But has a fairly permissive license.
dep_steamaudio = disabler()
if with_audio
dep_steamaudio = dependency('steamaudio',
fallback: ['steamaudio', 'steamaudio_dep'],
disabler: true,
required: get_option('steamaudio'))
endif
with_audio3D = dep_steamaudio.found()
# pulseaudio, optional, for linux audio recording/interaction
dep_pulse_simple = dependency('libpulse-simple',
required: false,
disabler: true)
dep_pulse_simple_optional = []
if dep_pulse_simple.found()
dep_pulse_simple_optional = [dep_pulse_simple]
endif
cd = configuration_data()
cd.set('TKN_LINUX', build_machine.system() == 'linux')
cd.set('TKN_WITH_AUDIO', with_audio)
cd.set('TKN_WITH_AUDIO3D', with_audio3D)
cd.set('TKN_WITH_BULLET', with_bullet)
cd.set('TKN_WITH_B2D', with_b2d)
cd.set('TKN_WITH_PULSE_SIMPLE', dep_pulse_simple.found())
cd.set('TKN_WITH_WL_PROTOS', dep_wl_protos.found() and wl_scanner.found())
subdir('include/tkn')
external_inc = include_directories('external/include')
subdir('src/shaders')
subdir('src/tkn')
subdir('docs/tests')
# projects
subdir('src/smooth_shadow')
subdir('src/pursuers')
subdir('src/fluids')
subdir('src/mists')
subdir('src/sss')
subdir('src/iro')
subdir('src/br')
subdir('src/dm')
subdir('src/lpgi')
subdir('src/taa')
subdir('src/deferred')
subdir('src/cloth')
# playground/dummy projects
if with_playground
subdir('src/playground')
endif
# erase shader dependencies only needed on android
if not android
atmosphere_shaders = [atmosphere_shaders[0]]
tess_shaders = []
subd_shaders = []
endif
# inline (for small projects)
executable('pendulum',
'src/pendulum/main.cpp',
dependencies: tkn_dep)
executable('dpend',
'src/dpend/main.cpp',
dependencies: tkn_dep)
executable('soundfont',
'src/soundfont/main.cpp',
dependencies: [tkn_dep, tkn_audio_dep])
executable('dummy',
'src/dummy/main.cpp',
dependencies: tkn_dep)
executable('guitest',
'src/guitest/main.cpp',
dependencies: [tkn_dep, dep_playground])
executable('rvgscene', [
'src/guitest/rvgscene.cpp',
'src/guitest/scene.cpp',
'src/guitest/buffer.cpp',
'src/guitest/context.cpp',
'src/guitest/paint.cpp',
'src/guitest/draw.cpp',
'src/guitest/polygon.cpp',
'src/guitest/update.cpp',
'src/guitest/font.cpp',
guitest_shaders,
], dependencies: [tkn_dep, dep_playground])
particles = build_target('particles', [
'src/particles/main.cpp',
particles_shaders,
], dependencies: [
tkn_dep,
tkn_audio_dep_optional,
dep_pulse_simple_optional
], target_type: exetarget)
p3 = build_target('p3', [
'src/p3/main.cpp'
], dependencies: [
tkn_dep,
], target_type: exetarget)
executable('automaton', [
'src/automaton/main.cpp',
'src/automaton/automaton.cpp',
automaton_shaders,
], dependencies: tkn_dep)
executable('normals', [
'src/normals/main.cpp',
normals_shaders,
], dependencies: tkn_dep)
executable('sviewer', [
'src/sviewer/main.cpp',
], dependencies: tkn_dep)
executable('visualizer', [
'src/visualizer/main.cpp',
], dependencies: [tkn_dep, tkn_audio_dep])
executable('ps', [
'src/ps/main.cpp',
ps_shaders,
], dependencies: tkn_dep)
executable('sen', [
'src/sen/main.cpp',
sen_shaders,
], dependencies: tkn_dep)
executable('gen', [
'src/gen/main.cpp',
tkn_shaders,
], dependencies: tkn_dep)
executable('gen_ltc', [
'src/gen/fitLTC/fit.cpp',
tkn_shaders,
], dependencies: tkn_dep,
cpp_args: ['-O3', '-march=native'])
executable('iv',
'src/iv/main.cpp',
dependencies: tkn_dep)
executable('shv', [
'src/shv/main.cpp',
shv_shaders,
], dependencies: tkn_dep)
volume = build_target('volume', [
'src/volume/main.cpp',
volume_shaders,
], dependencies: tkn_dep,
target_type: exetarget)
bezier = build_target('bezier', [
'src/bezier/main.cpp',
bezier_shaders,
], dependencies: tkn_dep,
target_type: exetarget)
executable('tta',
'src/playground/tta.cpp',
dependencies: tkn_dep)
atmosphere = build_target('atmosphere', [
'src/atmosphere/main.cpp',
atmosphere_shaders,
], dependencies: tkn_dep,
target_type: exetarget)
fem = build_target('fem', [
'src/fem/main.cpp',
fem_shaders,
], dependencies: tkn_dep,
target_type: exetarget)
hair = build_target('hair', [
'src/hair/main.cpp',
], dependencies: tkn_dep,
target_type: exetarget)
repro = build_target('repro', [
'src/repro/main.cpp',
repro_shaders,
], dependencies: tkn_dep,
target_type: exetarget)
rays = build_target('rays', [
'src/rays/main.cpp',
], dependencies: tkn_dep,
target_type: exetarget)
tess = build_target('tess', [
'src/tess/main.cpp',
tess_shaders,
], dependencies: [tkn_dep, dep_playground],
target_type: exetarget)
subd = build_target('subd', [
'src/subd/main.cpp',
subd_shaders,
], dependencies: [tkn_dep],
target_type: exetarget)
scatter = build_target('scatter', [
'src/scatter/main.cpp',
scatter_shaders,
], dependencies: [tkn_dep],
target_type: exetarget)
clouds = build_target('clouds', [
'src/clouds/main.cpp',
], dependencies: [tkn_dep],
target_type: exetarget)
sky = build_target('sky', [
'src/sky/main.cpp',
], dependencies: [tkn_dep],
target_type: exetarget)
oscil = build_target('oscil', [
'src/oscil/main.cpp',
oscil_shaders,
], dependencies: [tkn_dep, tkn_audio_dep, dep_pulse_simple_optional],
target_type: exetarget)
planet = build_target('planet', [
'src/planet/main.cpp',
planet_shaders,
], dependencies: [tkn_dep],
target_type: exetarget)
# TODO: no longer needed
planet_gen = build_target('planet_gen', [
'src/planet/gen.cpp',
planet_shaders,
], dependencies: [tkn_dep],
target_type: exetarget)
terrain = build_target('terrain', [
'src/terrain/main.cpp',
'src/terrain/atmosphere.cpp',
], dependencies: [tkn_dep],
target_type: exetarget)
if android
subdir('apk')
endif