Skip to content

Commit 2890a8c

Browse files
committed
Refactor platformio.ini to use dependency variables and add fs_data_filter script for managing filesystem data
1 parent 9d4dc1d commit 2890a8c

2 files changed

Lines changed: 68 additions & 12 deletions

File tree

esp_firmware/platformio.ini

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,23 @@ build_flags =
2727
board_build.partitions = partitions/esp32c3_4mb_ota_spiffs.csv
2828
extra_scripts =
2929
pre:scripts/esp32_compat_patches.py
30+
pre:scripts/fs_data_filter.py
3031
post:scripts/esp32_compat_patches.py
3132

3233
; Dependency resolution
3334
lib_ldf_mode = deep
3435
lib_compat_mode = soft
3536

36-
; Libraries (pinned)
37-
lib_deps =
38-
ESP32Async/AsyncTCP@=3.4.10
39-
ESP32Async/ESPAsyncWebServer@=3.10.3
40-
adafruit/Adafruit NeoPixel@=1.15.4
41-
ayushsharma82/ElegantOTA@=3.1.7
42-
ayushsharma82/NetWizard@=1.2.2
43-
bblanchon/ArduinoJson@=7.4.3
44-
https://github.com/micro-ROS/micro_ros_platformio.git#cfee17faffaa532363b7151dd13af6a85c69d3c1
45-
4637
; Upload / Monitor
4738
upload_port = /dev/ttyACM0
4839
monitor_port = /dev/ttyACM0
4940
monitor_speed = 115200
5041

42+
; Libraries
43+
lib_deps =
44+
${deps.base}
45+
${deps.mros}
46+
5147
[env:seeed_xiao_esp32c3_prod]
5248
extends = env:seeed_xiao_esp32c3
5349
build_flags =
@@ -58,6 +54,18 @@ build_flags =
5854
extends = env:seeed_xiao_esp32c3
5955
build_flags =
6056
${env:seeed_xiao_esp32c3.build_flags}
57+
-D BUILD_PROFILE=PROFILE_PROD
6158
-D APP_MODE=APP_MODE_ESTOP
62-
lib_ignore =
63-
micro_ros_platformio
59+
lib_deps =
60+
${deps.base}
61+
62+
[deps]
63+
base =
64+
ESP32Async/AsyncTCP@=3.4.10
65+
ESP32Async/ESPAsyncWebServer@=3.10.3
66+
adafruit/Adafruit NeoPixel@=1.15.4
67+
ayushsharma82/ElegantOTA@=3.1.7
68+
ayushsharma82/NetWizard@=1.2.2
69+
bblanchon/ArduinoJson@=7.4.3
70+
mros =
71+
https://github.com/micro-ROS/micro_ros_platformio.git#cfee17faffaa532363b7151dd13af6a85c69d3c1
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Import("env")
2+
3+
import shutil
4+
from pathlib import Path
5+
from SCons.Script import COMMAND_LINE_TARGETS
6+
7+
FS_TARGETS = {"buildfs", "uploadfs", "uploadfsota"}
8+
if FS_TARGETS.isdisjoint(set(COMMAND_LINE_TARGETS)):
9+
# Only filter data files when building/uploading filesystem images.
10+
pass
11+
else:
12+
ENV_EXCLUDES = {
13+
"seeed_xiao_esp32c3_prod": {
14+
"estop.html",
15+
"estop.js",
16+
},
17+
"seeed_xiao_esp32c3_estop": {
18+
"index.html",
19+
"script.js",
20+
"settings.html",
21+
"settings.js",
22+
},
23+
}
24+
25+
pioenv = env.get("PIOENV", "")
26+
excluded = ENV_EXCLUDES.get(pioenv)
27+
if not excluded:
28+
pass
29+
else:
30+
project_data_dir = Path(env.subst("$PROJECT_DIR")) / "data"
31+
if not project_data_dir.exists():
32+
pass
33+
else:
34+
staging_dir = Path(env.subst("$BUILD_DIR")) / "data_filtered"
35+
if staging_dir.exists():
36+
shutil.rmtree(staging_dir)
37+
staging_dir.parent.mkdir(parents=True, exist_ok=True)
38+
shutil.copytree(project_data_dir, staging_dir)
39+
40+
for rel in excluded:
41+
target = staging_dir / rel
42+
if target.is_file() or target.is_symlink():
43+
target.unlink()
44+
elif target.is_dir():
45+
shutil.rmtree(target, ignore_errors=True)
46+
47+
env.Replace(PROJECT_DATA_DIR=staging_dir.as_posix())
48+
print("Using filtered data dir for {}: {}".format(pioenv, staging_dir))

0 commit comments

Comments
 (0)