-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmeson.build
More file actions
318 lines (265 loc) · 10.2 KB
/
meson.build
File metadata and controls
318 lines (265 loc) · 10.2 KB
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# SPDX-FileCopyrightText: 2019 Benedikt Steinmeier
# SPDX-FileCopyrightText: 2019 Gerion Entrup <entrup@sra.uni-hannover.de>
# SPDX-FileCopyrightText: 2019 Manuel Breiden
# SPDX-FileCopyrightText: 2020 Björn Fiedler <fiedler@sra.uni-hannover.de>
# SPDX-FileCopyrightText: 2020 Fredo Nowak
# SPDX-FileCopyrightText: 2020 Kenny Albes
# SPDX-FileCopyrightText: 2020 Manuel Breiden
# SPDX-FileCopyrightText: 2022 Bastian Fuhlenriede
# SPDX-FileCopyrightText: 2022 Björn Fiedler <fiedler@sra.uni-hannover.de>
# SPDX-FileCopyrightText: 2022 Gerion Entrup <entrup@sra.uni-hannover.de>
# SPDX-FileCopyrightText: 2022 Jan Neugebauer
# SPDX-FileCopyrightText: 2023 Jan Neugebauer
# SPDX-FileCopyrightText: 2023 Andreas Kässens
#
# SPDX-License-Identifier: GPL-3.0-or-later
project('ara', 'cpp',
default_options : ['warning_level=3',
'cpp_std=c++17',
'buildtype=debugoptimized'],
meson_version: '>=1.10.0', version: 'SRA\'26'
)
add_project_arguments('-Werror=return-type', language: ['c', 'cpp'])
# c-linkage is not correct, see https://github.com/cython/cython/issues/1839
compiler = meson.get_compiler('cpp')
if compiler.has_argument('-Wno-error=return-type-c-linkage')
add_project_arguments('-Wno-error=return-type-c-linkage', language: ['c', 'cpp'])
endif
# The boost headers spam lots of warnings if this is not set
add_project_arguments([ '-DBOOST_ALLOW_DEPRECATED_HEADERS' ], language: 'cpp')
fs = import('fs')
# check all dependencies first
cython = find_program('cython', version: '>=0.29.14')
cython_flags = ['-Wextra', '--cplus', '-3']
py3_mod = import('python')
# TODO add version argument to find_installation: see https://github.com/mesonbuild/meson/issues/7078
python_modules = ['pydot', 'graph_tool', 'versuchung'] # TODO put versuchung to the places where it is actually needed
if get_option('gui_required')
python_modules += ['PySide6', 'scipy']
endif
py3_inst = py3_mod.find_installation('python3', modules: python_modules)
if py3_inst.language_version().version_compare('<3.10')
error('At least Python 3.10 is required.')
endif
## llvm dependencies
llvm_version = ['>=14', '<15']
llvm_dep = dependency('llvm', method: 'config-tool', version: llvm_version, include_type: 'system')
toolchains = subproject('toolchains')
arm_enabled = toolchains.get_variable('arm_enabled')
posix_enabled = toolchains.get_variable('posix_enabled')
riscv_enabled = toolchains.get_variable('riscv_enabled')
clang = toolchains.get_variable('clang')
llc = toolchains.get_variable('llc')
llvm_dis = toolchains.get_variable('llvm_dis')
llvm_opt = toolchains.get_variable('llvm_opt')
distro_id = run_command('lsb_release', '-is', check: true).stdout().strip().to_lower()
boost_python = 'python' + (distro_id == 'opensuse' ? '3' : py3_inst.language_version().replace('.', ''))
boost_dep = dependency('boost', include_type: 'system', modules: ['graph', boost_python])
graph_tool_dep = dependency('graph-tool-py' + py3_inst.language_version(), include_type: 'system', version: '>=2.68')
# Workaround for https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1070676
graph_tool_inc = '/usr/lib/python3/dist-packages/graph_tool/include'
if fs.is_dir(graph_tool_inc)
missing_includes = declare_dependency(
include_directories: graph_tool_inc
)
graph_tool_dep = declare_dependency (
dependencies: [graph_tool_dep, missing_includes]
)
endif
## pyllco
pyllco_dep = dependency('pyllco-py' + py3_inst.language_version(), required : false)
if pyllco_dep.found()
pyllco_used_from_subproj = false
pyllco_cython_inc = pyllco_dep.get_variable(pkgconfig: 'Cython.include')
pyllco_dir = ''
else
pyllco_used_from_subproj = true
pyllco_proj = subproject('pyllco')
pyllco_dep = pyllco_proj.get_variable('pyllco_dep')
pyllco_cython_inc = pyllco_proj.get_variable('pyllco_cython_inc')
pyllco_dir = pyllco_proj.get_variable('pyllco_dir')
endif
## svf
cmake = import('cmake')
svf_opts = cmake.subproject_options()
svf_opts.append_compile_args('cpp', '-Wno-unused-parameter')
svf_opts.append_compile_args('cpp', '-Wno-unused-variable')
svf_opts.append_compile_args('cpp', '-Wno-unused-function')
svf_opts.append_compile_args('cpp', '-Wno-maybe-uninitialized')
svf_opts.append_compile_args('cpp', '-Wno-ignored-qualifiers')
svf_opts.append_compile_args('cpp', '-Wno-system-headers')
svf_opts.append_compile_args('cpp', '-fexceptions')
svf_opts.add_cmake_defines({'LLVM_DIR': llvm_dep.get_variable(configtool: 'prefix'),
'BUILD_SHARED_LIBS': 'on'})
# Reduce verbosity
svf_opts.add_cmake_defines({'CMAKE_MESSAGE_LOG_LEVEL': 'ERROR',
'CMAKE_SUPPRESS_DEVELOPER_WARNINGS': 'ON', # this is not in cmake doku, but it works
'CMAKE_INSTALL_MESSAGE': 'NEVER',
})
svf_proj = cmake.subproject('svf', options: svf_opts)
svf_dep = svf_proj.dependency('Svf', include_type: 'system')
## sparsedata
sparsedata = subproject('sparsedata')
sparse_rle2 = sparsedata.get_variable('libsparserle2')
## ara-link
ara_link = toolchains.get_variable('ara_link')
## tools
nop = find_program('true')
st_flash = find_program('st-flash', required: false, disabler: true)
sed = find_program('sed')
# irx
if get_option('enable_irx')
irx = subproject('irx')
irx_dir = irx.get_variable('irx_dir')
irx_mod = irx.get_variable('irx_tgt')
else
irx_dir = ''
irx_mod=disabler()
endif
# all dependencies found, build the actual program
build_dir = meson.current_build_dir()
source_dir = meson.current_source_dir()
# tools for deploying
subdir('tools')
# build ARA itself
subdir('ara')
# Python optimization argument
python_opt_arg = ''
if get_option('python_optimization_level') == 1
python_opt_arg = ' -O'
elif get_option('python_optimization_level') == 2
python_opt_arg = ' -OO'
endif
# convenience script to call ara without installing
conv_wrapper = '''
"""Automatic Real-time System Analyzer"""
import importlib
import sys
import os
# see https://git.skewed.de/count0/graph-tool/-/issues/766
os.environ["OMP_WAIT_POLICY"] = "passive"
import graph_tool
def load(what, where):
module = importlib.import_module(what)
sys.modules[where] = module
sys.path = [@0@] + sys.path
sys.setdlopenflags(sys.getdlopenflags() | os.RTLD_GLOBAL)
import pyllco
@1@
load("graph_data", "ara.graph.graph_data")
load("py_logging", "ara.steps.py_logging")
load("step", "ara.steps.step")
sys.setdlopenflags(sys.getdlopenflags() & ~os.RTLD_GLOBAL)
'''
ara_py_content = '''#!@0@
@1@
from ara.ara import Main
main = Main()
sys.exit(main.main())
'''
python_dirs = [source_dir, pyllco_dir, step_dir, graph_data_dir, irx_dir]
python_path = 'PYTHONPATH=' + ':'.join(python_dirs)
conv_wrapper_formatted = conv_wrapper.format('"' + '", "'.join(python_dirs) + '"', '')
deps = [step_mod, graph_data_mod]
if get_option('enable_irx')
deps += [irx_mod]
deps += irx.get_variable('native_simulator_llvmir')
endif
ara_py = custom_target('ara-py',
input: [],
output: 'ara.py',
depends: deps,
command: [py3_inst, dump_cmds, '@OUTPUT@', '0o755', ara_py_content.format(py3_inst.full_path()+python_opt_arg, conv_wrapper_formatted)],
build_by_default: true
)
# ARA GUI
subdir('resources')
ara_gui_py_before_import = '''
from ara.visualization.util import RESOURCES, USING_ARA_GUI
RESOURCES.set_res_path(@0@)
USING_ARA_GUI.set(True)
'''
ara_gui_py_content = '''#!@0@
@1@
import ara.ara as _ara
import ara.visualization.main
sys.exit()
'''
ara_gui_py_before_import_formatted = ara_gui_py_before_import.format('"' + resources_dir + '"')
conv_wrapper_formatted = conv_wrapper.format('"' + '", "'.join(python_dirs) + '"', ara_gui_py_before_import_formatted)
ara_gui_py = custom_target('ara-gui-py',
input: [],
output: 'ara-gui.py',
depends: [step_mod, graph_data_mod],
command: [py3_inst, dump_cmds, '@OUTPUT@', '0o755', ara_gui_py_content.format(py3_inst.full_path()+python_opt_arg, conv_wrapper_formatted)],
build_by_default: true
)
subdir('startup')
# build test applications with help of ARA
# Attention: The include order is important here.
subdir('settings')
subdir('libs') # build libs such as osek/freertos/stm32-init
subdir('appl')
subdir('test')
# application tests
# tests that aren't actually tests, but a way to store ara invocations with a given set of arguments
if get_option('build_toplevel_tests')
settings = 'settings'
app = autosar_singlecore_bcc1_task1_a
app = autosar_multicore_paper_running
test('ara_tester',
py3_inst,
args: [ara_py, app['ll'],
'--log-level', 'warn', '--runtime-stats', '--runtime-stats-file', 'dump', '--runtime-stats-format', 'json',
'--oilfile', app['oil'],
'--timings', app['sys_timings'],
'--step-settings', files(settings / 'extra_settings.json')],
# '--manual-corrections', instance_corrections],
suite: 'toplevel'
)
test('rtas20',
py3_inst,
args: [ara_py, freertos_rtas20_example,
'--log-level', 'debug', '--runtime-stats', '--runtime-stats-file', 'dump', '--runtime-stats-format', 'json',
'--dump',
'--step-settings', files(settings / 'rtas_settings.json')],
suite: 'toplevel'
)
test('generator_tester',
py3_inst,
args: [ara_py, freertos_simple_print,
'--log-level', 'debug', '--dump',
'--generator_output', 'generator_tester-os.cc',
'--step-settings', files(settings / 'generator_settings.json')],
suite: 'toplevel'
)
test('multisse',
py3_inst,
args: [ara_py, autosar_multicore_minexample['ll'],
'--oilfile', autosar_multicore_minexample['oil'],
'--dump',
'--log-level', 'info',
'--step-settings', files(settings / 'autosar_minexample_settings.json')],
suite: 'toplevel',
timeout: 30
)
test('cfg_pic',
py3_inst,
args: [ara_py, freertos_cfg_pic,
'--dump',
'--log-level', 'info',
'--step', 'SIA'],
suite: 'toplevel',
timeout: 30
)
test('cfg_pic',
py3_inst,
args: [ara_py, freertos_visualization_thesis_example,
'--dump',
'--log-level', 'info',
'--step', 'SIA'],
suite: 'toplevel',
timeout: 30
)
endif
arm_freertos_apps = []