From ca85a1eb2393d5e6173405f0051369bb1572e83c Mon Sep 17 00:00:00 2001 From: Alessandro Gatti Date: Mon, 20 Apr 2026 18:23:14 +0200 Subject: [PATCH] tools/boardgen.py: Make per-pin content output extensible. This commit lets classes extending the base `PinGenerator` class to override the process of generating extra per-pin content when creating the pins' information source file. There are cases in which one may want to have more control on the part of the source generation process that dumps additional per-pin information to the source file. The current approach works fine if each pin generates self-contained additional data to be placed in the source file, but there is no clean way to provide a prologue or an epilogue to that content. For example, if one wants to emit a single consolidated additional pin data table it is not that convenient to be able to consistently emit the table start definition and the table end markers. With these changes all one has to do to achieve this is to override `PinGenerator.print_pin_source` in their PinGenerator-derived class to either wrap the output or to replace what is being output altogether. Signed-off-by: Alessandro Gatti --- tools/boardgen.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/boardgen.py b/tools/boardgen.py index 3723e7ce31..6b295f484f 100644 --- a/tools/boardgen.py +++ b/tools/boardgen.py @@ -475,6 +475,10 @@ class PinGenerator: def generate_extra_files(self): pass + def print_pin_source(self, out_source): + for pin in self.available_pins(): + pin.print_source(out_source) + def main(self): parser = argparse.ArgumentParser(description="Generate board specific pin file") parser.add_argument("--board-csv") @@ -495,8 +499,7 @@ class PinGenerator: self.load_inputs(out_source) # Allow a port to print arbitrary per-pin content. - for pin in self.available_pins(): - pin.print_source(out_source) + self.print_pin_source(out_source) # Print the tables and dictionaries. self.print_source(out_source)