From 28aeea4c964b1152680c52eaadf52443aa9840d7 Mon Sep 17 00:00:00 2001 From: mikecarper Date: Fri, 23 Oct 2026 09:44:10 -0700 Subject: [PATCH] Defer packed help board selection to the effective C++ profile --- scripts/nrf52_flash_trim.py | 9 +++++---- test/test_companion_help_build_policy.py | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/nrf52_flash_trim.py b/scripts/nrf52_flash_trim.py index a22caf16e..5b42f4a2e 100644 --- a/scripts/nrf52_flash_trim.py +++ b/scripts/nrf52_flash_trim.py @@ -190,10 +190,10 @@ def packed_help_policy(platform, mcu, src_filter, flags=(), cppdefines=()): return False if any(source_selected(src_filter, source) for source in ROLE_SOURCES): return False - values = flag_defines(flags, cppdefines) - # Full Companion can arrive later through PLATFORMIO_BUILD_FLAGS. Register - # the exact source early; its C++ gate leaves non-Full RAK builds empty. - return values.get("RAK_4631") is not None + # Board and Full profile defines can both arrive after pre-scripts. Only + # the exact help source changes language; its C++ gate leaves every other + # board/profile empty, without changing MyMesh or framework compilation. + return True def compile_packed_help(build_env, node): @@ -210,6 +210,7 @@ def compile_packed_help(build_env, node): for name in ("CCFLAGS", "CXXFLAGS")} flags["CXXFLAGS"].append("-std=gnu++17") private_env.Replace(**flags) + print("nRF52 Companion help: isolated C++17 source") return private_env.Object(node) diff --git a/test/test_companion_help_build_policy.py b/test/test_companion_help_build_policy.py index 407b223c5..1e9843666 100644 --- a/test/test_companion_help_build_policy.py +++ b/test/test_companion_help_build_policy.py @@ -6,12 +6,12 @@ import unittest ROOT=Path(__file__).resolve().parents[1] spec=importlib.util.spec_from_file_location('help_language_policy',ROOT/'scripts/nrf52_flash_trim.py');m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m) class HelpBuildPolicy(unittest.TestCase): - def test_rak_companion_source_registers_before_late_full_profile_flags(self): + def test_companion_source_registers_before_late_board_and_profile_flags(self): yes=dict(platform='nordicnrf52',mcu='nrf52840',src_filter='+<*> +<../examples/companion_radio>',flags='-DRAK_4631 -DCOMPANION_RADIO_FULL') self.assertTrue(m.packed_help_policy(**yes)) - for flags in ('-DRAK_4631', '-DRAK_4631 -DCOMPANION_RADIO_FULL -UCOMPANION_RADIO_FULL'): + for flags in ('', '-DRAK_4631', '-DCOMPANION_RADIO_FULL', '-DRAK_4631 -URAK_4631', '-DRAK_4631 -DCOMPANION_RADIO_FULL -UCOMPANION_RADIO_FULL'): self.assertTrue(m.packed_help_policy(**dict(yes,flags=flags))) - for key,value in [('platform','espressif32'),('mcu','nrf52832'),('src_filter','+<*>'),('src_filter','+<../examples/companion_radio> +<../examples/simple_repeater>'),('flags','-DCOMPANION_RADIO_FULL'),('flags','-DRAK_4631 -URAK_4631')]: + for key,value in [('platform','espressif32'),('mcu','nrf52832'),('src_filter','+<*>'),('src_filter','+<../examples/companion_radio> +<../examples/simple_repeater>')]: with self.subTest(key=key,value=value): no=dict(yes);no[key]=value;self.assertFalse(m.packed_help_policy(**no)) self.assertTrue(m.packed_help_policy('nordicnrf52','nrf52840','+<../examples/companion_radio>',cppdefines=[('RAK_4631',1),('COMPANION_RADIO_FULL',1)]))