commit f6d9d01
uint
·
2026-08-04 13:08:39 +0000 UTC
parent f634045
Add Meson build and options files
2 files changed,
+123,
-0
+116,
-0
1@@ -0,0 +1,116 @@
2+project(
3+ 'maus',
4+ 'c',
5+ default_options: [
6+ 'c_std=c89',
7+ 'warning_level=2',
8+ 'optimization=2',
9+ ]
10+)
11+
12+backend = get_option('window_backend')
13+cc = meson.get_compiler('c')
14+
15+inc = include_directories('include')
16+common_sources = [
17+ 'source/maus.c',
18+ 'source/maus_font.c',
19+ 'source/utils.c',
20+]
21+backend_sources = []
22+deps = []
23+c_args = []
24+backend_override_options = ['c_std=c89']
25+lib_name = 'maus_' + backend
26+if backend == 'windows'
27+ lib_name = 'maus_win'
28+endif
29+
30+if backend == 'x11'
31+ c_args += ['-DBACKEND_X11']
32+ deps += [
33+ dependency('x11'),
34+ dependency('xext'),
35+ ]
36+ backend_sources += ['source/maus_x11.c']
37+
38+
39+elif backend == 'wayland'
40+ c_args += ['-DBACKEND_WAY']
41+ backend_override_options = ['c_std=c99']
42+ deps += [ dependency('wayland-client'), dependency('wayland-cursor'), dependency('xkbcommon'), ]
43+
44+ wayland_scanner = find_program('wayland-scanner')
45+ wayland_protocols = dependency('wayland-protocols')
46+ protos = wayland_protocols.get_variable(pkgconfig: 'pkgdatadir')
47+
48+ protocols = [
49+ [ 'xdg-shell', protos / 'stable' / 'xdg-shell' / 'xdg-shell.xml', ],
50+ [ 'pointer-constraints-unstable-v1', protos / 'unstable' / 'pointer-constraints' / 'pointer-constraints-unstable-v1.xml', ],
51+ [ 'relative-pointer-unstable-v1', protos / 'unstable' / 'relative-pointer' / 'relative-pointer-unstable-v1.xml', ],
52+ ]
53+
54+ foreach protocol : protocols
55+ name = protocol[0]
56+ xml = protocol[1]
57+
58+ backend_sources += custom_target(
59+ name + '-client-protocol.h',
60+ input: xml,
61+ output: name + '-client-protocol.h',
62+ command: [wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@'],
63+ )
64+
65+ backend_sources += custom_target(
66+ name + '-protocol.c',
67+ input: xml,
68+ output: name + '-protocol.c',
69+ command: [wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@'],
70+ )
71+ endforeach
72+
73+ backend_sources += ['source/maus_wayland.c']
74+
75+
76+elif backend == 'windows'
77+ c_args += ['-DBACKEND_WIN']
78+ deps += [
79+ cc.find_library('gdi32'),
80+ cc.find_library('user32'),
81+ ]
82+ backend_sources += ['source/maus_win.c']
83+endif
84+
85+common = static_library(
86+ 'maus_common_' + backend,
87+ common_sources,
88+ include_directories: inc,
89+ c_args: c_args,
90+ override_options: ['c_std=c89'],
91+)
92+
93+backend_lib = static_library(
94+ 'maus_backend_' + backend,
95+ backend_sources,
96+ include_directories: inc,
97+ c_args: c_args,
98+ dependencies: deps,
99+ override_options: backend_override_options,
100+)
101+
102+maus = static_library(
103+ lib_name,
104+ objects: [
105+ common.extract_all_objects(recursive: false),
106+ backend_lib.extract_all_objects(recursive: false),
107+ ],
108+ dependencies: deps,
109+)
110+
111+maus_dep = declare_dependency(
112+ include_directories: inc,
113+ link_with: maus,
114+ dependencies: deps,
115+ compile_args: c_args,
116+)
117+
+7,
-0
1@@ -0,0 +1,7 @@
2+option(
3+ 'window_backend',
4+ type: 'combo',
5+ choices: ['x11', 'wayland', 'windows'],
6+ value: 'x11',
7+ description: 'Window system backend'
8+)