-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathmeson.build
144 lines (127 loc) · 3.92 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
project(
'adapterremoval3',
'cpp',
version: '3.0.0-alpha3',
meson_version: '>=1.2.0',
default_options: {
'buildtype': 'debugoptimized',
'cpp_std': 'c++17',
'optimization': '2',
'warning_level': '3',
# Disable costly (libc++) assertions in release mode
'b_ndebug': 'if-release',
},
)
compiler = meson.get_compiler(
'cpp',
)
compiler_id = compiler.get_id()
compiler_version = compiler.version()
################################################################################
add_project_arguments(
compiler.get_supported_arguments(
'-fno-rtti',
'-pedantic-errors',
'-Wfatal-errors', # Terminate on the first error to simplify debugging
# Additional warnings
'-Wcast-align',
'-Wcast-qual',
'-Wctor-dtor-privacy',
'-Wdate-time',
'-Wdeprecated',
'-Wdisabled-optimization',
'-Weffc++',
'-Wformat=2',
'-Winit-self',
'-Wold-style-cast',
'-Woverloaded-virtual',
'-Wpedantic',
'-Wredundant-decls',
'-Wsign-promo',
'-Wstrict-overflow=2',
'-Wswitch-default', # Require a default: statement in a switch, to catch corruption
'-Wswitch-enum', # Require all enum values in a switch, to catch unhandled cases
'-Wundef', # Undefined variables used in #if pragmas
checked: 'off',
),
# TODO: Remove once Makefile has been deleted
'-DMESON',
language: 'cpp',
)
# Build static binary, forcing linking against static libraries
static = get_option('static')
if static
add_project_link_arguments(
compiler.get_supported_link_arguments(
'-static',
),
language: 'cpp',
)
endif
# Hardening flags based on https://wiki.debian.org/Hardening
harden = get_option('harden')
if harden
add_project_arguments(
compiler.get_supported_arguments(
'-D_FORTIFY_SOURCE=2',
'-fPIE',
'-fstack-protector-all',
'-fstack-clash-protection',
),
language: 'cpp',
)
add_project_link_arguments(
compiler.get_supported_link_arguments(
'-pie',
'-Wl,-z,relro',
'-Wl,-z,now',
'-Wl,-z,noexecstack',
),
language: 'cpp',
)
endif
libisal = dependency('libisal', version: ['>=2.30.0', '<3'], static: static)
libdeflate = dependency('libdeflate', version: ['>=1', '<2'], static: static)
libthreads = dependency('threads', static: static)
################################################################################
subdir('src')
subdir('docs')
subdir('examples')
subdir('tests')
install_data(
'README.md',
install_dir: get_option('datadir') / meson.project_name(),
)
################################################################################
# Helper targets for building static/distro independent binaries
# Name of podman container for static compilation
container_name = 'ar3static'
container_runner = find_program('podman', 'docker', required: false)
if container_runner.found()
run_target(
'static-container',
command: [
container_runner,
'build',
'-f', meson.current_source_dir() / 'Containerfile',
'-t', container_name,
meson.current_source_dir(),
],
)
run_target(
'static',
command: [
container_runner,
'run',
'--rm',
'-t',
'--mount', 'type=bind,src=@0@/,dst=/root/src/'.format(meson.current_source_dir()),
'--mount', 'type=bind,src=@0@/,dst=/root/out/'.format(meson.current_build_dir()),
container_name,
],
)
endif
################################################################################
summary('type', get_option('buildtype'), section: 'Build')
summary('static', static, section: 'Build')
summary('harden', harden, section: 'Build')