Repository navigation
Expand file tree
/
Copy pathmeson.build
More file actions
307 lines (258 loc) · 10.3 KB
/
Copy pathmeson.build
File metadata and controls
307 lines (258 loc) · 10.3 KB
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
project(
'wayfire',
'c',
'cpp',
version: '0.12.0',
license: 'MIT',
meson_version: '>=0.64.0',
default_options: [
'cpp_std=c++17',
'c_std=c11',
'warning_level=2',
'werror=false',
],
)
cpp = meson.get_compiler('cpp')
version = '"@0@"'.format(meson.project_version())
add_project_arguments('-DWAYFIRE_VERSION=@0@'.format(version), language: 'cpp')
if get_option('custom_pch') and cpp.get_id() == 'clang'
# For clang, we need to ensure that we don't add timestamp to PCH.
# Otherwise, that breaks ccache (see https://ccache.dev/manual/latest.html#_precompiled_headers)
add_project_arguments(['-Xclang', '-fno-pch-timestamp'], language: 'cpp')
endif
wayfire_api_inc = include_directories('src/api')
wayland_server = dependency('wayland-server')
wayland_client = dependency('wayland-client')
wayland_cursor = dependency('wayland-cursor')
wayland_protos = dependency('wayland-protocols', version: '>=1.37')
cairo = dependency('cairo')
pango = dependency('pango')
pangocairo = dependency('pangocairo')
drm = dependency('libdrm')
egl = dependency('egl')
glesv2 = dependency('glesv2')
vulkan = dependency('vulkan', required: get_option('vulkan_effects'))
glm = dependency('glm', required: false)
libinput = dependency('libinput', version: '>=1.7.0')
pixman = dependency('pixman-1')
xkbcommon = dependency('xkbcommon')
libdl = cpp.find_library('dl')
udev = dependency('libudev')
json = subproject('wf-json', default_options: ['install_header=true']).get_variable('wfjson')
wlroots_base_version = '0.20'
if get_option('vulkan_effects')
wlroots_dep_name = 'wlroots-vkfx-' + wlroots_base_version
wlroots_subproject_name = 'wlroots-vkfx'
else
wlroots_dep_name = 'wlroots-' + wlroots_base_version
wlroots_subproject_name = 'wlroots'
endif
wlroots_min_version = '>=' + wlroots_base_version + '.0'
wlroots_max_version = '<=' + wlroots_base_version + '.99'
# We're not to use system wlroots: So we'll use the subproject
if get_option('use_system_wlroots').disabled()
use_system_wlroots = false
wlroots = subproject(wlroots_subproject_name, default_options : ['examples=false']).get_variable('wlroots')
elif get_option('use_system_wlroots').enabled()
use_system_wlroots = true
wlroots = dependency(wlroots_dep_name, version: [wlroots_min_version, wlroots_max_version], required: true)
elif get_option('use_system_wlroots').auto()
wlroots = dependency(wlroots_dep_name, version: [wlroots_min_version, wlroots_max_version], required: false)
use_system_wlroots = true
if not wlroots.found()
use_system_wlroots = false
wlroots = subproject(wlroots_subproject_name, default_options : ['examples=false']).get_variable('wlroots')
endif
endif
wlroots_features = {
'xwayland': false,
'drm_backend': false,
'gles2_renderer': false,
'vulkan_renderer': false,
'libinput_backend': false,
'session': false,
'x11_backend': false,
}
foreach name, _ : wlroots_features
var_name = 'have_' + name.underscorify()
wlroots_features += { name: wlroots.get_variable(pkgconfig: var_name, internal: var_name) == 'true' }
endforeach
required_wlroots_features= [
'drm_backend',
'session',
'libinput_backend',
]
missing_wlroots_features = []
# Required features based on currently exposed public api
foreach required_feature : required_wlroots_features
if not wlroots_features[required_feature]
missing_wlroots_features += required_feature
endif
endforeach
if missing_wlroots_features.length() > 0
error('wlroots is missing the following required features: @0@'.format(' '.join(missing_wlroots_features)))
endif
wfconfig_version = ['>=0.12.0', '<0.13.0']
# We're not to use system wlroots: So we'll use the subproject
if get_option('use_system_wfconfig').disabled()
use_system_wfconfig = false
wfconfig = subproject('wf-config').get_variable('wfconfig')
elif get_option('use_system_wfconfig').enabled()
use_system_wfconfig = true
wfconfig = dependency('wf-config', version: wfconfig_version, required: true)
elif get_option('use_system_wfconfig').auto()
wfconfig = dependency('wf-config', version: wfconfig_version, required: false)
use_system_wfconfig = true
if not wfconfig.found()
use_system_wfconfig = false
wfconfig = subproject('wf-config').get_variable('wfconfig')
endif
endif
if not glm.found() and not cpp.check_header('glm/glm.hpp')
error('GLM not found, and directly using the header \'glm/glm.hpp\' is not possible.')
endif
backtrace = cpp.find_library('execinfo', required: false)
wfutils = subproject('wf-utils').get_variable('wfutils')
wftouch = subproject('wf-touch').get_variable('wftouch')
needs_libinotify = ['freebsd', 'dragonfly'].contains(host_machine.system())
libinotify = dependency('libinotify', required: needs_libinotify)
jpeg = dependency('libjpeg', required: false)
png = dependency('libpng', required: false)
# backtrace() is in a separate library on FreeBSD and Linux with musl
backtrace = cpp.find_library('execinfo', required: false)
conf_data = configuration_data()
conf_data.set('INSTALL_PREFIX', get_option('prefix'))
conf_data.set('WAYFIRE_VERSION', meson.project_version())
fs = import('fs')
wayfire_api_abi_version = ''
foreach line : fs.read('src/api/wayfire/plugin.hpp').split('\n')
fields = line.split()
if fields.length() >= 3 and fields[0] == '#define' and fields[1] == 'WAYFIRE_API_ABI_VERSION_MACRO'
wayfire_api_abi_version = fields[2].replace('\'', '')
endif
endforeach
if wayfire_api_abi_version == ''
error('Could not read WAYFIRE_API_ABI_VERSION_MACRO from plugin.hpp')
endif
conf_data.set('WAYFIRE_API_ABI_VERSION', wayfire_api_abi_version)
conf_data.set('PLUGIN_PATH', join_paths(get_option('prefix'), get_option('libdir'), 'wayfire'))
metadata_dir_suffix = 'share/wayfire/metadata'
conf_data.set('PLUGIN_XML_DIR', join_paths(get_option('prefix'), metadata_dir_suffix))
sysconfdir = join_paths(get_option('prefix'), get_option('sysconfdir'))
conf_data.set('SYSCONFDIR', sysconfdir)
pkgdatadir = join_paths(get_option('prefix'), 'share', 'wayfire', 'protocols')
conf_data.set('REL_LIBDIR', get_option('libdir'))
if get_option('default_config_backend') == 'default'
conf_data.set('DEFAULT_CONFIG_BACKEND', join_paths(conf_data.get('PLUGIN_PATH'), 'libdefault-config-backend.so'))
else
conf_data.set('DEFAULT_CONFIG_BACKEND', get_option('default_config_backend'))
endif
# needed to dlopen() plugins
# -E is for RTTI/dynamic_cast across plugins
add_project_link_arguments(['-rdynamic', '-Wl,-E'], language: 'cpp')
project_args = ['-DWLR_USE_UNSTABLE']
# Needed for dlclose to actually free plugin memory on gcc+glibc
if cpp.has_argument('-fno-gnu-unique')
project_args += '-fno-gnu-unique'
endif
add_project_arguments(project_args, language: ['cpp', 'c'])
# Compile new libinput features only if they are supported with the libinput installed version
if cpp.has_function('libinput_device_config_3fg_drag_set_enabled', dependencies: libinput)
add_project_arguments('-DHAVE_LIBINPUT_3FG_DRAG=1', language : ['cpp', 'c'])
endif
# Needed on some older compilers
if cpp.has_link_argument('-lc++fs')
add_project_link_arguments(['-lc++fs'], language: 'cpp')
elif cpp.has_link_argument('-lc++experimental')
add_project_link_arguments(['-lc++experimental'], language: 'cpp')
elif cpp.has_link_argument('-lstdc++fs')
add_project_link_arguments(['-lstdc++fs'], language: 'cpp')
endif
if get_option('enable_gles32')
cpp.check_header('GLES3/gl32.h', dependencies: glesv2, required: true)
conf_data.set('USE_GLES32', true)
else
conf_data.set('USE_GLES32', false)
endif
if png.found() and jpeg.found()
conf_data.set('BUILD_WITH_IMAGEIO', true)
else
conf_data.set('BUILD_WITH_IMAGEIO', false)
endif
use_vulkan = vulkan.found() and wlroots_features['vulkan_renderer'] and get_option('vulkan_effects')
if use_vulkan
conf_data.set('WF_HAS_VULKANFX', 1)
else
conf_data.set('WF_HAS_VULKANFX', 0)
endif
wayfire_conf_inc = include_directories(['.'])
add_project_arguments(['-Wno-unused-parameter'], language: 'cpp')
if get_option('xwayland').enabled() and not wlroots_features['xwayland']
error('Cannot enable Xwayland in wayfire: wlroots has been built without Xwayland support')
endif
if get_option('xwayland').enabled() or (get_option('xwayland').auto() and wlroots_features['xwayland'])
xcb = dependency('xcb')
conf_data.set('WF_HAS_XWAYLAND', 1)
else
xcb = declare_dependency() # dummy dep
conf_data.set('WF_HAS_XWAYLAND', 0)
endif
if get_option('print_trace')
print_trace = true
else
print_trace = false
endif
add_project_arguments(['-DWF_USE_CONFIG_H'], language: ['cpp', 'c'])
configure_file(input: 'config.h.in',
output: 'config.h',
install: true,
install_dir: join_paths('include', 'wayfire'),
configuration: conf_data)
# Detect address sanitizer
cxx_flags_asan = run_command('/bin/sh', '-c', 'echo $CXXFLAGS $CPPFLAGS | grep fsanitize', check: false)
if get_option('b_sanitize').contains('address') or cxx_flags_asan.returncode() == 0
has_asan = true
else
has_asan = false
endif
if use_vulkan
subdir('shaders')
endif
subdir('proto')
subdir('src')
subdir('scripts')
subdir('man')
subdir('metadata')
subdir('plugins')
if get_option('buildtype') != 'debug' or not get_option('build_locales').auto()
if not get_option('build_locales').disabled()
subdir('locale')
endif
endif
# Unit tests
doctest = dependency('doctest', required: get_option('tests'))
if doctest.found()
subdir('test')
endif
install_data('wayfire.desktop', install_dir :
join_paths(get_option('prefix'), 'share/wayland-sessions'))
install_data('wayfire-portals.conf', install_dir :
join_paths(get_option('prefix'), 'share/xdg-desktop-portal/'))
summary = [
'',
'----------------',
'wayfire @0@'.format(meson.project_version()),
'',
'system wfconfig: @0@'.format(use_system_wfconfig),
' system wlroots: @0@'.format(use_system_wlroots),
' xwayland: @0@'.format(wlroots_features['xwayland']),
' x11-backend: @0@'.format(wlroots_features['x11_backend']),
' imageio: @0@'.format(conf_data.get('BUILD_WITH_IMAGEIO')),
' gles32: @0@'.format(conf_data.get('USE_GLES32')),
' vulkan effects: @0@'.format(conf_data.get('WF_HAS_VULKANFX')),
' print trace: @0@'.format(print_trace),
' unit tests: @0@'.format(doctest.found()),
'----------------',
''
]
message('\n'.join(summary))