-
Notifications
You must be signed in to change notification settings - Fork 11
/
meson.build
163 lines (137 loc) · 4.55 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
project('Arduino SDK Logger',
['c', 'cpp'],
default_options : [
'buildtype=minsize',
'b_lto=true',
'b_staticpic=false',
# `build.*` options affect `native: true targets`
# plain options affect `native: false` targets.
'cpp_std=gnu++11', 'build.cpp_std=gnu++11'
],
license: 'MIT',
meson_version: '>0.54.0',
version: '1.0'
)
# TODO: These sketches are currently not built, they're targeted for Teensy (ARM)
# CircularLogBuffer
# CircularLogBuffer_CompileTimeFiltering
# CircularLogBuffer_GlobalInst
# CircularLogBuffer_LocalInst
# SDFileLogger_Teensy.cpp
# TeensySDLogger.cpp
# TeensySDRotationalLogger.cpp
########################
# Identify Compiler(s) #
########################
subdir('meson/compiler')
subdir('meson/compiler/c')
subdir('meson/compiler/cpp')
if get_option('enable-werror') == true
desired_common_compile_flags += '-Werror'
endif
if get_option('enable-pedantic-error') == true
desired_common_compile_flags += '-pedantic-error'
endif
compile_settings_list = [
{'lang': 'cpp', 'compiler': host_cpp_compiler, 'flags': desired_cpp_compile_flags, 'isnative': false},
{'lang': 'cpp', 'compiler': native_cpp_compiler, 'flags': desired_native_cpp_compile_flags, 'isnative': true},
]
# Process the compilation flags
subdir('meson/compiler/check-and-apply-flags')
arduinoprintf = subproject('arduino-printf')
libPrintf_test_dep = arduinoprintf.get_variable('libPrintf_test_dep')
#######################
# Process source tree #
#######################
if meson.is_cross_build()
if host_machine.cpu_family() != 'avr'
error('Cross builds for this library are only enabled for AVR targets')
endif
# This library uses `static`, which is not defined for avr-libc
add_project_arguments('-fno-threadsafe-statics', language: 'cpp', native: false)
libPrintf_dep = arduinoprintf.get_variable('libPrintf_dep')
arduinocore = subproject('arduinocore-avr')
arduinocore_dep = arduinocore.get_variable('arduinocore_dep')
arduinocore_main_dep = arduinocore.get_variable('arduinocore_main_dep')
arduinocore_eeprom_dep = arduinocore.get_variable('arduinocore_eeprom_dep')
arduinoprintf = subproject('arduino-printf')
libPrintf_dep = arduinoprintf.get_variable('libPrintf_dep')
logger_includes = include_directories('src')
LibArduinoLogger = static_library('ArduinoLogger',
'src/ArduinoLogger.cpp',
include_directories: logger_includes,
dependencies: [
arduinocore_dep,
libPrintf_dep,
],
build_by_default: meson.is_subproject() == false,
)
libArduinoLogger_dep = declare_dependency(
include_directories: logger_includes,
link_with: LibArduinoLogger,
dependencies: libPrintf_dep,
)
if meson.is_subproject() == false
executable('AVRCircularLogBuffer',
files('test/sketch/AVRCircularLogBuffer.cpp', 'test/sketch/Adafruit_SleepyDog.cpp'),
include_directories: include_directories('test', 'test/sketch', is_system: true),
dependencies: [
libArduinoLogger_dep,
arduinocore_main_dep,
],
install: false,
build_by_default: meson.is_subproject() == false,
)
executable('AVRSDRotationalLogger-donotuse',
files('test/sketch/AVRSDRotationalLogger.cpp', 'test/sketch/Adafruit_SleepyDog.cpp'),
include_directories: include_directories('test', 'test/sketch', is_system: true),
dependencies: [
libArduinoLogger_dep,
arduinocore_main_dep,
arduinocore_eeprom_dep
],
install: false,
build_by_default: meson.is_subproject() == false,
)
endif
endif
# Add files to this variable if you want them analyzed by clang-tidy
clangtidy_files = [
files('src/ArduinoLogger.cpp')
]
################
# Test Targets #
################
logging_tests = executable('arduino_logger_tests',
[
files('src/ArduinoLogger.cpp'),
files('test/CircularBufferLoggerTests.cpp'),
# Currently disabled due to use of AVR header
#files('test/AVRCircularBufferLoggerTests.cpp'),
files('test/catch_main.cpp'),
files('test/test_helper.cpp'),
files('test/CoreLoggerTests.cpp'),
],
include_directories: include_directories('test', 'test/catch', 'src'),
dependencies: libPrintf_test_dep,
native: true,
build_by_default: meson.is_subproject() == false,
)
if meson.is_subproject() == false
test('ArduinoLogger_tests',
logging_tests)
endif
############################
# Supporting Build Targets #
############################
clangformat_excludes = [
meson.project_source_root() / 'test/catch',
meson.project_source_root() / 'test/sketch',
]
cppcheck_paths = [
meson.project_source_root() / 'src'
]
subdir('meson/analysis/clang-tidy')
subdir('meson/analysis/complexity')
subdir('meson/analysis/cppcheck')
subdir('meson/format')