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

This commit is contained in:
Ivan Kravets
2024-01-11 19:23:26 +02:00
parent aabbbef944
commit adab425c6d
3 changed files with 12 additions and 3 deletions

View File

@ -20,6 +20,8 @@ test-driven methodologies, and modern toolchains for unrivaled success.
6.1.13 (2024-??-??)
~~~~~~~~~~~~~~~~~~~
* Expanded support for SCons variables declared in the legacy format ``${SCONS_VARNAME}`` (`issue #4828 <https://github.com/platformio/platformio-core/issues/4828>`_)
6.1.12 (2024-01-10)
~~~~~~~~~~~~~~~~~~~

View File

@ -164,6 +164,7 @@ class ProjectConfigBase:
@staticmethod
def get_section_scope(section):
assert section
return section.split(":", 1)[0] if ":" in section else section
def walk_options(self, root_section):
@ -343,8 +344,11 @@ class ProjectConfigBase:
section, option = match.group(1), match.group(2)
# handle built-in variables
if section is None and option in self.BUILTIN_VARS:
return self.BUILTIN_VARS[option]()
if section is None:
if option in self.BUILTIN_VARS:
return self.BUILTIN_VARS[option]()
# SCons varaibles
return f"${option}"
# handle system environment variables
if section == "sysenv":

View File

@ -657,7 +657,9 @@ build_dir = /tmp/pio-$PROJECT_HASH
data_dir = $PROJECT_DIR/assets
[env:myenv]
build_flags = -D UTIME=${UNIX_TIME}
build_flags =
-D UTIME=${UNIX_TIME}
-I ${PROJECTSRC_DIR}/hal
test_testing_command =
${platformio.packages_dir}/tool-simavr/bin/simavr
-m
@ -672,6 +674,7 @@ 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"
testing_command = config.get("env:myenv", "test_testing_command")
assert "$" not in " ".join(testing_command)