Expanded support for SCons variables declared in the legacy format `${SCONS_VARNAME}` // Resolve #4828

This commit is contained in:
Ivan Kravets
2024-01-11 21:33:01 +02:00
parent 485f801c74
commit f31f9fa616
2 changed files with 10 additions and 3 deletions

View File

@ -348,7 +348,7 @@ class ProjectConfigBase:
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":

View File

@ -660,12 +660,14 @@ data_dir = $PROJECT_DIR/assets
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
"""
)
@ -674,9 +676,14 @@ test_testing_command =
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):