Skip to content

Commit b7594ef

Browse files
authored
Create meson.build
1 parent bc7cce5 commit b7594ef

1 file changed

Lines changed: 159 additions & 0 deletions

File tree

source-code/meson.build

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
project('gameframe', 'c',
2+
version: '0.1.0',
3+
license: 'MIT',
4+
meson_version: '>=0.58.1',
5+
default_options: [
6+
'c_std=c11',
7+
'warning_level=2',
8+
'werror=true',
9+
],
10+
)
11+
12+
add_project_arguments(
13+
[
14+
'-DWLR_USE_UNSTABLE',
15+
'-Wundef',
16+
'-Wno-unused-parameter',
17+
],
18+
language: 'c',
19+
)
20+
21+
if get_option('buildtype').startswith('debug')
22+
add_project_arguments('-DDEBUG', language : 'c')
23+
endif
24+
25+
cc = meson.get_compiler('c')
26+
27+
is_freebsd = host_machine.system().startswith('freebsd')
28+
if is_freebsd
29+
add_project_arguments(
30+
[
31+
'-Wno-format-extra-args',
32+
'-Wno-gnu-zero-variadic-macro-arguments',
33+
],
34+
language: 'c'
35+
)
36+
endif
37+
38+
wlroots = dependency('wlroots', fallback: ['wlroots', 'wlroots'])
39+
wayland_protos = dependency('wayland-protocols', version: '>=1.14')
40+
wayland_server = dependency('wayland-server')
41+
xkbcommon = dependency('xkbcommon')
42+
math = cc.find_library('m')
43+
44+
wl_protocol_dir = wayland_protos.get_variable('pkgdatadir')
45+
wayland_scanner = find_program('wayland-scanner')
46+
wayland_scanner_server = generator(
47+
wayland_scanner,
48+
output: '@[email protected]',
49+
arguments: ['server-header', '@INPUT@', '@OUTPUT@'],
50+
)
51+
52+
server_protocols = [
53+
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
54+
]
55+
56+
server_protos_headers = []
57+
58+
foreach p : server_protocols
59+
xml = join_paths(p)
60+
server_protos_headers += wayland_scanner_server.process(xml)
61+
endforeach
62+
63+
server_protos = declare_dependency(
64+
sources: server_protos_headers,
65+
)
66+
67+
have_xwayland = wlroots.get_variable(pkgconfig: 'have_xwayland', internal: 'have_xwayland') == 'true'
68+
69+
version = '@0@'.format(meson.project_version())
70+
git = find_program('git', native: true, required: false)
71+
if git.found()
72+
git_commit = run_command([git, 'rev-parse', '--short', 'HEAD'], check: false)
73+
git_branch = run_command([git, 'rev-parse', '--abbrev-ref', 'HEAD'], check: false)
74+
if git_commit.returncode() == 0 and git_branch.returncode() == 0
75+
version = '@0@-@1@ (branch \'@2@\')'.format(
76+
meson.project_version(),
77+
git_commit.stdout().strip(),
78+
git_branch.stdout().strip(),
79+
)
80+
endif
81+
endif
82+
83+
conf_data = configuration_data()
84+
conf_data.set10('GAMEFRAME_HAS_XWAYLAND', have_xwayland)
85+
conf_data.set_quoted('GAMEFRAME_VERSION', version)
86+
87+
scdoc = dependency('scdoc', version: '>=1.9.2', native: true, required: get_option('man-pages'))
88+
if scdoc.found()
89+
scdoc_prog = find_program(scdoc.get_variable('scdoc'), native: true)
90+
sh = find_program('sh', native: true)
91+
mandir = get_option('mandir')
92+
man_files = [
93+
'gameframe.1.scd'
94+
]
95+
foreach filename : man_files
96+
topic = filename.split('.')[-3].split('/')[-1]
97+
section = filename.split('.')[-2]
98+
output = '@0@.@1@'.format(topic, section)
99+
100+
custom_target(
101+
output,
102+
input: filename,
103+
output: output,
104+
command: [
105+
sh, '-c', '@0@ < @INPUT@ > @1@'.format(scdoc_prog.full_path(), output)
106+
],
107+
install: true,
108+
install_dir: '@0@/man@1@'.format(mandir, section)
109+
)
110+
endforeach
111+
endif
112+
113+
gameframe_sources = [
114+
'main.c',
115+
'idle_inhibit_v1.c',
116+
'output.c',
117+
'seat.c',
118+
'view.c',
119+
'xdg_shell.c',
120+
]
121+
122+
gameframe_headers = [
123+
configure_file(input: 'config.h.in',
124+
output: 'config.h',
125+
configuration: conf_data),
126+
'idle_inhibit_v1.h',
127+
'output.h',
128+
'seat.h',
129+
'server.h',
130+
'view.h',
131+
'xdg_shell.h',
132+
]
133+
134+
if conf_data.get('GAMEFRAME_HAS_XWAYLAND', 0) == 1
135+
gameframe_sources += 'xwayland.c'
136+
gameframe_headers += 'xwayland.h'
137+
endif
138+
139+
executable(
140+
meson.project_name(),
141+
gameframe_sources + gameframe_headers,
142+
dependencies: [
143+
server_protos,
144+
wayland_server,
145+
wlroots,
146+
xkbcommon,
147+
math,
148+
],
149+
install: true,
150+
)
151+
152+
summary = [
153+
'',
154+
'Gameframe @0@'.format(version),
155+
'',
156+
' xwayland: @0@'.format(have_xwayland),
157+
''
158+
]
159+
message('\n'.join(summary))

0 commit comments

Comments
 (0)