forked from artemsen/swayimg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
235 lines (220 loc) · 6.14 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
# Rules for building with Meson
project(
'swayimg',
'c',
default_options: [
'c_std=c99',
'warning_level=3',
],
license: 'MIT',
version: '0.0.0',
meson_version: '>=0.59.0',
)
add_project_arguments(
[
'-D_POSIX_C_SOURCE=200809'
],
language: 'c',
)
cc = meson.get_compiler('c')
# version info
version = get_option('version')
if version == '0.0.0'
git = find_program('git', native: true, required: false)
if git.found()
git_ver = run_command([git, 'describe', '--tags', '--long', '--always', '--dirty'], check: false)
if git_ver.returncode() == 0
version = git_ver.stdout().strip().substring(1)
endif
endif
endif
# mandatory dependencies
wlcln = dependency('wayland-client')
json = dependency('json-c')
xkb = dependency('xkbcommon')
fontconfig = dependency('fontconfig')
freetype = dependency('freetype2')
threads = dependency('threads')
rt = cc.find_library('rt')
# optional dependencies: file formats support
exr = dependency('OpenEXR', version: '>=3.1', required: get_option('exr'))
gif = cc.find_library('gif', required: get_option('gif'))
heif = dependency('libheif', required: get_option('heif'))
avif = dependency('libavif', required: get_option('avif'))
jpeg = dependency('libjpeg', required: get_option('jpeg'))
png = dependency('libpng', required: get_option('png'))
rsvg = dependency('librsvg-2.0', version: '>=2.46', required: get_option('svg'))
tiff = dependency('libtiff-4', required: get_option('tiff'))
webp = dependency('libwebp', required: get_option('webp'))
webp_demux = dependency('libwebpdemux', required: get_option('webp'))
# optional dependencies: other features
exif = dependency('libexif', required: get_option('exif'))
bash = dependency('bash-completion', required: get_option('bash'))
# Arch specific: https://bugs.archlinux.org/task/73931
jxl_feature = get_option('jxl')
jxl = dependency('libjxl', required: false)
if not jxl.found() and (jxl_feature.auto() or jxl_feature.enabled())
jxl = cc.find_library('libjxl', required: jxl_feature)
endif
# non-Linux (BSD specific)
epoll = dependency('epoll-shim', required: false)
inotify = dependency('libinotify', required: false)
# configuration file
conf = configuration_data()
conf.set('HAVE_LIBEXR', exr.found())
conf.set('HAVE_LIBGIF', gif.found())
conf.set('HAVE_LIBHEIF', heif.found())
conf.set('HAVE_LIBAVIF', avif.found())
conf.set('HAVE_LIBJPEG', jpeg.found())
conf.set('HAVE_LIBJXL', jxl.found())
conf.set('HAVE_LIBPNG', png.found())
conf.set('HAVE_LIBRSVG', rsvg.found())
conf.set('HAVE_LIBTIFF', tiff.found())
conf.set('HAVE_LIBWEBP', webp.found() and webp_demux.found())
conf.set('HAVE_LIBEXIF', exif.found())
conf.set('HAVE_INOTIFY', cc.has_header('sys/inotify.h', dependencies: inotify))
conf.set_quoted('APP_NAME', meson.project_name())
conf.set_quoted('APP_VERSION', version)
configure_file(output: 'buildcfg.h', configuration: conf)
# Wayland protocols
wlproto = dependency('wayland-protocols')
wlproto_dir = wlproto.get_variable(pkgconfig : 'pkgdatadir')
wlscan = dependency('wayland-scanner', required: false, native: true)
if wlscan.found()
wl_scanner = find_program(wlscan.get_variable(pkgconfig : 'wayland_scanner'), native: true)
else
wl_scanner = find_program('wayland-scanner', native: true)
endif
# XDG shell Wayland protocol
xdg_shell_xml = join_paths(wlproto_dir, 'stable/xdg-shell/xdg-shell.xml')
xdg_shell_c = custom_target(
'xdg-shell-protocol.c',
output: 'xdg-shell-protocol.c',
input: xdg_shell_xml,
command: [wl_scanner, 'private-code', '@INPUT@', '@OUTPUT@'],
)
xdg_shell_h = custom_target(
'xdg-shell-protocol.h',
output: 'xdg-shell-protocol.h',
input: xdg_shell_xml,
command: [wl_scanner, 'client-header', '@INPUT@', '@OUTPUT@'],
)
# install sample config
install_data('extra/swayimgrc',
install_dir: join_paths(get_option('datadir'), 'swayimg'))
# man installation
if get_option('man')
install_man('extra/swayimg.1')
install_man('extra/swayimgrc.5')
endif
# desktop file + icon
if get_option('desktop')
install_data('extra/swayimg.desktop',
install_dir: join_paths(get_option('datadir'), 'applications'))
install_data('extra/swayimg.png',
install_dir: join_paths(get_option('datadir'), 'icons/hicolor/64x64/apps'))
endif
# zsh completion
zsh = get_option('zsh')
if zsh.auto()
shell = find_program('zsh', required: false)
zsh = zsh.disable_auto_if(not shell.found())
endif
if zsh.allowed()
datadir = get_option('datadir')
zsh_install_dir = join_paths(datadir, 'zsh', 'site-functions')
install_data('extra/zsh.completion',
install_dir: zsh_install_dir,
rename: '_swayimg')
endif
# bash completion installation
if bash.found()
datadir = get_option('datadir')
bash_install_dir = bash.get_variable(pkgconfig : 'completionsdir',
pkgconfig_define: ['datadir', datadir])
install_data('extra/bash.completion',
install_dir: bash_install_dir,
rename: 'swayimg')
endif
# source files
sources = [
'src/canvas.c',
'src/config.c',
'src/font.c',
'src/image.c',
'src/imagelist.c',
'src/info.c',
'src/keybind.c',
'src/main.c',
'src/str.c',
'src/sway.c',
'src/ui.c',
'src/viewer.c',
'src/formats/bmp.c',
'src/formats/pnm.c',
'src/formats/loader.c',
xdg_shell_h,
xdg_shell_c,
]
if exif.found()
sources += 'src/exif.c'
endif
if exr.found()
sources += 'src/formats/exr.c'
endif
if gif.found()
sources += 'src/formats/gif.c'
endif
if heif.found()
sources += 'src/formats/heif.c'
endif
if avif.found()
sources += 'src/formats/avif.c'
endif
if jpeg.found()
sources += 'src/formats/jpeg.c'
endif
if jxl.found()
sources += 'src/formats/jxl.c'
endif
if png.found()
sources += 'src/formats/png.c'
endif
if rsvg.found()
sources += 'src/formats/svg.c'
endif
if tiff.found()
sources += 'src/formats/tiff.c'
endif
if webp.found() and webp_demux.found()
sources += 'src/formats/webp.c'
endif
executable(
'swayimg',
sources,
dependencies: [
# runtime
rt,
threads,
wlcln,
epoll,
inotify,
json,
xkb,
fontconfig,
freetype,
exif,
# image support
exr,
gif,
heif,
avif,
jpeg,
jxl,
png,
rsvg,
tiff,
webp, webp_demux,
],
install: true
)