From 666cb1b85259cfbea52e1f4fc69eb1640f2764c2 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sun, 30 Apr 2023 21:53:45 +0200 Subject: build: Allow patching/overriding platform spec. --- build/scons_tools/tool_selectmcu.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/build/scons_tools/tool_selectmcu.py b/build/scons_tools/tool_selectmcu.py index f73caa1..38b154d 100644 --- a/build/scons_tools/tool_selectmcu.py +++ b/build/scons_tools/tool_selectmcu.py @@ -1,6 +1,14 @@ from SCons.Script import * -def SelectMCU(env, mcu, variant_dir = None): +def do_patch(target, source): + for k, v in source.items(): + if k in target and isinstance(v, dict): + do_patch(target[k], v) + + else: + target[k] = v + +def SelectMCU(env, mcu, variant_dir = None, patch = None): spec = env.PlatformSpec(mcu = mcu) @@ -8,6 +16,9 @@ def SelectMCU(env, mcu, variant_dir = None): print('Unknown MCU: %s' % mcu) Exit(1) + if patch: + do_patch(spec, patch) + detected_gcc = env.Detect([f'{toolchain}-gcc' for toolchain in spec['toolchains']]) if detected_gcc is None: print('Couldn\'t find a suitable toolchain.') -- cgit v1.2.3