forked from linuxwacom/xf86-input-wacom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
414 lines (359 loc) · 10.8 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
project('xf86-input-wacom', 'c',
version : '1.2.2', # bump version in configure.ac
license : 'MIT/Expat',
default_options : [ 'c_std=gnu99', 'warning_level=2' ],
meson_version : '>= 0.51.0')
wacom_version = meson.project_version().split('.')
dir_man1 = get_option('prefix') / get_option('mandir') / 'man1'
dir_man4 = get_option('prefix') / get_option('mandir') / 'man4'
dir_bin = get_option('prefix') / get_option('bindir')
dir_x11_config = get_option('prefix') / get_option('datadir') / 'X11' / 'xorg.conf.d'
dir_pkgconf = get_option('prefix') / get_option('libdir') / 'pkgconfig'
dir_udev = get_option('prefix') / 'lib' / 'udev'
dir_systemd = get_option('prefix') / 'lib' / 'systemd'
dir_src_test = 'test'
dir_src = 'src'
dir_include = 'include'
# Compiler setup
cc = meson.get_compiler('c')
cflags = [
# '-Wall', handled through meson's warning_level option
# '-Wextra', handled through meson's warning_level option
'-Wno-unused-parameter',
'-Wmissing-prototypes',
'-Wstrict-prototypes',
'-Wlogical-op',
'-Wpointer-arith',
'-Wuninitialized',
'-Winit-self',
'-Wstrict-prototypes',
'-Wimplicit-fallthrough',
'-Wredundant-decls',
'-Wincompatible-pointer-types',
'-Wformat=2',
'-Wformat-overflow=2',
'-Wformat-signedness',
'-Wformat-truncation=2',
'-Wmissing-declarations',
'-Wshift-overflow=2',
'-Wstrict-overflow=2',
'-Wswitch-enum',
]
add_project_arguments(cc.get_supported_arguments(cflags), language : 'c')
add_project_arguments('-D_GNU_SOURCE', language : 'c')
build_xsetwacom = get_option('xsetwacom')
# Dependencies
pkgconfig = import('pkgconfig')
dep_xserver = dependency('xorg-server', version: '>= 1.13.0')
if build_xsetwacom
dep_protos = []
protos = ['xproto', 'xext', 'kbproto', 'inputproto', 'randrproto']
foreach proto : protos
dep_protos += [dependency(proto)]
endforeach
xlibs = ['x11', 'xi', 'xrandr', 'xinerama']
dep_xlibs = []
foreach xlib : xlibs
dep_xlibs += [dependency(xlib)]
endforeach
endif
dep_libudev = dependency('libudev')
dep_m = cc.find_library('m')
dir_wacom_headers = get_option('sdkdir')
if dir_wacom_headers == ''
dir_wacom_headers = dep_xserver.get_variable(pkgconfig: 'sdkdir')
endif
dir_xorg_modules = get_option('xorg-module-dir')
if dir_xorg_modules == ''
dir_xorg_modules = dep_xserver.get_variable(pkgconfig: 'moduledir') / 'input'
endif
dir_xorg_conf = get_option('xorg-conf-dir')
if dir_xorg_conf == ''
dir_xorg_conf = dir_x11_config
endif
dir_udev_rules = get_option('udev-rules-dir')
if dir_udev_rules == ''
dir_udev_rules = dir_udev / 'rules.d'
endif
dir_systemd_unit = get_option('systemd-unit-dir')
if dir_udev_rules == ''
dir_systemd_unit = dir_systemd / 'systemd'
endif
# config-ver.h
config_ver_h = vcs_tag(command : ['git', 'describe'],
fallback : meson.project_version(),
input : 'config-ver.h.in',
output :'config-ver.h',
replace_string: '@GITVERSION@')
# config.h
config_h = configuration_data()
config_h.set('_GNU_SOURCE', 1)
config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
config_h.set('PACKAGE_VERSION_MAJOR', wacom_version[0])
config_h.set('PACKAGE_VERSION_MINOR', wacom_version[1])
config_h.set('PACKAGE_VERSION_PATCHLEVEL', wacom_version[2])
# shortcut to avoid linking to _Xasprintf if xorg-server isn't included
if cc.has_function('asprintf',
prefix: '#define _GNU_SOURCE',
args: ['-Wno-error=format'])
config_h.set10('HAVE_ASPRINTF', true)
endif
if get_option('debug-messages')
config_h.set10('DEBUG', true)
endif
if get_option('fuzzinterface')
config_h.set10('BUILD_FUZZINTERFACE', true)
endif
# Driver
src_wacom_core = [
config_ver_h,
'src/WacomInterface.h',
'src/wcmCommon.c',
'src/wcmConfig.c',
'src/wcmFilter.c',
'src/wcmFilter.h',
'src/wcmPressureCurve.c',
'src/wcmTouchFilter.c',
'src/wcmTouchFilter.h',
'src/wcmUSB.c',
'src/wcmValidateDevice.c',
'src/xf86WacomDefs.h',
'src/xf86Wacom.h',
'src/wcmUSB.c',
]
src_wacom = src_wacom_core + [
'src/x11/xf86WacomProperties.c',
'src/x11/xf86Wacom.c',
]
shared_module(
'wacom_drv',
src_wacom,
include_directories: [dir_src, dir_include],
dependencies: [dep_xserver, dep_m],
name_prefix: '', # we want wacomdrv.so, not libwacomdrv.so
install_dir: dir_xorg_modules,
install: true,
# Note: xorg-xserver.pc always appends -fvisibility=hidden so
# this correct but superfluous
gnu_symbol_visibility: 'hidden',
)
conf_pkgconf = configuration_data()
conf_pkgconf.set('PACKAGE_VERSION', meson.project_version())
conf_pkgconf.set('sdkdir', dir_wacom_headers)
configure_file(
input: 'xorg-wacom.pc.in',
output: 'xorg-wacom.pc',
configuration: conf_pkgconf,
install_dir: dir_pkgconf,
)
install_headers(
'include/Xwacom.h',
'include/wacom-properties.h',
'include/isdv4.h',
'include/wacom-util.h',
install_dir: dir_wacom_headers
)
# GWacom library
# This is not a stable library interface
dep_glib = dependency('glib-2.0', required: get_option('wacom-gobject'))
dep_gobject = dependency('gobject-2.0', required: get_option('wacom-gobject'))
dep_gio = dependency('gio-2.0', required: get_option('wacom-gobject'))
dep_gio_unix = dependency('gio-unix-2.0', required: get_option('wacom-gobject'))
dep_object_ir = dependency('gobject-introspection-1.0', required: get_option('wacom-gobject'))
dep_libevdev = dependency('libevdev', required: get_option('wacom-gobject'))
build_gwacom = dep_glib.found() and dep_gobject.found() and dep_gio.found() and dep_gio_unix.found() and dep_object_ir.found() and dep_libevdev.found()
if build_gwacom
gnome = import('gnome')
src_gwacom = [
'src/gwacom/wacom-driver.h',
'src/gwacom/wacom-driver.c',
'src/gwacom/wacom-device.h',
'src/gwacom/wacom-device.c',
]
src_libgwacom = src_wacom_core + src_gwacom
deps_gwacom = [
dep_xserver,
dep_m,
dep_glib,
dep_gobject,
dep_gio,
dep_gio_unix,
dep_libevdev,
]
lib_gwacom = shared_library(
'gwacom',
src_libgwacom + src_wacom_core,
include_directories: [dir_src, dir_include],
dependencies: deps_gwacom,
install: false,
# Note: xorg-xserver.pc always appends -fvisibility=hidden so
# this is the only way to force default visibility
c_args: ['-fvisibility=default'],
)
dep_gwacom = declare_dependency(
link_with: lib_gwacom,
dependencies: deps_gwacom,
include_directories: ['src/gwacom/'],
)
# GIR bindings are not installed, use
# export GI_TYPELIB_PATH="$PWD/builddir:$LD_LIBRARY_PATH"
# export LD_LIBRARY_PATH="$PWD/builddir:$LD_LIBRARY_PATH"
dep_gir = gnome.generate_gir(lib_gwacom,
sources: src_gwacom,
dependencies: [deps_gwacom],
namespace: 'wacom',
nsversion: '1.0',
identifier_prefix: 'Wacom',
symbol_prefix: 'wacom',
includes: 'GObject-2.0',
install: false,
)
# A custom target that forces the GIR bindings to be built. Usually
# those get built on install but we don't install ours.
custom_target('force GIR build',
build_by_default: true,
command: ['echo'],
output: 'force-gir-build.dummy',
capture: true,
depends: [dep_gir])
executable('wacom-record',
'tools/wacom-record.c',
config_ver_h,
dependencies: [dep_libudev, dep_glib, dep_gwacom],
install: false,
)
endif
# Tools
if get_option('serial-device-support')
src_shared = [
'tools/tools-shared.h',
'tools/tools-shared.c',
]
executable(
'isdv4-serial-debugger',
'tools/isdv4-serial-debugger.c', src_shared,
dependencies: [dep_libudev],
include_directories: [dir_include],
install: true,
)
executable(
'isdv4-serial-inputattach',
'tools/isdv4-serial-inputattach.c', src_shared,
dependencies: [dep_libudev],
include_directories: [dir_include],
install: true,
)
endif
if build_xsetwacom
xsetwacom_deps = [dep_xlibs, dep_protos, dep_m]
src_xsetwacom = [
config_ver_h,
'tools/xsetwacom.c',
]
executable(
'xsetwacom',
src_xsetwacom,
dependencies: xsetwacom_deps,
include_directories: [dir_include],
install: true,
)
endif
executable(
'pressurecurve',
['tools/pressurecurve.c',
'src/wcmPressureCurve.c'],
include_directories: [dir_src],
install: false)
# Man pages
config_man = configuration_data()
config_man.set('VERSION', '@0@ @1@'.format(meson.project_name(), meson.project_version()))
configure_file(
input: 'man/wacom.man',
output: 'wacom.4',
configuration: config_man,
install_dir: dir_man4
)
configure_file(
input: 'man/xsetwacom.man',
output: 'xsetwacom.1',
configuration: config_man,
install_dir: dir_man1,
)
# Config files
install_data('conf/70-wacom.conf', install_dir: dir_xorg_conf)
if get_option('serial-device-support')
install_data('conf/wacom.rules', install_dir: dir_udev_rules)
conf_service = configuration_data()
conf_service.set('BIN_PREFIX', dir_bin)
configure_file(
input: 'conf/[email protected]',
output: '[email protected]',
configuration: conf_service,
install_dir: dir_systemd_unit,
)
endif
# Tests
build_unittests = not get_option('unittests').disabled()
if build_unittests
if build_xsetwacom
xsetwacom_test = executable(
'xsetwacom-test',
src_xsetwacom + ['test/wacom-test-suite.c', 'test/wacom-test-suite.h'],
c_args: ['-DENABLE_TESTS', '-Wno-unused-function'],
dependencies: xsetwacom_deps,
include_directories: [dir_include, dir_src, dir_src_test],
)
test('xsetwacom-tests', xsetwacom_test)
endif
# Rebuild the driver with -DENABLE_TESTS to enable all the various
# local tests in the files. This is built as a module (like the
# driver) so we don't need to resolve any symbols until runtime.
# Look at wacom-test-suite.(c|h) for the magic sauce.
wacom_drv_test = shared_module(
'wacom_drv_test',
src_wacom + ['test/wacom-test-suite.c', 'test/wacom-test-suite.h'],
include_directories: [dir_src, dir_include, dir_src_test],
dependencies: [dep_xserver, dep_m],
name_prefix: '', # we want wacom_drv_test.so, not libwacom_drv_test.so
install: false,
# Note: xorg-xserver.pc always appends -fvisibility=hidden so
# this is the only way to force default visibility
c_args: ['-DENABLE_TESTS', '-fvisibility=default'],
)
dep_dl = cc.find_library('dl')
# wacom-tests.c is just a stub to load the above driver and run the
# entry point.
test('wacom-tests',
executable(
'wacom-tests',
'test/wacom-tests.c',
dependencies: [dep_dl],
install: false),
env: [
'LD_LIBRARY_PATH=@0@'.format(meson.current_build_dir()),
]
)
devenv = environment()
devenv.set('LD_LIBRARY_PATH', meson.current_build_dir())
devenv.set('GI_TYPELIB_PATH', meson.current_build_dir())
# pytest doesn't like asan or ubsan
if build_gwacom and get_option('b_sanitize') == 'none'
pymod = import('python')
pymod.find_installation(
'python3',
modules: ['libevdev', 'pytest', 'yaml', 'attr', 'gi']
)
pytest = find_program('pytest-3', 'pytest')
test('pytest',
pytest,
args: ['--verbose', '--log-level=DEBUG'],
env: devenv,
workdir: meson.current_source_dir(),
)
endif
if meson.version().version_compare('>= 0.58.0')
meson.add_devenv(devenv)
endif
endif
# Now generate config.h
configure_file(output: 'config.h', configuration: config_h)