Skip to content

Commit 204a60d

Browse files
committed
Parse only $PROJECT_HASH legacy built-in variable
1 parent 0f554d2 commit 204a60d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

platformio/project/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,11 @@ def _expand_interpolations(self, section, option, value):
316316
return value
317317

318318
# legacy support for variables delclared without "${}"
319+
legacy_vars = ["PROJECT_HASH"]
319320
stop = False
320321
while not stop:
321322
stop = True
322-
for name in self.BUILTIN_VARS:
323+
for name in legacy_vars:
323324
x = value.find(f"${name}")
324325
if x < 0 or value[x - 1] == "$":
325326
continue

tests/project/test_config.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,7 @@ def test_get_value(config):
354354
"--help",
355355
]
356356
# test relative dir
357-
assert config.get("platformio", "src_dir") == os.path.abspath(
358-
os.path.join(os.getcwd(), "source")
359-
)
360-
357+
assert config.get("platformio", "src_dir") == "source"
361358
# renamed option
362359
assert config.get("env:extra_1", "lib_install") == ["574"]
363360
assert config.get("env:extra_1", "lib_deps") == ["574"]
@@ -654,6 +651,7 @@ def test_nested_interpolation(tmp_path: Path):
654651
"""
655652
[platformio]
656653
build_dir = /tmp/pio-$PROJECT_HASH
654+
data_dir = $PROJECT_DIR/assets
657655
658656
[env:myenv]
659657
build_flags = -D UTIME=${UNIX_TIME}
@@ -667,9 +665,10 @@ def test_nested_interpolation(tmp_path: Path):
667665
"""
668666
)
669667
config = ProjectConfig(str(project_conf))
668+
assert config.get("platformio", "data_dir") == "$PROJECT_DIR/assets"
669+
assert config.get("env:myenv", "build_flags")[0][-10:].isdigit()
670670
testing_command = config.get("env:myenv", "test_testing_command")
671671
assert "$" not in " ".join(testing_command)
672-
assert config.get("env:myenv", "build_flags")[0][-10:].isdigit()
673672

674673

675674
def test_extends_order(tmp_path: Path):

0 commit comments

Comments
 (0)