-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert usermods to static libraries #4480
base: main
Are you sure you want to change the base?
Changes from 3 commits
b8685f2
4d5e0ca
71b0e8e
90b1815
a5575bc
6e76a72
67022be
cbed841
c16d83f
d64cedd
2381e32
79bac91
d3eec72
3521732
52b784e
52bee88
075fd4d
4c19341
8527d23
cc9e9b1
f2626b0
24accf9
b380d5e
2c9c413
1dbd706
e471487
869e275
0b8721c
270d75a
8fd9052
30559cd
32607ee
ef2eb07
2adf745
5da380e
59a79a3
0afd2fe
5d05d79
8487dd7
15edfcd
193926c
2b07be1
44a1a1e
48372bc
0233dae
30a697e
1d558e8
0d44e7e
86f9761
5d392d8
4bc3408
a5b972d
51db63d
851e9ec
070b08a
b3f9983
7a40ef7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Import('env') | ||
import os | ||
|
||
def find_usermod(mod_dir: str, mod: str): | ||
"""Locate this library in the usermods folder. | ||
We do this to avoid needing to rename a bunch of folders; | ||
this could be removed later | ||
""" | ||
# Check name match | ||
mp = f"{mod_dir}/{mod}" | ||
if os.path.exists(mp): | ||
return mp | ||
mp = f"{mod_dir}/usermod_v2_{mod}" | ||
if os.path.exists(mp): | ||
return mp | ||
raise RuntimeError(f"Couldn't locate module {mod} in usermods directory!") | ||
|
||
usermods = env.GetProjectOption("custom_usermods","") | ||
if usermods: | ||
proj = env.GetProjectConfig() | ||
deps = env.GetProjectOption('lib_deps') | ||
src_dir = proj.get("platformio", "src_dir") | ||
src_dir = src_dir.replace('\\','/') | ||
mod_paths = {mod: find_usermod(f"{src_dir}/../usermods", mod) for mod in usermods.split(" ")} | ||
usermods = [f"{mod} = symlink://{path}" for mod, path in mod_paths.items()] | ||
proj.set("env:" + env['PIOENV'], 'lib_deps', deps + usermods) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,6 +114,7 @@ extra_scripts = | |
post:pio-scripts/output_bins.py | ||
post:pio-scripts/strip-floats.py | ||
pre:pio-scripts/user_config_copy.py | ||
pre:pio-scripts/load_usermods.py | ||
pre:pio-scripts/build_ui.py | ||
; post:pio-scripts/obj-dump.py ;; convenience script to create a disassembly dump of the firmware (hardcore debugging) | ||
|
||
|
@@ -165,13 +166,8 @@ lib_deps = | |
; https://github.com/adafruit/Adafruit_MAX1704X @ 1.0.2 | ||
#For MPU6050 IMU uncomment follwoing | ||
;electroniccats/MPU6050 @1.0.1 | ||
# For -D USERMOD_ANIMARTRIX | ||
# CC BY-NC 3.0 licensed effects by Stefan Petrick, include this usermod only if you accept the terms! | ||
;https://github.com/netmindz/animartrix.git#18bf17389e57c69f11bc8d04ebe1d215422c7fb7 | ||
# SHT85 | ||
;robtillaart/SHT85@~0.3.3 | ||
# Audioreactive usermod | ||
;kosme/arduinoFFT @ 2.0.1 | ||
|
||
extra_scripts = ${scripts_defaults.extra_scripts} | ||
|
||
|
@@ -261,11 +257,11 @@ lib_deps = | |
https://github.com/lorol/LITTLEFS.git | ||
https://github.com/pbolduc/AsyncTCP.git @ 1.2.0 | ||
${env.lib_deps} | ||
# additional build flags for audioreactive | ||
AR_build_flags = -D USERMOD_AUDIOREACTIVE | ||
-D sqrt_internal=sqrtf ;; -fsingle-precision-constant ;; forces ArduinoFFT to use float math (2x faster) | ||
AR_lib_deps = kosme/arduinoFFT @ 2.0.1 | ||
board_build.partitions = ${esp32.default_partitions} ;; default partioning for 4MB Flash - can be overridden in build envs | ||
# additional build flags for audioreactive - must be applied globally | ||
AR_build_flags = -D sqrt_internal=sqrtf ;; -fsingle-precision-constant ;; forces ArduinoFFT to use float math (2x faster) | ||
AR_lib_deps = kosme/arduinoFFT @ 2.0.1 ;; for pre-usermod-library platformio_override compatibility | ||
|
||
|
||
[esp32_idf_V4] | ||
;; experimental build environment for ESP32 using ESP-IDF 4.4.x / arduino-esp32 v2.0.5 | ||
|
@@ -424,23 +420,23 @@ build_flags = ${common.build_flags} ${esp8266.build_flags} -D WLED_RELEASE_NAME= | |
board = esp32dev | ||
platform = ${esp32.platform} | ||
platform_packages = ${esp32.platform_packages} | ||
custom_usermods = audioreactive | ||
build_unflags = ${common.build_unflags} | ||
build_flags = ${common.build_flags} ${esp32.build_flags} -D WLED_RELEASE_NAME=\"ESP32\" #-D WLED_DISABLE_BROWNOUT_DET | ||
${esp32.AR_build_flags} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any way to move the build_flags used for the usermod into it's library.json? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In most cases, yes. In the specific case of AR, the build flags aren't actually for the AR module, they're for the FFT library dependency. Unfortunately, the only way to affect some dependent library's build is to do it at the project level. PlaformIO doesn't let one library define flags for one of its dependencies. https://community.platformio.org/t/setting-flags-defines-for-building-a-librarys-dependency/36744 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, maybe there is a way, using platformio hook scripts in the library. Working on it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are certainly usermods that use more typical build_flags that affect the usermod itself, but perhaps these still need to stay in the main platformio.ini if they are actual optional flags the user chooses to set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed! It turns out there is a way though platformio hook scripts. 8527d23 |
||
lib_deps = ${esp32.lib_deps} | ||
${esp32.AR_lib_deps} | ||
monitor_filters = esp32_exception_decoder | ||
board_build.partitions = ${esp32.default_partitions} | ||
|
||
[env:esp32dev_8M] | ||
board = esp32dev | ||
platform = ${esp32_idf_V4.platform} | ||
platform_packages = ${esp32_idf_V4.platform_packages} | ||
custom_usermods = audioreactive | ||
build_unflags = ${common.build_unflags} | ||
build_flags = ${common.build_flags} ${esp32_idf_V4.build_flags} -D WLED_RELEASE_NAME=\"ESP32_8M\" #-D WLED_DISABLE_BROWNOUT_DET | ||
${esp32.AR_build_flags} | ||
lib_deps = ${esp32_idf_V4.lib_deps} | ||
${esp32.AR_lib_deps} | ||
monitor_filters = esp32_exception_decoder | ||
board_build.partitions = ${esp32.large_partitions} | ||
board_upload.flash_size = 8MB | ||
|
@@ -452,11 +448,11 @@ board_upload.maximum_size = 8388608 | |
board = esp32dev | ||
platform = ${esp32_idf_V4.platform} | ||
platform_packages = ${esp32_idf_V4.platform_packages} | ||
custom_usermods = audioreactive | ||
build_unflags = ${common.build_unflags} | ||
build_flags = ${common.build_flags} ${esp32_idf_V4.build_flags} -D WLED_RELEASE_NAME=\"ESP32_16M\" #-D WLED_DISABLE_BROWNOUT_DET | ||
${esp32.AR_build_flags} | ||
lib_deps = ${esp32_idf_V4.lib_deps} | ||
${esp32.AR_lib_deps} | ||
monitor_filters = esp32_exception_decoder | ||
board_build.partitions = ${esp32.extreme_partitions} | ||
board_upload.flash_size = 16MB | ||
|
@@ -468,11 +464,11 @@ board_build.flash_mode = dio | |
;board = esp32dev | ||
;platform = ${esp32.platform} | ||
;platform_packages = ${esp32.platform_packages} | ||
;custom_usermods = audioreactive | ||
;build_unflags = ${common.build_unflags} | ||
;build_flags = ${common.build_flags} ${esp32.build_flags} -D WLED_RELEASE_NAME=\"ESP32_audioreactive\" #-D WLED_DISABLE_BROWNOUT_DET | ||
; ${esp32.AR_build_flags} | ||
;lib_deps = ${esp32.lib_deps} | ||
; ${esp32.AR_lib_deps} | ||
;monitor_filters = esp32_exception_decoder | ||
;board_build.partitions = ${esp32.default_partitions} | ||
;; board_build.f_flash = 80000000L | ||
|
@@ -483,12 +479,12 @@ board = esp32-poe | |
platform = ${esp32.platform} | ||
platform_packages = ${esp32.platform_packages} | ||
upload_speed = 921600 | ||
custom_usermods = audioreactive | ||
build_unflags = ${common.build_unflags} | ||
build_flags = ${common.build_flags} ${esp32.build_flags} -D WLED_RELEASE_NAME=\"ESP32_Ethernet\" -D RLYPIN=-1 -D WLED_USE_ETHERNET -D BTNPIN=-1 | ||
; -D WLED_DISABLE_ESPNOW ;; ESP-NOW requires wifi, may crash with ethernet only | ||
${esp32.AR_build_flags} | ||
lib_deps = ${esp32.lib_deps} | ||
${esp32.AR_lib_deps} | ||
board_build.partitions = ${esp32.default_partitions} | ||
|
||
[env:esp32_wrover] | ||
|
@@ -499,14 +495,14 @@ board = ttgo-t7-v14-mini32 | |
board_build.f_flash = 80000000L | ||
board_build.flash_mode = qio | ||
board_build.partitions = ${esp32.extended_partitions} | ||
custom_usermods = audioreactive | ||
build_unflags = ${common.build_unflags} | ||
build_flags = ${common.build_flags} ${esp32_idf_V4.build_flags} -D WLED_RELEASE_NAME=\"ESP32_WROVER\" | ||
-DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue ;; Older ESP32 (rev.<3) need a PSRAM fix (increases static RAM used) https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/external-ram.html | ||
-D DATA_PINS=25 | ||
${esp32.AR_build_flags} | ||
lib_deps = ${esp32_idf_V4.lib_deps} | ||
${esp32.AR_lib_deps} | ||
|
||
|
||
[env:esp32c3dev] | ||
extends = esp32c3 | ||
platform = ${esp32c3.platform} | ||
|
@@ -530,6 +526,7 @@ board_build.arduino.memory_type = qio_opi ;; use with PSRAM: 8MB or 16MB | |
platform = ${esp32s3.platform} | ||
platform_packages = ${esp32s3.platform_packages} | ||
upload_speed = 921600 | ||
custom_usermods = audioreactive | ||
build_unflags = ${common.build_unflags} | ||
build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S3_16MB_opi\" | ||
-D CONFIG_LITTLEFS_FOR_IDF_3_2 -D WLED_WATCHDOG_TIMEOUT=0 | ||
|
@@ -538,7 +535,6 @@ build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME= | |
-DBOARD_HAS_PSRAM | ||
${esp32.AR_build_flags} | ||
lib_deps = ${esp32s3.lib_deps} | ||
${esp32.AR_lib_deps} | ||
board_build.partitions = ${esp32.extreme_partitions} | ||
board_upload.flash_size = 16MB | ||
board_upload.maximum_size = 16777216 | ||
|
@@ -553,6 +549,7 @@ board_build.arduino.memory_type = qio_opi ;; use with PSRAM: 8MB or 16MB | |
platform = ${esp32s3.platform} | ||
platform_packages = ${esp32s3.platform_packages} | ||
upload_speed = 921600 | ||
custom_usermods = audioreactive | ||
build_unflags = ${common.build_unflags} | ||
build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S3_8MB_opi\" | ||
-D CONFIG_LITTLEFS_FOR_IDF_3_2 -D WLED_WATCHDOG_TIMEOUT=0 | ||
|
@@ -561,7 +558,6 @@ build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME= | |
-DBOARD_HAS_PSRAM | ||
${esp32.AR_build_flags} | ||
lib_deps = ${esp32s3.lib_deps} | ||
${esp32.AR_lib_deps} | ||
board_build.partitions = ${esp32.large_partitions} | ||
board_build.f_flash = 80000000L | ||
board_build.flash_mode = qio | ||
|
@@ -575,6 +571,7 @@ platform_packages = ${esp32s3.platform_packages} | |
board = esp32s3camlcd ;; this is the only standard board with "opi_opi" | ||
board_build.arduino.memory_type = opi_opi | ||
upload_speed = 921600 | ||
custom_usermods = audioreactive | ||
build_unflags = ${common.build_unflags} | ||
build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S3_WROOM-2\" | ||
-D CONFIG_LITTLEFS_FOR_IDF_3_2 -D WLED_WATCHDOG_TIMEOUT=0 | ||
|
@@ -587,7 +584,6 @@ build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME= | |
${esp32.AR_build_flags} | ||
-D SR_DMTYPE=1 -D I2S_SDPIN=13 -D I2S_CKPIN=14 -D I2S_WSPIN=15 -D MCLK_PIN=4 ;; I2S mic | ||
lib_deps = ${esp32s3.lib_deps} | ||
${esp32.AR_lib_deps} | ||
|
||
board_build.partitions = ${esp32.extreme_partitions} | ||
board_upload.flash_size = 16MB | ||
|
@@ -600,6 +596,7 @@ board = lolin_s3_mini ;; -S3 mini, 4MB flash 2MB PSRAM | |
platform = ${esp32s3.platform} | ||
platform_packages = ${esp32s3.platform_packages} | ||
upload_speed = 921600 | ||
custom_usermods = audioreactive | ||
build_unflags = ${common.build_unflags} | ||
build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S3_4M_qspi\" | ||
-DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=1 ;; for boards with USB-OTG connector only (USBCDC or "TinyUSB") | ||
|
@@ -608,7 +605,6 @@ build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME= | |
-D WLED_WATCHDOG_TIMEOUT=0 | ||
${esp32.AR_build_flags} | ||
lib_deps = ${esp32s3.lib_deps} | ||
${esp32.AR_lib_deps} | ||
board_build.partitions = ${esp32.default_partitions} | ||
board_build.f_flash = 80000000L | ||
board_build.flash_mode = qio | ||
|
@@ -621,6 +617,7 @@ board = lolin_s2_mini | |
board_build.partitions = ${esp32.default_partitions} | ||
board_build.flash_mode = qio | ||
board_build.f_flash = 80000000L | ||
custom_usermods = audioreactive | ||
build_unflags = ${common.build_unflags} | ||
build_flags = ${common.build_flags} ${esp32s2.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S2\" | ||
-DARDUINO_USB_CDC_ON_BOOT=1 | ||
|
@@ -639,4 +636,3 @@ build_flags = ${common.build_flags} ${esp32s2.build_flags} -D WLED_RELEASE_NAME= | |
; -D STATUSLED=15 | ||
${esp32.AR_build_flags} | ||
lib_deps = ${esp32s2.lib_deps} | ||
${esp32.AR_lib_deps} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "audioreactive", | ||
"build": { | ||
"srcDir": ".", | ||
"includeDir": "../../wled00", | ||
"libLDFMode": "chain+", | ||
"libArchive": false | ||
}, | ||
netmindz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"dependencies": [ | ||
{ | ||
"owner": "kosme", | ||
"name": "arduinoFFT", | ||
"version": "2.0.1", | ||
"platforms": "espressif32" | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "animartrix", | ||
"build": { | ||
"srcDir": ".", | ||
"includeDir": "../../wled00", | ||
"libLDFMode": "chain+", | ||
"libArchive": false | ||
}, | ||
"dependencies": { | ||
"Animartrix": "https://github.com/netmindz/animartrix.git#b172586" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "auto_save", | ||
"build": { | ||
"srcDir": ".", | ||
"includeDir": "../../wled00", | ||
"libLDFMode": "chain+" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are updating to be a library, why do we still need the old
AR_lib_deps
info as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compatibility with old platformio_override files that reference it. If we remove it,
git pull
breaks platformIO completely until you clean all references out of your overrides.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If folk have platform_override that is trying to use AR, is having
AR_build_flags
that that doesn't have the old define just going to cause confusion? They will think they have the flags, but now that's not enough to actually enableThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this would be a breaking change that will need to be staged appropriately. Unfortunately if your platformio file is outright invalid, PlatformIO in VSCode doesn't tell you what's wrong, it just blankly refuses to operate with no error message. I found it more useful to at least keep the tool operating while I was correcting my build definitions, but that's just my $0.02.