|
1 | | -from os.path import join, realpath, exists |
2 | | -import shutil, os |
| 1 | +from os.path import realpath |
3 | 2 |
|
4 | | -Import("env") |
| 3 | +Import("env") # type: ignore |
| 4 | +menv=env # type: ignore |
5 | 5 |
|
6 | | -platform_stm32=False |
7 | | -platform_esp32=False |
8 | | -platform_nrf52=False |
9 | | -platform_rp2040=False |
| 6 | +src_filter = [ |
| 7 | + '+<*.cpp>', |
| 8 | + '+<helpers/*.cpp>', |
| 9 | + '+<helpers/radiolib/*.cpp>', |
| 10 | + '+<helpers/ui/MomentaryButton.cpp>', |
| 11 | +] |
10 | 12 |
|
11 | | -src_filter = [] |
12 | | -src_filter.append("+<*>") |
13 | | -src_filter.append("-<helpers/ui/*>") # don't build with ui for now ... |
14 | | - |
15 | | -for item in env.get("CPPDEFINES", []): |
| 13 | +for item in menv.get("CPPDEFINES", []): |
16 | 14 | if isinstance(item, str) and item == "STM32_PLATFORM": |
17 | 15 | # add STM32 specific sources |
18 | | - env.Append(CPPPATH=[realpath("src/helpers/stm32")]) |
19 | | - platform_stm32=True |
20 | | - env.Append(BUILD_FLAGS=["-I src/helpers/stm32"]) |
| 16 | + menv.Append(CPPPATH=[realpath("src/helpers/stm32")]) |
| 17 | + menv.Append(BUILD_FLAGS=["-I src/helpers/stm32"]) |
| 18 | + src_filter.append("+<helpers/stm32/*>") |
21 | 19 | elif isinstance(item, str) and item == "ESP32": |
22 | | - platform_esp32=True |
23 | | - env.Append(CPPPATH=[realpath("src/helpers/esp32")]) |
24 | | - env.Append(BUILD_FLAGS=["-I src/helpers/esp32"]) |
25 | | - elif isinstance(item, str) and item == "WIO_E5_DEV_VARIANT": |
26 | | - env.Append(BUILD_FLAGS=["-I variants/wio-e5-dev"]) |
27 | | - src_filter.append("+<../variants/wio-e5-dev>") |
28 | | - elif isinstance(item, str) and item == "RAK_3X72_VARIANT": |
29 | | - env.Append(BUILD_FLAGS=["-I variants/rak3x72"]) |
30 | | - src_filter.append("+<../variants/rak3x72>") |
31 | | - elif isinstance(item, str) and item == "XIAO_S3_WIO_VARIANT": |
32 | | - env.Append(BUILD_FLAGS=["-I variants/xiao_s3_wio"]) |
33 | | - src_filter.append("+<../variants/xiao_s3_wio>") |
34 | | - elif isinstance(item, str) and item == "XIAO_C6_VARIANT": |
35 | | - env.Append(BUILD_FLAGS=["-I variants/xiao_c6"]) |
36 | | - src_filter.append("+<../variants/xiao_c6>") |
37 | | - elif isinstance(item, str) and item == "GENERIC_ESPNOW_VARIANT": |
38 | | - env.Append(BUILD_FLAGS=["-I variants/generic_espnow"]) |
39 | | - src_filter.append("+<../variants/generic_espnow>") |
40 | | - src_filter.append("+<helpers/esp32/ESPNOWRadio.cpp>") |
41 | | - |
42 | | -if not platform_stm32: |
43 | | - src_filter.append("-<helpers/stm32/*>") |
44 | | -if not platform_esp32: |
45 | | - src_filter.append("-<helpers/esp32/*>") |
46 | | -if not platform_nrf52: |
47 | | - src_filter.append("-<helpers/nrf52/*>") |
48 | | -if not platform_rp2040: |
49 | | - src_filter.append("-<helpers/rp2040/*>") |
| 20 | + menv.Append(CPPPATH=[realpath("src/helpers/esp32")]) |
| 21 | + menv.Append(BUILD_FLAGS=["-I src/helpers/esp32"]) |
| 22 | + src_filter.append("+<helpers/esp32/*>") |
| 23 | + elif isinstance(item, tuple) and item[0] == "MC_VARIANT": |
| 24 | + variant_name = item[1] |
| 25 | + menv.Append(BUILD_FLAGS=[f"-I variants/{variant_name}"]) |
| 26 | + src_filter.append(f"+<../variants/{variant_name}>") |
50 | 27 |
|
51 | | -env.Replace(SRC_FILTER=src_filter) |
| 28 | +menv.Replace(SRC_FILTER=src_filter) |
52 | 29 |
|
53 | | -print (env.Dump()) |
| 30 | +#print (menv.Dump()) |
0 commit comments