Open turgu1 opened 3 years ago
Hello,
You are looking for extends
option, see https://docs.platformio.org/en/latest/projectconf/section_env_advanced.html
I'm sorry Ivan, but extends doesn't do the job. Please look closer to my simple example: If I do what you said:
[devices]
build_flags =
-D MAIN_DEFINE=2
[env:device1]
extends = devices
build_flags =
-D OTHER_DEFINE=1
In [env:device1], I loose the MAIN_DEFINE definition. Hope this is clearer.
Thanks! Guy
See Dynamic variables:
[devices]
build_flags =
-D MAIN_DEFINE=2
[env:device1]
extends = devices
build_flags =
-D OTHER_DEFINE=1
${devices.build_flags}
That is exactly what I want to avoid. When you have several hundred lines of platformio.ini file, it become quiet combersome.
On Mon, 2021-01-04 at 06:02 -0800, Ivan Kravets wrote:
See Dynamic variables:
[devices] build_flags = -D MAIN_DEFINE=2
[env:device1] extends = devices build_flags = -D OTHER_DEFINE=1 ${devices.build_flags}
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Thanks, I moved to PlatformIO Core.
Also see #3952 which is similar but does not limit to build_flags
only.
@turgu1, @lnlp, @softwaregravy, how about the following syntax?
[foo]
build_flags = -DHELLO
[bar]
lib_deps = ...
[env:myenv]
extends = merge:foo, bar
So, the prefix merge
will instruct PlatformIO to merge values and avoid duplicates, and the replace:%name%
or %name%
will override the option (current behavior).
That seems reasonable
This is it! Thanks guys!
👍
@ivankravets any news on this topic?
I have a different use case to merge. Please look at this platformio.ini snippet:
[OTA8266]
upload_protocol = espota
; use secret from _credentials_OTA.ini for later use in [env:My-Device-OTA]
ota_auth = ${secrets.ota_auth}
upload_flags =
--auth=${ota_auth}
--port=8266
[env:MyDevice1]
board = esp01_1m
; set device for Config.h
build_flags = ${env.build_flags}
-DMyDevice1
[env: MyDevice1_OTA]
extends = MyDevice1, OTA8266
upload_port = MyDevice1.local
With the current implementation we get
Error: BoardConfig: Board is not defined
But there are no conflicting properties which would be overwritten.
This is exactly what I was hoping to do as well; multiple upload protocols to configure, multiple build configurations and I'd like to matrix them together.
Conceptually, this is the first thing to come to mind: https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#using-a-matrix-strategy
Version: PlatformIO IDE V2.2.1 Editor: VSCode OS: Linux
Hello, it would be beneficial that the following platformio.ini would merge options, such that in my (over simplified) example below, for [env:device1], there would be two entries in the build_flags option, instead of one (with the current version of platformio, builds_flags in [env:device1] replaces the one from devices when
extends
is used. I was expecting that there would be some merge option available):I could have added
${device.build_flags}
under-D OTHER_DEFINE=1
but when you have many of these repeated options, it defeat the purpose of clarity. Here is a real example that would benefit from this feature (don't tell me to use [env] for this, the platformio.ini contains a lot more that can't rely on [env]):Did I miss something from what is currently possible with the platform.ini structure? Is there another way to do it without compromising the clarity of the ini file? Maybe a new option named
merges
or something? Thanks a lot for your help!!Guy