From abf63048187c2ed28429dceeb072793e6f7c6252 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 17 May 2022 16:03:33 +0300 Subject: [PATCH] Fixed an issue when using "Interpolation of Values" and merging str+int options // Resolve #4271 --- HISTORY.rst | 6 ++++-- platformio/project/config.py | 2 +- tests/project/test_config.py | 16 ++++++++++++---- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index bb35be2c..c8d278c2 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,7 @@ Release Notes .. |PIOCONF| replace:: `"platformio.ini" `__ configuration file .. |LDF| replace:: `LDF `__ +.. |INTERPOLATION| replace:: `Interpolation of Values `__ .. _release_notes_6: @@ -15,7 +16,8 @@ PlatformIO Core 6 ~~~~~~~~~~~~~~~~~~ * Improved support for the renamed configuration options (`issue #4270 `_) -* Fixed an issue when calling built-in `pio device monitor `__ filter +* Fixed an issue when calling the built-in `pio device monitor `__ filter +* Fixed an issue when using |INTERPOLATION| and merging str+int options (`issue #4271 `_) 6.0.0 (2022-05-16) ~~~~~~~~~~~~~~~~~~ @@ -98,7 +100,7 @@ Please check the `Migration guide from 5.x to 6.0 `__ with ``${this}`` pattern (`issue #3953 `_) + - Extended |INTERPOLATION| with ``${this}`` pattern (`issue #3953 `_) - 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 `__ - Renamed the "src_filter" project configuration option to the `build_src_filter `__ diff --git a/platformio/project/config.py b/platformio/project/config.py index 0a4c6ed1..999827d5 100644 --- a/platformio/project/config.py +++ b/platformio/project/config.py @@ -330,7 +330,7 @@ class ProjectConfigBase(object): ) if isinstance(value, list): return "\n".join(value) - return value + return str(value) def get(self, section, option, default=MISSING): value = None diff --git a/tests/project/test_config.py b/tests/project/test_config.py index aa948f71..964c0e67 100644 --- a/tests/project/test_config.py +++ b/tests/project/test_config.py @@ -85,6 +85,7 @@ build_flags = -Wl,--gc-sections ${custom.lib_flags} ${custom.debug_flags} + -D SERIAL_BAUD_RATE=${this.monitor_speed} lib_install = 574 [env:extra_2] @@ -297,9 +298,9 @@ def test_getraw_value(config): # known assert config.getraw("env:base", "targets") == "" assert config.getraw("env:extra_1", "lib_deps") == "574" - assert ( - config.getraw("env:extra_1", "build_flags") - == "\n-fdata-sections\n-Wl,--gc-sections\n-lc -lm\n-D DEBUG=1" + assert config.getraw("env:extra_1", "build_flags") == ( + "\n-fdata-sections\n-Wl,--gc-sections\n" + "-lc -lm\n-D DEBUG=1\n-D SERIAL_BAUD_RATE=9600" ) # extended @@ -329,6 +330,7 @@ def test_get_value(config): "-Wl,--gc-sections", "-lc -lm", "-D DEBUG=1", + "-D SERIAL_BAUD_RATE=9600", ] assert config.get("env:extra_2", "build_flags") == ["-Og"] assert config.get("env:extra_2", "monitor_speed") == 9600 @@ -390,7 +392,13 @@ def test_items(config): assert config.items(env="extra_1") == [ ( "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"]), ("monitor_speed", 9600),