-
Notifications
You must be signed in to change notification settings - Fork 188
Expand file tree
/
Copy pathmeson.build
More file actions
154 lines (136 loc) · 4.12 KB
/
meson.build
File metadata and controls
154 lines (136 loc) · 4.12 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
project('mango', ['c'],
version : '0.14.2',
)
subdir('protocols')
is_nixos = false
os_release = run_command('cat', '/etc/os-release', check: false)
if os_release.returncode() == 0
if os_release.stdout().contains('ID=nixos')
is_nixos = true
endif
endif
prefix = get_option('prefix')
sysconfdir = get_option('sysconfdir')
# 如果 sysconfdir 以 prefix 开头,去掉 prefix
if sysconfdir.startswith(prefix) and not is_nixos
sysconfdir = sysconfdir.substring(prefix.length())
# 确保 sysconfdir 是绝对路径
if not sysconfdir.startswith('/')
sysconfdir = '/' + sysconfdir
endif
endif
cc = meson.get_compiler('c')
libm = cc.find_library('m')
xcb = dependency('xcb', required : get_option('xwayland'))
xlibs = dependency('xcb-icccm', required : get_option('xwayland'))
wayland_server_dep = dependency('wayland-server',version: '>=1.23.1')
wlroots_dep = dependency('wlroots-0.19',version: '>=0.19.0')
xkbcommon_dep = dependency('xkbcommon')
libinput_dep = dependency('libinput',version: '>=1.27.1')
libwayland_client_dep = dependency('wayland-client')
pcre2_dep = dependency('libpcre2-8')
libscenefx_dep = dependency('scenefx-0.4',version: '>=0.4.1')
pixman_dep = dependency('pixman-1')
cjson_dep = dependency('libcjson')
# version info
git = find_program('git', required : false)
is_git_repo = false
# check if current directory is a git repo
if git.found()
git_status = run_command(git, 'rev-parse', '--is-inside-work-tree', check : false)
if git_status.returncode() == 0 and git_status.stdout().strip() == 'true'
is_git_repo = true
endif
endif
if is_git_repo
# if current directory is a git repo, get commit hash and latest tag
commit_hash = run_command(git, 'rev-parse', '--short', 'HEAD', check : false).stdout().strip()
latest_tag = meson.project_version()
version_with_hash = '@0@(@1@)'.format(latest_tag, commit_hash)
else
# if not a git repo, use project version and "release" string
commit_hash = 'release'
latest_tag = meson.project_version()
version_with_hash = '@0@(@1@)'.format(latest_tag, commit_hash)
endif
# define compilation args
c_args = [
'-g',
'-Wno-unused-function',
'-DWLR_USE_UNSTABLE',
'-D_POSIX_C_SOURCE=200809L',
'-DVERSION="@0@"'.format(version_with_hash),
'-DSYSCONFDIR="@0@"'.format('/etc'),
]
# add debug args only when debug option is enabled
if get_option('asan')
c_args += [
'-fsanitize=address',
'-fno-omit-frame-pointer',
'-fno-optimize-sibling-calls'
]
endif
if xcb.found() and xlibs.found()
c_args += '-DXWAYLAND'
endif
# define link args
link_args = []
if get_option('asan')
link_args += '-fsanitize=address'
endif
executable('mango',
'src/mango.c',
'src/common/util.c',
'src/ext-protocol/wlr_ext_workspace_v1.c',
wayland_sources,
dependencies : [
libm,
xcb,
xlibs,
libscenefx_dep,
wayland_server_dep,
wlroots_dep,
xkbcommon_dep,
libinput_dep,
libwayland_client_dep,
pcre2_dep,
pixman_dep,
cjson_dep,
],
install : true,
c_args : c_args,
link_args : link_args,
)
# build mmsg
dwl_ipc_protocol = 'protocols/dwl-ipc-unstable-v2.xml'
wayland_scanner_client_header = generator(
wayland_scanner,
output: '@BASENAME@-protocol.h',
arguments: ['client-header', '@INPUT@', '@OUTPUT@']
)
wayland_scanner_private_code = generator(
wayland_scanner,
output: '@BASENAME@-protocol.c',
arguments: ['private-code', '@INPUT@', '@OUTPUT@']
)
# use generator in mmsg target
executable('mmsg',
'mmsg/mmsg.c',
wayland_scanner_private_code.process(dwl_ipc_protocol),
wayland_scanner_client_header.process(dwl_ipc_protocol),
dependencies: [
libwayland_client_dep
],
install: true,
c_args: [
'-g',
'-Wno-unused-function',
],
)
mandir = get_option('mandir')
desktop_install_dir = join_paths(prefix, 'share/wayland-sessions')
portal_install_dir = join_paths(prefix, 'share/xdg-desktop-portal')
install_data('assets/mango.desktop', install_dir : desktop_install_dir)
install_data('assets/mango-portals.conf', install_dir : portal_install_dir)
install_data('assets/config.conf', install_dir : join_paths(sysconfdir, 'mango'))
install_data('mmsg/mmsg.1', install_dir : join_paths(mandir, 'man1'))