Skip to content
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

Proposal to improve platformio.ini #4469

Closed
1 task done
softwaregravy opened this issue Nov 21, 2022 · 3 comments
Closed
1 task done

Proposal to improve platformio.ini #4469

softwaregravy opened this issue Nov 21, 2022 · 3 comments
Labels
config platformio.ini feature

Comments

@softwaregravy
Copy link

  • Feature Request.

Background

As my current project ramps up from tiny to small, I am looking for a more power config system. I see others with similar concerns. #3788 #4462 #3952 #4451

As I see it, the current model is override (or replace). Simply put, if a duplicate key is found the last one loaded wins and replaces all the options. The other issues and feature requests are looking for a merge option which combines other entries found.

To illustrate, consider the case of our code running in 2 modes: staging and production, and on 2 boards: esp32_s2 and esp32_s3. These two each have configs. And these configs makes sense across all combinations.

Current

[staging]
build_flags = -DStaging
[production]
build_flags = -DProduction
[esp32_s2]
build_flags = -DS2
[esp32_s3]
build_flags = -DS3

Currently extending directly via extends or indirectly via [env: prefix overrides values. So we have to currently include all previous flags by referencing them on a per-key basis

[s2_staging]
build_flags = ${staging.build_flags} ${esp32_s2.build_flags}
[s2_production]
build_flags = ${production.build_flags} ${esp32_s2.build_flags}
[s3_staging]
build_flags = ${staging.build_flags} ${esp32_s3.build_flags}
[s3_production]
build_flags = ${production.build_flags} ${esp32_s3.build_flags}

Hopefully my contrived example accurately illustrates the current status quo.

Proposal

I propose adding a an option that operates like extends, but it merges instead of overrides. For now, lets call this extend_merge (but we can call it whatever). In this case, we'd still have the first part.

[staging]
build_flags = -DStaging
[production]
build_flags = -DProduction
[esp32_s2]
build_flags = -DS2
[esp32_s3]
build_flags = -DS3

But then the 2nd part would reference this directly without knowing the keys:

[s2_staging]
extend_merge = staging, esp32_s2
[s2_production]
extend_merge = production, esp32_s2
[s3_staging]
extend_merge = staging, esp32_s3
[s3_production]
extend_merge = production, esp32_s3

In my little contrived case, the lines of code saved are minimal. But it is easy to imagine a case where the number of keys set in staging is 6-10, and then we'd save all those other lines.

@Jason2866
Copy link
Contributor

What should happen if there are duplicate but different entrys defined?

@ivankravets ivankravets added feature config platformio.ini labels Nov 24, 2022
@ivankravets ivankravets added this to the 6.2 milestone Nov 24, 2022
@softwaregravy
Copy link
Author

I don't follow what you mean by "duplicate but different"

@ivankravets
Copy link
Member

Duplicates of #3788

I'll provide more details in #3788

@ivankravets ivankravets removed this from the 6.2 milestone Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config platformio.ini feature
Projects
None yet
Development

No branches or pull requests

3 participants