Fixed an issue when using "Interpolation of Values" and merging str+int options // Resolve #4271

This commit is contained in:
Ivan Kravets
2022-05-17 16:03:33 +03:00
parent 9a86175701
commit abf6304818
3 changed files with 17 additions and 7 deletions

View File

@ -3,6 +3,7 @@ Release Notes
.. |PIOCONF| replace:: `"platformio.ini" <https://docs.platformio.org/en/latest/projectconf.html>`__ configuration file .. |PIOCONF| replace:: `"platformio.ini" <https://docs.platformio.org/en/latest/projectconf.html>`__ configuration file
.. |LDF| replace:: `LDF <https://docs.platformio.org/en/latest/librarymanager/ldf.html>`__ .. |LDF| replace:: `LDF <https://docs.platformio.org/en/latest/librarymanager/ldf.html>`__
.. |INTERPOLATION| replace:: `Interpolation of Values <https://docs.platformio.org/en/latest/projectconf/interpolation.html>`__
.. _release_notes_6: .. _release_notes_6:
@ -15,7 +16,8 @@ PlatformIO Core 6
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
* Improved support for the renamed configuration options (`issue #4270 <https://github.com/platformio/platformio-core/issues/4270>`_) * Improved support for the renamed configuration options (`issue #4270 <https://github.com/platformio/platformio-core/issues/4270>`_)
* Fixed an issue when calling built-in `pio device monitor <https://docs.platformio.org/en/latest/core/userguide/device/cmd_monitor.html#filters>`__ filter * Fixed an issue when calling the built-in `pio device monitor <https://docs.platformio.org/en/latest/core/userguide/device/cmd_monitor.html#filters>`__ filter
* Fixed an issue when using |INTERPOLATION| and merging str+int options (`issue #4271 <https://github.com/platformio/platformio-core/issues/4271>`_)
6.0.0 (2022-05-16) 6.0.0 (2022-05-16)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
@ -98,7 +100,7 @@ Please check the `Migration guide from 5.x to 6.0 <https://docs.platformio.org/e
* **Project Configuration** * **Project Configuration**
- Extended `Interpolation of Values <https://docs.platformio.org/en/latest/projectconf/interpolation.html>`__ with ``${this}`` pattern (`issue #3953 <https://github.com/platformio/platformio-core/issues/3953>`_) - Extended |INTERPOLATION| with ``${this}`` pattern (`issue #3953 <https://github.com/platformio/platformio-core/issues/3953>`_)
- Embed environment name of the current section in the |PIOCONF| using ``${this.__env__}`` pattern - Embed environment name of the current section in the |PIOCONF| using ``${this.__env__}`` pattern
- Renamed the "src_build_flags" project configuration option to the `build_src_flags <https://docs.platformio.org/en/latest/projectconf/section_env_build.html#build-src-flags>`__ - Renamed the "src_build_flags" project configuration option to the `build_src_flags <https://docs.platformio.org/en/latest/projectconf/section_env_build.html#build-src-flags>`__
- Renamed the "src_filter" project configuration option to the `build_src_filter <https://docs.platformio.org/en/latest/projectconf/section_env_build.html#build-src-filter>`__ - Renamed the "src_filter" project configuration option to the `build_src_filter <https://docs.platformio.org/en/latest/projectconf/section_env_build.html#build-src-filter>`__

View File

@ -330,7 +330,7 @@ class ProjectConfigBase(object):
) )
if isinstance(value, list): if isinstance(value, list):
return "\n".join(value) return "\n".join(value)
return value return str(value)
def get(self, section, option, default=MISSING): def get(self, section, option, default=MISSING):
value = None value = None

View File

@ -85,6 +85,7 @@ build_flags =
-Wl,--gc-sections -Wl,--gc-sections
${custom.lib_flags} ${custom.lib_flags}
${custom.debug_flags} ${custom.debug_flags}
-D SERIAL_BAUD_RATE=${this.monitor_speed}
lib_install = 574 lib_install = 574
[env:extra_2] [env:extra_2]
@ -297,9 +298,9 @@ def test_getraw_value(config):
# known # known
assert config.getraw("env:base", "targets") == "" assert config.getraw("env:base", "targets") == ""
assert config.getraw("env:extra_1", "lib_deps") == "574" assert config.getraw("env:extra_1", "lib_deps") == "574"
assert ( assert config.getraw("env:extra_1", "build_flags") == (
config.getraw("env:extra_1", "build_flags") "\n-fdata-sections\n-Wl,--gc-sections\n"
== "\n-fdata-sections\n-Wl,--gc-sections\n-lc -lm\n-D DEBUG=1" "-lc -lm\n-D DEBUG=1\n-D SERIAL_BAUD_RATE=9600"
) )
# extended # extended
@ -329,6 +330,7 @@ def test_get_value(config):
"-Wl,--gc-sections", "-Wl,--gc-sections",
"-lc -lm", "-lc -lm",
"-D DEBUG=1", "-D DEBUG=1",
"-D SERIAL_BAUD_RATE=9600",
] ]
assert config.get("env:extra_2", "build_flags") == ["-Og"] assert config.get("env:extra_2", "build_flags") == ["-Og"]
assert config.get("env:extra_2", "monitor_speed") == 9600 assert config.get("env:extra_2", "monitor_speed") == 9600
@ -390,7 +392,13 @@ def test_items(config):
assert config.items(env="extra_1") == [ assert config.items(env="extra_1") == [
( (
"build_flags", "build_flags",
["-fdata-sections", "-Wl,--gc-sections", "-lc -lm", "-D DEBUG=1"], [
"-fdata-sections",
"-Wl,--gc-sections",
"-lc -lm",
"-D DEBUG=1",
"-D SERIAL_BAUD_RATE=9600",
],
), ),
("lib_install", ["574"]), ("lib_install", ["574"]),
("monitor_speed", 9600), ("monitor_speed", 9600),