From 5d7947e6d919418765b02c6ad327bd7d0bde586d Mon Sep 17 00:00:00 2001 From: Pat Bernardi Date: Tue, 9 Jul 2024 10:38:56 -0400 Subject: [PATCH] Treat loaders differently for OS targets As background, OS targets use OS provided linker scripts rather than scripts provided by the runtime. Instead of resorting to external runtime.xml files to exclude references to these scripts, target.py is enhanced to not generate references these bare-metal specific loaders and linker scripts through a new Target property is_os_target. This makes it easier to maintain OS target's compiler and linker switches in a single file in bb-runtimes. The loaders property is also repurposed for OS targets to accommodate different link time scenarios. Issue: #70 --- support/bsp_sources/target.py | 71 +++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/support/bsp_sources/target.py b/support/bsp_sources/target.py index 034a41f7..a7de8b6b 100644 --- a/support/bsp_sources/target.py +++ b/support/bsp_sources/target.py @@ -286,9 +286,14 @@ def dump_runtime_xml(self, rts_name, rts): ret += " \n" ret += " \n' % loader + if loader == "USER": + continue indent += 3 blank = indent * " " - for loader in loaders: + switches = [] + for val in self.ld_scripts: + if val.loaders is None or loader in val.loaders: + switches.append('"-T", "%s"' % val.name) + for sw in self.ld_switches: + if is_string(sw["loader"]) and sw["loader"] == loader: + switches.append('"%s"' % sw["switch"]) + if isinstance(sw["loader"], list) and loader in sw["loader"]: + switches.append('"%s"' % sw["switch"]) + if len(switches) > 0: ret += blank - ret += 'when "%s" =>\n' % loader - if loader == "USER": - continue - indent += 3 - blank = indent * " " - - switches = [] - for val in self.ld_scripts: - if val.loaders is None or loader in val.loaders: - switches.append('"-T", "%s"' % val.name) - for sw in self.ld_switches: - if is_string(sw["loader"]) and sw["loader"] == loader: - switches.append('"%s"' % sw["switch"]) - if isinstance(sw["loader"], list) and loader in sw["loader"]: - switches.append('"%s"' % sw["switch"]) - if len(switches) > 0: - ret += blank - ret += "for Required_Switches use Linker'Required_Switches" - ret += " &\n" + blank + " " - ret += "(%s);\n" % (",\n " + blank).join(switches) - indent -= 3 - blank = indent * " " - + ret += "for Required_Switches use Linker'Required_Switches" + ret += " &\n" + blank + " " + ret += "(%s);\n" % (",\n " + blank).join(switches) indent -= 3 blank = indent * " " - ret += "%send case;\n" % blank + + indent -= 3 + blank = indent * " " + ret += "%send case;\n" % blank ret += ( " end Linker;\n"