|
| 1 | +from os.path import realpath |
| 2 | + |
| 3 | +Import("env") # type: ignore |
| 4 | +menv=env # type: ignore |
| 5 | + |
| 6 | +src_filter = [ |
| 7 | + '+<*.cpp>', |
| 8 | + '+<helpers/*.cpp>', |
| 9 | + '+<helpers/sensors>' |
| 10 | + '+<helpers/radiolib/*.cpp>', |
| 11 | + '+<helpers/ui/MomentaryButton.cpp>', |
| 12 | +] |
| 13 | + |
| 14 | +# add build and include dirs according to CPPDEFINES |
| 15 | +for item in menv.get("CPPDEFINES", []): |
| 16 | + |
| 17 | + # STM32 |
| 18 | + if isinstance(item, str) and item == "STM32_PLATFORM": |
| 19 | + menv.Append(CPPPATH=[realpath("src/helpers/stm32")]) |
| 20 | + menv.Append(BUILD_FLAGS=["-I src/helpers/stm32"]) |
| 21 | + src_filter.append("+<helpers/stm32/*>") |
| 22 | + |
| 23 | + # ESP32 |
| 24 | + elif isinstance(item, str) and item == "ESP32": |
| 25 | + menv.Append(CPPPATH=[realpath("src/helpers/esp32")]) |
| 26 | + menv.Append(BUILD_FLAGS=["-I src/helpers/esp32"]) |
| 27 | + src_filter.append("+<helpers/esp32/*>") |
| 28 | + |
| 29 | + # NRF52 |
| 30 | + elif isinstance(item, str) and item == "NRF52_PLATFORM": |
| 31 | + menv.Append(CPPPATH=[realpath("src/helpers/nrf52")]) |
| 32 | + menv.Append(BUILD_FLAGS=["-I src/helpers/nrf52"]) |
| 33 | + src_filter.append("+<helpers/nrf52/*>") |
| 34 | + |
| 35 | + # RP2040 |
| 36 | + elif isinstance(item, str) and item == "RP2040_PLATFORM": |
| 37 | + menv.Append(CPPPATH=[realpath("src/helpers/rp2040")]) |
| 38 | + menv.Append(BUILD_FLAGS=["-I src/helpers/rp2040"]) |
| 39 | + src_filter.append("+<helpers/rp2040/*>") |
| 40 | + |
| 41 | + # VARIANTS HANDLING |
| 42 | + elif isinstance(item, tuple) and item[0] == "MC_VARIANT": |
| 43 | + variant_name = item[1] |
| 44 | + menv.Append(BUILD_FLAGS=[f"-I variants/{variant_name}"]) |
| 45 | + src_filter.append(f"+<../variants/{variant_name}>") |
| 46 | + |
| 47 | +menv.Replace(SRC_FILTER=src_filter) |
| 48 | + |
| 49 | +#print (menv.Dump()) |
0 commit comments