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 aabbbef commit adab425
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions HISTORY.rst
Expand Up @@ -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)
~~~~~~~~~~~~~~~~~~~

Expand Down
8 changes: 6 additions & 2 deletions platformio/project/config.py
Expand Up @@ -164,6 +164,7 @@ def _maintain_renamed_options(self):

@staticmethod
def get_section_scope(section):
assert section
return section.split(":", 1)[0] if ":" in section else section

def walk_options(self, root_section):
Expand Down Expand Up @@ -343,8 +344,11 @@ def _re_interpolation_handler(self, parent_section, parent_option, match):
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":
Expand Down
5 changes: 4 additions & 1 deletion tests/project/test_config.py
Expand Up @@ -657,7 +657,9 @@ def test_nested_interpolation(tmp_path: Path):
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
Expand All @@ -672,6 +674,7 @@ 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"
testing_command = config.get("env:myenv", "test_testing_command")
assert "$" not in " ".join(testing_command)

Expand Down

0 comments on commit adab425

Please sign in to comment.