-
Notifications
You must be signed in to change notification settings - Fork 225
/
meson.build
229 lines (214 loc) · 6.89 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
project('vkquake', 'c', default_options : ['c_std=gnu11', 'buildtype=release'])
shaders = [
'Shaders/alias.frag',
'Shaders/alias.vert',
'Shaders/alias_alphatest.frag',
'Shaders/md5.vert',
'Shaders/basic.frag',
'Shaders/basic.vert',
'Shaders/basic_alphatest.frag',
'Shaders/basic_notex.frag',
'Shaders/cs_tex_warp.comp',
'Shaders/indirect.comp',
'Shaders/indirect_clear.comp',
'Shaders/postprocess.frag',
'Shaders/postprocess.vert',
'Shaders/screen_effects_10bit.comp',
'Shaders/screen_effects_10bit_scale.comp',
'Shaders/screen_effects_10bit_scale_sops.comp',
'Shaders/screen_effects_8bit.comp',
'Shaders/screen_effects_8bit_scale.comp',
'Shaders/screen_effects_8bit_scale_sops.comp',
'Shaders/showtris.frag',
'Shaders/showtris.vert',
'Shaders/sky_box.frag',
'Shaders/sky_cube.frag',
'Shaders/sky_cube.vert',
'Shaders/sky_layer.frag',
'Shaders/sky_layer.vert',
'Shaders/update_lightmap.comp',
'Shaders/update_lightmap_rt.comp',
'Shaders/world.frag',
'Shaders/world.vert',
'Shaders/ray_debug.comp',
]
glslang = find_program('glslangValidator')
spirv_opt = find_program('spirv-opt')
spirv_remap = find_program('spirv-remap')
bintoc = executable('bintoc', ['Shaders/bintoc.c'], native: true)
if (build_machine.system() == 'darwin') or get_option('buildtype').startswith('debug')
spirv_opt_command = [] # MoltenVK spirv-cross has a bug that breaks optimized shaders
else
spirv_opt_command = [spirv_opt, '-Os', '@[email protected]', '-o', '@[email protected]', '&&']
endif
spirv_remap_command = get_option('buildtype').startswith('debug') ? [] : [spirv_remap, '-s', '-o', '.', '-i', '@[email protected]', '&&']
bintoc_command = [bintoc, '@[email protected]', '@PLAINNAME@_spv', '@OUTPUT@']
shaders_c = []
foreach shader : shaders
target_env = shader.contains('sops') ? ['--target-env', 'vulkan1.1'] : []
debug_flag = get_option('buildtype').startswith('debug') ? ['-g'] : []
glslang_command = [glslang, '-V'] + debug_flag + target_env + ['-o', '@[email protected]', '@INPUT@', '--depfile', '@[email protected]', '&&']
shaders_c += custom_target(shader.underscorify(),
input: shader,
output: '@[email protected]',
depfile: '@[email protected]',
command: glslang_command
+ spirv_opt_command
+ spirv_remap_command
+ bintoc_command)
endforeach
srcs = [
'Quake/bgmusic.c',
'Quake/cd_null.c',
'Quake/cfgfile.c',
'Quake/chase.c',
'Quake/cl_demo.c',
'Quake/cl_input.c',
'Quake/cl_main.c',
'Quake/cl_parse.c',
'Quake/cl_tent.c',
'Quake/cmd.c',
'Quake/common.c',
'Quake/console.c',
'Quake/crc.c',
'Quake/cvar.c',
'Quake/gl_draw.c',
'Quake/gl_fog.c',
'Quake/gl_heap.c',
'Quake/gl_mesh.c',
'Quake/gl_model.c',
'Quake/gl_refrag.c',
'Quake/gl_rlight.c',
'Quake/gl_rmain.c',
'Quake/gl_rmisc.c',
'Quake/gl_screen.c',
'Quake/gl_sky.c',
'Quake/gl_texmgr.c',
'Quake/gl_vidsdl.c',
'Quake/gl_warp.c',
'Quake/host.c',
'Quake/host_cmd.c',
'Quake/image.c',
'Quake/in_sdl.c',
'Quake/keys.c',
'Quake/main_sdl.c',
'Quake/mathlib.c',
'Quake/mdfour.c',
'Quake/mem.c',
'Quake/menu.c',
'Quake/miniz.c',
'Quake/net_bsd.c',
'Quake/net_dgrm.c',
'Quake/net_loop.c',
'Quake/net_main.c',
'Quake/net_udp.c',
'Quake/palette.c',
'Quake/pl_linux.c',
'Quake/pr_cmds.c',
'Quake/pr_edict.c',
'Quake/pr_exec.c',
'Quake/pr_ext.c',
'Quake/r_alias.c',
'Quake/r_brush.c',
'Quake/r_part.c',
'Quake/r_part_fte.c',
'Quake/r_sprite.c',
'Quake/r_world.c',
'Quake/sbar.c',
'Quake/snd_codec.c',
'Quake/snd_dma.c',
'Quake/snd_mem.c',
'Quake/snd_mix.c',
'Quake/snd_sdl.c',
'Quake/snd_umx.c',
'Quake/snd_wave.c',
'Quake/strlcat.c',
'Quake/strlcpy.c',
'Quake/sv_main.c',
'Quake/sv_move.c',
'Quake/sv_phys.c',
'Quake/sv_user.c',
'Quake/sys_sdl.c',
'Quake/sys_sdl_unix.c',
'Quake/tasks.c',
'Quake/view.c',
'Quake/wad.c',
'Quake/world.c',
'Quake/hash_map.c',
'Quake/embedded_pak.c',
]
cflags = ['-Wall', '-Wno-trigraphs', '-Werror', '-std=gnu11']
cc = meson.get_compiler('c')
deps = [
cc.find_library('m', required : false),
cc.find_library('dl', required : false),
dependency('threads'),
dependency('sdl2'),
]
if build_machine.system() == 'darwin'
molten_dirs = []
if import('fs').exists('/opt/homebrew/lib/libMoltenVK.dylib')
molten_dirs += '/opt/homebrew/lib'
endif
deps += cc.find_library('MoltenVK', required : true, dirs : molten_dirs)
else
deps += dependency('vulkan')
endif
if get_option('use_codec_wave').enabled()
cflags += '-DUSE_CODEC_WAVE'
endif
if get_option('mp3_lib') == 'mad'
mp3_dep = dependency('mad', required : get_option('use_codec_mp3'))
if mp3_dep.found()
srcs += [ 'Quake/snd_mp3.c', 'Quake/snd_mp3tag.c' ]
deps += mp3_dep
cflags += '-DUSE_CODEC_MP3'
endif
else
mp3_dep = dependency('libmpg123', required : get_option('use_codec_mp3'))
if mp3_dep.found()
srcs += [ 'Quake/snd_mpg123.c', 'Quake/snd_mp3tag.c' ]
deps += mp3_dep
cflags += '-DUSE_CODEC_MP3'
endif
endif
flac_dep = dependency('flac', required : get_option('use_codec_flac'))
if flac_dep.found()
srcs += 'Quake/snd_flac.c'
deps += flac_dep
cflags += '-DUSE_CODEC_FLAC'
endif
ogg_dep = dependency('ogg', required : get_option('use_codec_vorbis'))
if get_option('vorbis_lib') == 'vorbis'
vorbisfile_dep = dependency('vorbisfile', required : get_option('use_codec_vorbis'))
vorbis_dep = dependency('vorbis', required : get_option('use_codec_vorbis'))
if ogg_dep.found() and vorbisfile_dep.found() and vorbis_dep.found()
srcs += 'Quake/snd_vorbis.c'
deps += [ ogg_dep, vorbisfile_dep, vorbis_dep ]
cflags += '-DUSE_CODEC_VORBIS'
endif
else
vorbis_dep = dependency('vorbisidec', required : get_option('use_codec_vorbis'))
if ogg_dep.found() and vorbis_dep.found()
srcs += 'Quake/snd_vorbis.c'
deps += [ ogg_dep, vorbis_dep ]
cflags += [ '-DUSE_CODEC_VORBIS', '-DVORBIS_USE_TREMOR' ]
endif
endif
opus_dep = dependency('opus', required : get_option('use_codec_opus'))
opusfile_dep = dependency('opusfile', required : get_option('use_codec_opus'))
if opus_dep.found() and opusfile_dep.found()
srcs += 'Quake/snd_opus.c'
deps += [ opus_dep, opusfile_dep ]
cflags += '-DUSE_CODEC_OPUS'
endif
if get_option('buildtype').startswith('debug')
cflags += '-D_DEBUG'
endif
if get_option('do_userdirs').enabled()
cflags += '-DDO_USERDIRS=1'
endif
incdirs = [
'Quake/mimalloc',
]
executable('vkquake', [srcs, shaders_c], dependencies : deps, include_directories : incdirs, c_args : cflags, c_pch: ['Quake/quakedef.h', 'Quake/quakedef.c'])