diff --git a/scripts/stm32_mini_size.py b/scripts/stm32_mini_size.py index 79cb33378..55718c987 100644 --- a/scripts/stm32_mini_size.py +++ b/scripts/stm32_mini_size.py @@ -12,7 +12,7 @@ if env["PIOENV"] == "wio-e5-mini_repeater": # Reuse the qualified RAK CLI's equivalent libc reply copies. Restrict # this flag to CommonCLI.cpp; radio, framework and other objects retain # the existing optimizer recipe. - source = Path(__file__).resolve().with_name("nrf52_flash_trim.py") + source = Path(env.subst("$PROJECT_DIR/scripts/nrf52_flash_trim.py")).resolve() spec = importlib.util.spec_from_file_location("mesh_mini_cli_replies", source) replies = importlib.util.module_from_spec(spec) spec.loader.exec_module(replies) diff --git a/test/test_stm32_mini_repeater_profile.py b/test/test_stm32_mini_repeater_profile.py index 91ca5ef6f..3e2e28242 100644 --- a/test/test_stm32_mini_repeater_profile.py +++ b/test/test_stm32_mini_repeater_profile.py @@ -159,6 +159,17 @@ class MiniRepeaterProfileTest(unittest.TestCase): other = Node(ROOT / path) self.assertIs(callback(environment, other), other) + def test_scons_script_context_without_file_still_installs_exact_cli_policy(self): + script = ROOT / "scripts/stm32_mini_size.py" + environment = FakeEnvironment(PIOENV=TARGET) + namespace = {"env": environment, + "Import": lambda name: self.assertEqual(name, "env")} + exec(compile(script.read_text(), str(script), "exec"), namespace) + self.assertNotIn("__file__", namespace) + self.assertEqual(environment["LINKFLAGS"], list(LINK_SIZE_FLAGS)) + self.assertEqual(len(environment.middleware), 1) + self.assertEqual(environment.middleware[0][1], "*CommonCLI.cpp") + def test_capability_contract_declares_only_exact_mini_repeater_omissions(self): command = r''' set -euo pipefail