Skip to content

Commit f31f9fa

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

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

platformio/project/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def _re_interpolation_handler(self, parent_section, parent_option, match):
348348
if option in self.BUILTIN_VARS:
349349
return self.BUILTIN_VARS[option]()
350350
# SCons varaibles
351-
return f"${option}"
351+
return f"${{{option}}}"
352352

353353
# handle system environment variables
354354
if section == "sysenv":

tests/project/test_config.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,12 +660,14 @@ def test_nested_interpolation(tmp_path: Path):
660660
build_flags =
661661
-D UTIME=${UNIX_TIME}
662662
-I ${PROJECTSRC_DIR}/hal
663+
-Wl,-Map,${BUILD_DIR}/${PROGNAME}.map
663664
test_testing_command =
664665
${platformio.packages_dir}/tool-simavr/bin/simavr
665666
-m
666667
atmega328p
667668
-f
668669
16000000L
670+
${UPLOAD_PORT and "-p "+UPLOAD_PORT}
669671
${platformio.build_dir}/${this.__env__}/firmware.elf
670672
"""
671673
)
@@ -674,9 +676,14 @@ def test_nested_interpolation(tmp_path: Path):
674676
os.path.join("$PROJECT_DIR", "assets")
675677
)
676678
assert config.get("env:myenv", "build_flags")[0][-10:].isdigit()
677-
assert config.get("env:myenv", "build_flags")[1] == "-I $PROJECTSRC_DIR/hal"
679+
assert config.get("env:myenv", "build_flags")[1] == "-I ${PROJECTSRC_DIR}/hal"
680+
assert (
681+
config.get("env:myenv", "build_flags")[2]
682+
== "-Wl,-Map,${BUILD_DIR}/${PROGNAME}.map"
683+
)
678684
testing_command = config.get("env:myenv", "test_testing_command")
679-
assert "$" not in " ".join(testing_command)
685+
assert "$" not in testing_command[0]
686+
assert testing_command[5] == '${UPLOAD_PORT and "-p "+UPLOAD_PORT}'
680687

681688

682689
def test_extends_order(tmp_path: Path):

0 commit comments

Comments
 (0)