forked from FastLED/FastLED
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathmeson.build
More file actions
203 lines (174 loc) · 6.62 KB
/
meson.build
File metadata and controls
203 lines (174 loc) · 6.62 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
project('fastled', 'cpp',
version: '6.0.0',
default_options: [
'cpp_std=gnu++17',
'warning_level=2',
'werror=false',
'buildtype=debug'
]
)
# Source directory
src_dir = include_directories('src')
tests_dir = include_directories('tests')
# Platform-specific stub include
stub_dir = include_directories('src/platforms/stub')
# FastLED library sources
fastled_sources = files(
'src/FastLED.cpp',
'src/bitswap.cpp',
'src/cled_controller.cpp',
'src/colorpalettes.cpp',
'src/crgb.cpp',
'src/hsv2rgb.cpp',
'src/lib8tion.cpp',
'src/noise.cpp',
'src/platforms.cpp',
'src/power_mgt.cpp',
'src/simplex.cpp',
'src/transpose8x1_noinline.cpp',
'src/wiring.cpp',
'src/fastled_delay.cpp'
)
# Collect all .cpp files recursively from src directory
# This mimics what the Python build system does
fs = import('fs')
# Find additional sources in subdirectories
lib8tion_sources = run_command('python', '-c',
'import pathlib; print("\\n".join(str(p) for p in pathlib.Path("src/lib8tion").glob("*.cpp")))',
check: false, capture: true)
stub_sources = run_command('python', '-c',
'import pathlib; print("\\n".join(str(p) for p in pathlib.Path("src/platforms/stub").glob("*.cpp") if p.name != "stub_main.cpp"))',
check: false, capture: true)
fl_sources = run_command('python', '-c',
'import pathlib; print("\\n".join(str(p) for p in pathlib.Path("src/fl").glob("*.cpp")))',
check: false, capture: true)
shared_sources = run_command('python', '-c',
'import pathlib; print("\\n".join(str(p) for p in pathlib.Path("src/platforms/shared").rglob("*.cpp")))',
check: false, capture: true)
third_party_sources = run_command('python', '-c',
'import pathlib; print("\\n".join(str(p) for p in pathlib.Path("src/third_party").rglob("*.cpp")))',
check: false, capture: true)
codec_sources = run_command('python', '-c',
'import pathlib; print("\\n".join(str(p) for p in pathlib.Path("src/fl/codec").glob("*.cpp")))',
check: false, capture: true)
fx_sources = run_command('python', '-c',
'import pathlib; print("\\n".join(str(p) for p in pathlib.Path("src/fx").rglob("*.cpp")))',
check: false, capture: true)
sensors_sources = run_command('python', '-c',
'import pathlib; print("\\n".join(str(p) for p in pathlib.Path("src/sensors").glob("*.cpp")))',
check: false, capture: true)
# Add found sources if any
if lib8tion_sources.returncode() == 0 and lib8tion_sources.stdout().strip() != ''
fastled_sources += files(lib8tion_sources.stdout().strip().split('\n'))
endif
if stub_sources.returncode() == 0 and stub_sources.stdout().strip() != ''
fastled_sources += files(stub_sources.stdout().strip().split('\n'))
endif
if fl_sources.returncode() == 0 and fl_sources.stdout().strip() != ''
fastled_sources += files(fl_sources.stdout().strip().split('\n'))
endif
if shared_sources.returncode() == 0 and shared_sources.stdout().strip() != ''
fastled_sources += files(shared_sources.stdout().strip().split('\n'))
endif
if third_party_sources.returncode() == 0 and third_party_sources.stdout().strip() != ''
fastled_sources += files(third_party_sources.stdout().strip().split('\n'))
endif
if codec_sources.returncode() == 0 and codec_sources.stdout().strip() != ''
fastled_sources += files(codec_sources.stdout().strip().split('\n'))
endif
if fx_sources.returncode() == 0 and fx_sources.stdout().strip() != ''
fastled_sources += files(fx_sources.stdout().strip().split('\n'))
endif
if sensors_sources.returncode() == 0 and sensors_sources.stdout().strip() != ''
fastled_sources += files(sensors_sources.stdout().strip().split('\n'))
endif
# Compile flags for unit tests (base flags)
unit_test_compile_args = [
'-DFASTLED_UNIT_TEST=1',
'-DFASTLED_USE_PROGMEM=0',
'-DSTUB_PLATFORM',
'-DARDUINO=10808',
'-DFASTLED_USE_STUB_ARDUINO',
'-DSKETCH_HAS_LOTS_OF_MEMORY=1',
'-DFASTLED_STUB_IMPL',
'-DFASTLED_USE_JSON_UI=1',
'-DFASTLED_TESTING',
'-DFASTLED_NO_AUTO_NAMESPACE',
'-DFASTLED_NO_PINMAP',
'-DHAS_HARDWARE_PIN_SUPPORT',
'-DFASTLED_DEBUG_LEVEL=1',
'-DFASTLED_NO_ATEXIT=1',
'-DDOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS',
'-DENABLE_CRASH_HANDLER',
'-DRELEASE=1',
'-DFASTLED_FORCE_NAMESPACE=1',
'-fpermissive',
'-Wall',
'-Wextra',
'-Wno-deprecated-register',
'-Wno-backslash-newline-escape',
'-Wno-narrowing',
'-fno-exceptions',
'-fno-rtti',
'-fno-omit-frame-pointer',
'-fno-strict-aliasing',
'-Werror=unused-variable',
'-O0',
'-g'
]
# Windows-specific compiler flags (matches ci/build_unit.toml [windows] section)
if build_machine.system() == 'windows'
cpp_compiler = meson.get_compiler('cpp')
# Add common Windows defines for all compilers
unit_test_compile_args += [
'-DNOMINMAX', # Prevent Windows min/max macros
'-DWIN32_LEAN_AND_MEAN', # Reduce Windows header conflicts
]
# Clang/Zig-specific flags
if cpp_compiler.get_id() in ['clang', 'clang-cl']
unit_test_compile_args += [
'--target=x86_64-windows-gnu', # Explicit GNU target for MSYS2/MinGW compatibility
'-fuse-ld=lld-link', # Use lld-link (MSVC-compatible linker)
]
endif
endif
# Link arguments
unit_test_link_args = []
if build_machine.system() == 'windows'
cpp_compiler = meson.get_compiler('cpp')
# Clang/Zig-specific linker flags (matches ci/build_unit.toml [windows] link_flags + [test] link_flags)
if cpp_compiler.get_id() in ['clang', 'clang-cl']
unit_test_link_args = [
'-mconsole', # Console application
'-nodefaultlibs', # Don't automatically include default libraries
'-unwindlib=libunwind', # Use Clang's libunwind (avoid MinGW unwind)
'-nostdlib++', # Don't auto-link standard C++ library
'-lc++', # Manually link libc++ (Clang's C++ standard library)
'-lkernel32', # Windows kernel functions
'-luser32', # Windows user interface
'-lgdi32', # Graphics device interface
'-ladvapi32', # Advanced Windows API
'-ldbghelp', # Debug helper (for stack traces)
'-lpsapi', # Process status API
]
else
# GCC/MinGW linker flags
unit_test_link_args = [
'-ldbghelp', # Debug helper (for stack traces)
'-lpsapi', # Process status API
]
endif
else
unit_test_link_args = ['-pthread']
endif
# Build FastLED static library for tests
fastled_lib = static_library('fastled',
fastled_sources,
include_directories: [src_dir, stub_dir],
cpp_args: unit_test_compile_args,
install: false
)
# Build tests subdirectory
subdir('tests')
# Build examples subdirectory (provides meson targets for example compilation)
subdir('examples')