diff --git a/build_as_lib.py b/build_as_lib.py new file mode 100644 index 00000000..da4337c0 --- /dev/null +++ b/build_as_lib.py @@ -0,0 +1,49 @@ +from os.path import realpath + +Import("env") # type: ignore +menv=env # type: ignore + +src_filter = [ + '+<*.cpp>', + '+', + '+' + '+', + '+', +] + +# add build and include dirs according to CPPDEFINES +for item in menv.get("CPPDEFINES", []): + + # STM32 + if isinstance(item, str) and item == "STM32_PLATFORM": + menv.Append(CPPPATH=[realpath("src/helpers/stm32")]) + menv.Append(BUILD_FLAGS=["-I src/helpers/stm32"]) + src_filter.append("+") + + # ESP32 + elif isinstance(item, str) and item == "ESP32": + menv.Append(CPPPATH=[realpath("src/helpers/esp32")]) + menv.Append(BUILD_FLAGS=["-I src/helpers/esp32"]) + src_filter.append("+") + + # NRF52 + elif isinstance(item, str) and item == "NRF52_PLATFORM": + menv.Append(CPPPATH=[realpath("src/helpers/nrf52")]) + menv.Append(BUILD_FLAGS=["-I src/helpers/nrf52"]) + src_filter.append("+") + + # RP2040 + elif isinstance(item, str) and item == "RP2040_PLATFORM": + menv.Append(CPPPATH=[realpath("src/helpers/rp2040")]) + menv.Append(BUILD_FLAGS=["-I src/helpers/rp2040"]) + src_filter.append("+") + + # VARIANTS HANDLING + elif isinstance(item, tuple) and item[0] == "MC_VARIANT": + variant_name = item[1] + menv.Append(BUILD_FLAGS=[f"-I variants/{variant_name}"]) + src_filter.append(f"+<../variants/{variant_name}>") + +menv.Replace(SRC_FILTER=src_filter) + +#print (menv.Dump()) diff --git a/library.json b/library.json new file mode 100644 index 00000000..982983a3 --- /dev/null +++ b/library.json @@ -0,0 +1,16 @@ +{ + "name": "MeshCore", + "version" : "1.7.4", + "dependencies": { + "SPI": "*", + "Wire": "*", + "jgromes/RadioLib": "^7.1.2", + "rweather/Crypto": "^0.4.0", + "adafruit/RTClib": "^2.1.3", + "melopero/Melopero RV3028": "^1.1.0", + "electroniccats/CayenneLPP": "1.4.0" + }, + "build": { + "extraScript": "build_as_lib.py" + } +} \ No newline at end of file