-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeson.build
149 lines (128 loc) · 4.03 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
project('pingpath', 'c',
default_options: [ # 'c_std=gnu99,c99',
'warning_level=2' ],
meson_version: '>= 0.53',
license: 'GPL-2.0-or-later',
version: '.'.join(['0', '3', find_program('git', required: false).found() ?
run_command('git', 'rev-list', '--count', 'd3da356..HEAD', check: false).stdout().strip() : ''
]).strip('.'),
)
add_project_arguments('-D_GNU_SOURCE', language: 'c')
name = meson.project_name()
dnd = get_option('DND')
json = get_option('JSON')
plot = get_option('PLOT')
nls = get_option('NLS')
docdir = get_option('docdir')
pingdir = get_option('pingdir')
summary({'DND': dnd, 'JSON': json, 'PLOT': plot, 'NLS': nls}, bool_yn: true)
config = configuration_data()
# sources
srcs = [name + '.c']
srcs += 'common.c'
srcs += 'pinger.c'
srcs += 'parser.c'
srcs += 'stat.c'
srcs += 'series.c'
srcs += 'dns.c'
srcs += 'whois.c'
srcs += 'cli.c'
ui = 'ui'
srcs += ui/ 'style.c'
srcs += ui/ 'appbar.c'
srcs += ui/ 'action.c'
srcs += ui/ 'option.c'
srcs += ui/ 'clipboard.c'
srcs += ui/ 'notifier.c'
tb = 'tabs'
srcs += tb/ 'aux.c'
srcs += tb/ 'ping.c'
srcs += tb/ 'graph.c'
srcs += tb/ 'log.c'
#
cc = meson.get_compiler('c')
# aux
fnhdr = {
'secure_getenv': 'stdlib.h',
'localtime_r': 'time.h',
'uselocale': 'locale.h',
}
foreach fn, hdr: fnhdr
if cc.has_function(fn, prefix: '#define _GNU_SOURCE\n#include <' + hdr + '>\n')
config.set('HAVE_' + fn.underscorify().to_upper(), 1)
endif
endforeach
# dependencies
deps = [cc.find_library('m', required: true)]
deps += dependency('gtk4', required: true)
# optional: DND (default ON)
if dnd
config.set('WITH_DND', 1)
endif
# optional: JSON (default ON)
if json
config.set('WITH_JSON', 1)
deps += dependency('json-glib-1.0', required: true)
endif
# optional: PLOT (default ON)
if plot
config.set('WITH_PLOT', 1)
srcs += tb/ 'plot.c'
srcs += tb/ 'plot_aux.c'
srcs += tb/ 'plot_pango.c'
deps += dependency('gl', required: true)
deps += dependency('cglm', required: true)
deps += dependency('epoxy', required: true)
endif
# optional: NLS (default ON)
if nls
config.set('WITH_NLS', 1)
subdir('po')
endif
# optional: WITH_SNAPHINT (default OFF)
if get_option('WITH_SNAPHINT')
config.set('WITH_SNAPHINT', 1)
endif
if pingdir != ''
config.set_quoted('PINGDIR', pingdir)
endif
prefix = get_option('prefix')
datadir = get_option('datadir')
localedir = get_option('localedir')
config.set_quoted('DATADIR', prefix / datadir)
config.set_quoted('LOCALEDIR', prefix / localedir)
config_h = 'config.h'
configure_file(output: config_h, configuration: config)
add_project_arguments('-include', config_h, language: 'c')
pp = executable(name, srcs, dependencies: deps, install: true)
asst = 'assets'
desk = name + '.desktop'
install_data(asst / desk, rename: 'net.tools.' + desk, install_dir: datadir / 'applications')
install_man(name + '.1')
install_data(asst / 'icons' / name + '.svg', install_dir: datadir / 'icons/hicolor/scalable/apps')
conf = name + '.conf'
datadoc = docdir != '' ? docdir : datadir / 'doc'
install_data(conf + '.sample', rename: conf, install_dir: datadoc / name / 'examples')
text_mode = ['--cycles', '1', '--recap', 't', 'localhost']
test_args = [['--version'], text_mode]
if json
test_args += [['--cycles', '1', '--recap', 'j', 'localhost']]
test_args += [['--cycles', '1', '--recap', 'J', 'localhost']]
endif
test_args += [['--cycles', '1', '--recap', 'c', 'localhost']]
test_args += [['--numeric'] + text_mode]
test_args += [['--interval', '2'] + text_mode]
test_args += [['--payload', 'ff'] + text_mode]
test_args += [['--ttl', '2'] + text_mode]
test_args += [['--info', 'hacdr'] + text_mode]
test_args += [['--stat', 'lsrmbwaj'] + text_mode]
test_args += [['-4'] + text_mode]
test_args += [['-6'] + ['--cycles', '1', '--recap', 't', '::1']]
test_args += [['--file', meson.current_source_dir() / name + '.conf.sample'] + text_mode]
foreach args: test_args
cmd = ' '.join([name] + args)
if meson.version().version_compare('>=0.58')
cmd = cmd.replace(':', '_')
endif
test(cmd, pp, args: args)
endforeach