forked from artemsen/swayimg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
259 lines (239 loc) · 6.74 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
# Rules for building with Meson
project(
'swayimg',
'c', 'cpp',
default_options: [
'c_std=c99',
'warning_level=3',
'buildtype=release',
],
license: 'MIT',
version: '0.0.0',
meson_version: '>=0.60.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'))
heif = dependency('libheif', required: get_option('heif'))
avif = dependency('libavif', required: get_option('avif'))
jpeg = dependency('libjpeg', required: get_option('jpeg'))
jxl = dependency('libjxl', required: get_option('jxl'))
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'))
# hack to build "pkgconfigless" gif in FreeBSD
gif_opt = get_option('gif')
if gif_opt.disabled()
gif = cc.find_library('gif', required: gif_opt)
else
gif = cc.find_library('gif', required: false)
if not gif.found() and gif_opt.allowed()
gif = cc.find_library('gif',
dirs: wlcln.get_variable(pkgconfig: 'libdir'),
required: gif_opt)
endif
endif
# optional dependencies: other features
exif = dependency('libexif', required: get_option('exif'))
bash = dependency('bash-completion', required: get_option('bash'))
# 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 = 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: 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: get_option('datadir') / 'applications')
install_data('extra/icon_64.png', rename: 'swayimg.png',
install_dir: get_option('datadir') / 'icons/hicolor/64x64/apps')
install_data('extra/icon_128.png', rename: 'swayimg.png',
install_dir: get_option('datadir') / 'icons/hicolor/128x128/apps')
install_data('extra/icon_256.png', rename: 'swayimg.png',
install_dir: get_option('datadir') / 'icons/hicolor/256x256/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 = 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
# unit tests
if get_option('tests').enabled()
subdir('test')
endif
# source files
sources = [
'src/action.c',
'src/application.c',
'src/config.c',
'src/event.c',
'src/fetcher.c',
'src/font.c',
'src/gallery.c',
'src/image.c',
'src/imagelist.c',
'src/info.c',
'src/keybind.c',
'src/loader.c',
'src/main.c',
'src/memdata.c',
'src/pixmap.c',
'src/sway.c',
'src/ui.c',
'src/viewer.c',
'src/formats/bmp.c',
'src/formats/pnm.c',
'src/formats/tga.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
)