MeshCore/build_as_lib.py

65 lines
2.2 KiB
Python
Raw Normal View History

2025-08-24 13:09:55 +02:00
from os.path import realpath
2025-08-24 13:09:55 +02:00
Import("env") # type: ignore
menv=env # type: ignore
2025-08-24 13:09:55 +02:00
src_filter = [
'+<*.cpp>',
'+<helpers/*.cpp>',
2025-08-25 12:11:39 +02:00
'+<helpers/sensors>',
2025-08-24 13:09:55 +02:00
'+<helpers/radiolib/*.cpp>',
'+<helpers/ui/MomentaryButton.cpp>',
'+<helpers/ui/buzzer.cpp>',
2025-08-24 13:09:55 +02:00
]
2025-08-24 14:47:03 +02:00
# add build and include dirs according to CPPDEFINES
2025-08-24 13:09:55 +02:00
for item in menv.get("CPPDEFINES", []):
2025-08-24 14:47:03 +02:00
# PLATFORM HANDLING
if item == "STM32_PLATFORM":
2025-08-24 13:09:55 +02:00
src_filter.append("+<helpers/stm32/*>")
elif item == "ESP32":
2025-08-24 13:09:55 +02:00
src_filter.append("+<helpers/esp32/*>")
elif item == "NRF52_PLATFORM":
2025-08-24 14:47:03 +02:00
src_filter.append("+<helpers/nrf52/*>")
elif item == "RP2040_PLATFORM":
2025-08-24 14:47:03 +02:00
src_filter.append("+<helpers/rp2040/*>")
2025-08-25 12:11:39 +02:00
# DISPLAY HANDLING
elif isinstance(item, tuple) and item[0] == "DISPLAY_CLASS":
display_class = item[1]
src_filter.append(f"+<helpers/ui/{display_class}.cpp>")
if (display_class == "ST7789Display") :
src_filter.append(f"+<helpers/ui/OLEDDisplay.cpp>")
src_filter.append(f"+<helpers/ui/OLEDDisplayFonts.cpp>")
2025-08-24 14:47:03 +02:00
# VARIANTS HANDLING
2025-08-24 13:09:55 +02:00
elif isinstance(item, tuple) and item[0] == "MC_VARIANT":
variant_name = item[1]
src_filter.append(f"+<../variants/{variant_name}>")
# INCLUDE EXAMPLE CODE IN BUILD (to provide your own support files without touching the tree)
elif isinstance(item, tuple) and item[0] == "BUILD_EXAMPLE":
example_name = item[1]
src_filter.append(f"+<../examples/{example_name}/*.cpp>")
2025-08-25 18:34:50 +02:00
# EXCLUDE A SOURCE FILE FROM AN EXAMPLE (must be placed after example name or boom)
elif isinstance(item, tuple) and item[0] == "EXCLUDE_FROM_EXAMPLE":
exclude_name = item[1]
if example_name is None:
print("***** PLEASE DEFINE EXAMPLE FIRST *****")
break
2025-08-25 18:34:50 +02:00
src_filter.append(f"-<../examples/{example_name}/{exclude_name}>")
# DEAL WITH UI VARIANT FOR AN EXAMPLE
elif isinstance(item, tuple) and item[0] == "MC_UI_FLAVOR":
ui_flavor = item[1]
if example_name is None:
print("***** PLEASE DEFINE EXAMPLE FIRST *****")
break
src_filter.append(f"+<../examples/{example_name}/{ui_flavor}/*.cpp>")
2025-08-24 13:09:55 +02:00
menv.Replace(SRC_FILTER=src_filter)
2025-08-24 13:09:55 +02:00
#print (menv.Dump())