Skip to content

Commit

Permalink
Expanded support for SCons variables declared in the legacy format ``…
Browse files Browse the repository at this point in the history
…${SCONS_VARNAME}`` // Resolve #4828
  • Loading branch information
ivankravets committed Jan 11, 2024
1 parent 485f801 commit f31f9fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion platformio/project/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def _re_interpolation_handler(self, parent_section, parent_option, match):
if option in self.BUILTIN_VARS:
return self.BUILTIN_VARS[option]()
# SCons varaibles
return f"${option}"
return f"${{{option}}}"

# handle system environment variables
if section == "sysenv":
Expand Down
11 changes: 9 additions & 2 deletions tests/project/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,12 +660,14 @@ def test_nested_interpolation(tmp_path: Path):
build_flags =
-D UTIME=${UNIX_TIME}
-I ${PROJECTSRC_DIR}/hal
-Wl,-Map,${BUILD_DIR}/${PROGNAME}.map
test_testing_command =
${platformio.packages_dir}/tool-simavr/bin/simavr
-m
atmega328p
-f
16000000L
${UPLOAD_PORT and "-p "+UPLOAD_PORT}
${platformio.build_dir}/${this.__env__}/firmware.elf
"""
)
Expand All @@ -674,9 +676,14 @@ def test_nested_interpolation(tmp_path: Path):
os.path.join("$PROJECT_DIR", "assets")
)
assert config.get("env:myenv", "build_flags")[0][-10:].isdigit()
assert config.get("env:myenv", "build_flags")[1] == "-I $PROJECTSRC_DIR/hal"
assert config.get("env:myenv", "build_flags")[1] == "-I ${PROJECTSRC_DIR}/hal"
assert (
config.get("env:myenv", "build_flags")[2]
== "-Wl,-Map,${BUILD_DIR}/${PROGNAME}.map"
)
testing_command = config.get("env:myenv", "test_testing_command")
assert "$" not in " ".join(testing_command)
assert "$" not in testing_command[0]
assert testing_command[5] == '${UPLOAD_PORT and "-p "+UPLOAD_PORT}'


def test_extends_order(tmp_path: Path):
Expand Down

0 comments on commit f31f9fa

Please sign in to comment.