forked from canonical/netplan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeson.build
134 lines (121 loc) · 4.46 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
project('netplan', 'c',
version: '0.106',
license: 'GPL3',
default_options: [
'c_std=c99',
'warning_level=1',
'werror=true',
],
meson_version: '>= 0.61.0',
)
glib = dependency('glib-2.0')
gio = dependency('gio-2.0')
yaml = dependency('yaml-0.1')
uuid = dependency('uuid')
libsystemd = dependency('libsystemd')
meson_make_symlink = meson.current_source_dir() + '/tools/meson-make-symlink.sh'
systemd = dependency('systemd')
completions = dependency('bash-completion')
systemd_generator_dir = systemd.get_variable(pkgconfig: 'systemdsystemgeneratordir')
bash_completions_dir = completions.get_variable(pkgconfig: 'completionsdir', default_value: '/etc/bash_completion.d')
# Order: Fedora/Mageia/openSUSE || Debian/Ubuntu
pyflakes = find_program('pyflakes-3', 'pyflakes3', required: false)
pycodestyle = find_program('pycodestyle-3', 'pycodestyle', 'pep8', required: false)
pytest = find_program('pytest-3', 'pytest3') # also requires the pytest-cov plugin
pycoverage = find_program('coverage-3', 'python3-coverage')
pandoc = find_program('pandoc', required: false)
find = find_program('find')
add_project_arguments(
'-DSBINDIR="' + join_paths(get_option('prefix'), get_option('sbindir')) + '"',
'-D_GNU_SOURCE',
language: 'c')
inc = include_directories('include')
subdir('include')
subdir('src')
subdir('dbus')
subdir('netplan')
subdir('examples')
subdir('doc')
pkg_mod = import('pkgconfig')
pkg_mod.generate(
libraries: libnetplan,
subdirs: ['netplan'],
name: 'libnetplan',
filebase: 'netplan',
description: 'YAML network configuration abstraction runtime library')
install_data(
'netplan.completions',
rename: 'netplan',
install_dir: bash_completions_dir)
###########
# Testing #
###########
test_env = [
'PYTHONPATH=' + meson.current_source_dir(),
'LD_LIBRARY_PATH=' + join_paths(meson.current_build_dir(), 'src'),
'NETPLAN_GENERATE_PATH=' + join_paths(meson.current_build_dir(), 'src', 'generate'),
'NETPLAN_DBUS_CMD=' + join_paths(meson.current_build_dir(), 'dbus', 'netplan-dbus'),
'COVERAGE_PROCESS_START=' + join_paths(meson.current_source_dir(), '.coveragerc'),
]
if get_option('unit_testing')
subdir('tests/ctests')
endif
#FIXME: exclude doc/env/
test('linting',
pyflakes,
args: [meson.current_source_dir()])
test('codestyle',
pycodestyle,
args: ['--max-line-length=130', '--exclude=doc/env', meson.current_source_dir()])
test('documentation',
find_program('tests/validate_docs.sh'),
workdir: meson.current_source_dir())
test('legacy-tests',
find_program('tests/cli_legacy.py'),
timeout: 120,
env: test_env)
#TODO: split out dbus tests into own test() instance, to run in parallel
test('unit-tests',
pycoverage,
args: ['run', '-a', '-m', 'pytest', '-s', '-v', '--cov-append', meson.current_source_dir()],
timeout: 600,
env: test_env)
#TODO: the coverage section should probably be cleaned up a bit
if get_option('b_coverage')
message('Find coverage reports in <BUILDDIR>/meson-logs/coveragereport[-py]/')
# Using gcovr instead of lcov/gcov.
# The 'ninja coverage' command will produce the html/txt reports for C implicitly
#lcov = find_program('lcov')
#gcov = find_program('gcov')
#genhtml = find_program('genhtml')
gcovr = find_program('gcovr')
ninja = find_program('ninja')
grep = find_program('grep')
test('coverage-c-output',
find_program('ninja'),
args: ['-C', meson.current_build_dir(), 'coverage'],
timeout: 60,
priority: -90, # run before 'coverage-c'
is_parallel: false)
test('coverage-c',
grep,
args: ['^TOTAL.*100%$', join_paths(meson.current_build_dir(), 'meson-logs', 'coverage.txt')],
priority: -99, # run last
is_parallel: false)
test('coverage-py-combine',
pycoverage,
args: ['combine', '-a', meson.current_build_dir()],
priority: -90, # run before 'coverage-py-output'
is_parallel: false)
test('coverage-py-output',
pycoverage,
args: ['html', '-d', join_paths(meson.current_build_dir(),
'meson-logs', 'coveragereport-py'), '--omit=/usr*'],
priority: -95, # run before 'coverage-py'
is_parallel: false)
test('coverage-py',
pycoverage,
args: ['report', '--omit=/usr*', '--show-missing', '--fail-under=100'],
priority: -99, # run last
is_parallel: false)
endif