Skip to content

Commit adab425

Browse files
committed
Expanded support for SCons variables declared in the legacy format ${SCONS_VARNAME} // Resolve platformio#4828
1 parent aabbbef commit adab425

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

HISTORY.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ test-driven methodologies, and modern toolchains for unrivaled success.
2020
6.1.13 (2024-??-??)
2121
~~~~~~~~~~~~~~~~~~~
2222

23+
* Expanded support for SCons variables declared in the legacy format ``${SCONS_VARNAME}`` (`issue #4828 <https://github.com/platformio/platformio-core/issues/4828>`_)
24+
2325
6.1.12 (2024-01-10)
2426
~~~~~~~~~~~~~~~~~~~
2527

platformio/project/config.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def _maintain_renamed_options(self):
164164

165165
@staticmethod
166166
def get_section_scope(section):
167+
assert section
167168
return section.split(":", 1)[0] if ":" in section else section
168169

169170
def walk_options(self, root_section):
@@ -343,8 +344,11 @@ def _re_interpolation_handler(self, parent_section, parent_option, match):
343344
section, option = match.group(1), match.group(2)
344345

345346
# handle built-in variables
346-
if section is None and option in self.BUILTIN_VARS:
347-
return self.BUILTIN_VARS[option]()
347+
if section is None:
348+
if option in self.BUILTIN_VARS:
349+
return self.BUILTIN_VARS[option]()
350+
# SCons varaibles
351+
return f"${option}"
348352

349353
# handle system environment variables
350354
if section == "sysenv":

tests/project/test_config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,9 @@ def test_nested_interpolation(tmp_path: Path):
657657
data_dir = $PROJECT_DIR/assets
658658
659659
[env:myenv]
660-
build_flags = -D UTIME=${UNIX_TIME}
660+
build_flags =
661+
-D UTIME=${UNIX_TIME}
662+
-I ${PROJECTSRC_DIR}/hal
661663
test_testing_command =
662664
${platformio.packages_dir}/tool-simavr/bin/simavr
663665
-m
@@ -672,6 +674,7 @@ def test_nested_interpolation(tmp_path: Path):
672674
os.path.join("$PROJECT_DIR", "assets")
673675
)
674676
assert config.get("env:myenv", "build_flags")[0][-10:].isdigit()
677+
assert config.get("env:myenv", "build_flags")[1] == "-I $PROJECTSRC_DIR/hal"
675678
testing_command = config.get("env:myenv", "test_testing_command")
676679
assert "$" not in " ".join(testing_command)
677680

0 commit comments

Comments
 (0)