forked from managarm/managarm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
253 lines (210 loc) · 6.44 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
project('managarm',
license : 'MIT',
meson_version : '>=0.57.0',
default_options : [
'cpp_std=gnu++20',
'c_std=gnu11',
'warning_level=2'
]
)
add_project_arguments('-Wimplicit-fallthrough', '-Werror=misleading-indentation', '-Werror=switch', language: ['c', 'cpp'])
add_project_arguments('-Wno-missing-field-initializers', language: 'cpp')
# build documentation
if get_option('build_docs')
subdir('docs')
doxyfile = configure_file(
input : 'hel/Doxyfile.in',
output : 'Doxyfile',
configuration : {
'ROOTDIR': meson.current_source_dir()/'hel'
}
)
doxygen = find_program('doxygen', required : false)
if doxygen.found()
custom_target('hel-doxygen',
input : doxyfile,
output : 'hel-api',
depend_files : 'hel/include/hel.h',
command : [ doxygen, doxyfile ]
)
endif
endif
build_kernel = get_option('build_kernel')
build_drivers = get_option('build_drivers')
build_tools = get_option('build_tools')
provide_deps = get_option('provide_deps')
any_userspace = build_drivers or build_tools
if build_kernel
add_project_link_arguments(['-Wl,--orphan-handling=warn', '-Wl,-znoexecstack'], language: ['c', 'cpp'])
endif
if build_kernel or build_drivers
add_languages('c', 'cpp', native: false)
endif
if build_tools
add_languages('c', 'cpp')
endif
if build_kernel and any_userspace
error('Cannot build kernel and userspace components at the same time')
endif
# Set flavor = {'kernel', 'userspace', 'none'}.
# Use this variable below if we need conflicting settings in each of the cases.
if build_kernel
flavor = 'kernel'
elif any_userspace
flavor = 'userspace'
else
flavor = 'none'
endif
summary('Build flavor', flavor, section : 'Configuration')
if flavor == 'kernel'
if not meson.is_cross_build()
error('Kernel can only be cross-compiled')
endif
elif flavor == 'userspace'
summary({'System' : build_drivers,
'Tools' : build_tools},
section : 'Userspace Components', bool_yn : true)
endif
if not build_kernel and not build_drivers and not build_tools and not provide_deps
subdir_done()
endif
if provide_deps and (build_kernel or any_userspace)
error('The \'provide_deps\' option cannot be used with any \'build_*\' option')
endif
# declare constants that subdirs are going to use
if not provide_deps
c = meson.get_compiler('cpp')
cxx = meson.get_compiler('cpp')
endif
arch = host_machine.cpu_family()
protos = meson.project_source_root()/'protocols'
server = get_option('libdir')/'managarm/server'
kasan = get_option('kernel_kasan')
ubsan = get_option('kernel_ubsan')
log_alloc = get_option('kernel_log_allocations')
frame_pointers = get_option('kernel_frame_pointers')
supported_archs = [
'aarch64',
'riscv64',
'x86_64'
]
if not supported_archs.contains(arch)
error('unknown architecture ' + arch)
endif
bragi = find_program('bragi')
frigg = dependency('frigg',
default_options : [ 'frigg_no_install=true' ],
fallback: ['frigg', 'frigg_dep'],
required: (not provide_deps)
)
cxxbragi = generator(bragi,
output : '@[email protected]',
arguments : [ '-l', 'stdc++', '--protobuf', '@INPUT@', '@OUTPUT@' ]
)
frgbragi = generator(bragi,
output : '@[email protected]_bragi.hpp',
arguments : [ '-l', 'frigg', '--protobuf', '@INPUT@', '@OUTPUT@' ]
)
# declare dependencies that subdirs are going to use
bragi_dep = subproject('bragi', default_options: ['install_headers=false']).get_variable('bragi_dep')
# If we are building the kernel, we need the freestanding subset of libarch.
if flavor == 'kernel' or flavor == 'none'
libarch_opts = [ 'install_headers=false', 'header_only=true' ]
elif flavor == 'userspace'
libarch_opts = [ 'install_headers=false' ]
endif
if build_kernel or build_drivers or provide_deps
cxxshim_dep = dependency('cxxshim',
required: false,
fallback: ['cxxshim', 'cxxshim_dep'])
coroutines = dependency('cxxshim-coroutine-std',
required: false,
fallback: ['cxxshim', 'std_coroutine_dep'])
endif
if build_kernel or build_drivers
libarch = subproject('libarch',
default_options : libarch_opts
).get_variable('libarch_dep')
endif
if build_kernel
cralgo = subproject('cralgo')
uacpi = subproject('uacpi')
libasync = subproject('libasync', default_options : [ 'install_headers=false' ])
cralgo_sources = cralgo.get_variable('sources')
cralgo_includes = cralgo.get_variable('includes')
uacpi_sources = uacpi.get_variable('sources')
uacpi_includes = uacpi.get_variable('includes')
libasync_dep = libasync.get_variable('libasync_dep')
subdir('hel')
subdir('kernel/eir')
subdir('kernel/thor')
endif
if build_drivers
bakesvr = find_program('bakesvr')
libudev_dep = dependency('libudev')
cli11_dep = dependency('CLI11')
endif
if build_drivers or provide_deps
subdir('protocols/posix')
# this produces the helix dependency which
# all other protocols depend on
subdir('hel')
protocols = [ 'clock', 'fs', 'hw', 'mbus', 'usb', 'svrctl', 'kerncfg', 'kernlet', 'ostrace' ]
core = [ 'core', 'core/drm', 'core/virtio', 'mbus' ]
posix = [ 'subsystem', 'init' ]
drivers = [
# libraries
'libblockfs', 'libevbackend',
# storage
'block/ata', 'block/virtio-blk', 'block/ahci', 'block/nvme',
# net
'nic/usb_net', 'nic/rtl8168', 'nic/freebsd-e1000',
# gfx
'gfx/bochs', 'gfx/intel', 'gfx/virtio', 'gfx/plainfb', 'gfx/vmware',
# io
'kbd', 'tty/virtio-console', 'uart',
# usb
'usb/hcds/uhci', 'usb/hcds/ehci', 'usb/hcds/xhci',
'usb/devices/hid', 'usb/devices/storage', 'usb/devices/serial',
# misc
'kernletcc'
]
utils = [ 'runsvr', 'lsmbus' ]
testsuites = [ 'kernel-bench', 'kernel-tests', 'posix-torture', 'posix-tests', 'virt-test' ]
# delay these dirs until last as they require other libs
# to already be built
delay = [ 'drivers/nic/virtio', 'servers/netserver', 'drivers/clocktracker' ]
foreach dir : protocols
subdir('protocols'/dir)
endforeach
endif
if build_drivers
foreach dir : core
subdir(dir)
endforeach
foreach dir : posix
subdir('posix'/dir)
endforeach
foreach dir : drivers
subdir('drivers'/dir)
endforeach
foreach dir : utils
subdir('utils'/dir)
endforeach
foreach dir : testsuites
subdir('testsuites'/dir)
endforeach
foreach dir : delay
subdir(dir)
endforeach
rules = [ 'drivers/gfx/90-managarm-vga.rules', 'drivers/nic/90-managarm-nic.rules', 'drivers/usb/90-managarm-usb.rules' ]
install_data(rules, install_dir : 'lib/udev/rules.d')
endif
# when building these tools make sure they stay below everything else
# as they depend on parts above
if build_tools
cli11_dep = dependency('CLI11')
foreach tool : [ 'ostrace', 'bakesvr' ]
subdir('tools'/tool)
endforeach
endif