Skip to content

Commit 685f752

Browse files
committed
let users compile their projects against meshcore as a lib
1 parent cb96503 commit 685f752

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

build_as_lib.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from os.path import join, realpath, exists
2+
import shutil, os
3+
4+
Import("env")
5+
6+
platform_stm32=False
7+
platform_esp32=False
8+
platform_nrf52=False
9+
platform_rp2040=False
10+
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", []):
16+
if isinstance(item, str) and item == "STM32_PLATFORM":
17+
# 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"])
21+
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/*>")
50+
51+
env.Replace(SRC_FILTER=src_filter)
52+
53+
print (env.Dump())

library.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "MeshCore",
3+
"version" : "1.7.4",
4+
"dependencies": {
5+
"SPI": "*",
6+
"Wire": "*",
7+
"jgromes/RadioLib": "^7.1.2",
8+
"rweather/Crypto": "^0.4.0",
9+
"adafruit/RTClib": "^2.1.3",
10+
"melopero/Melopero RV3028": "^1.1.0",
11+
"electroniccats/CayenneLPP": "1.4.0"
12+
},
13+
"build": {
14+
"extraScript": "build_as_lib.py"
15+
}
16+
}

0 commit comments

Comments
 (0)