Skip to content

Commit 44fb4d1

Browse files
authored
Merge pull request #659 from fdlamotte/use_as_lib
Use as lib
2 parents cb96503 + b88a360 commit 44fb4d1

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

build_as_lib.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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())

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)