Skip to content

Commit ca85a1e

Browse files
agattidpgeorge
authored andcommitted
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 <a.gatti@frob.it>
1 parent 2c37f06 commit ca85a1e

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

tools/boardgen.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,10 @@ def load_inputs(self, out_source):
475475
def generate_extra_files(self):
476476
pass
477477

478+
def print_pin_source(self, out_source):
479+
for pin in self.available_pins():
480+
pin.print_source(out_source)
481+
478482
def main(self):
479483
parser = argparse.ArgumentParser(description="Generate board specific pin file")
480484
parser.add_argument("--board-csv")
@@ -495,8 +499,7 @@ def main(self):
495499
self.load_inputs(out_source)
496500

497501
# Allow a port to print arbitrary per-pin content.
498-
for pin in self.available_pins():
499-
pin.print_source(out_source)
502+
self.print_pin_source(out_source)
500503

501504
# Print the tables and dictionaries.
502505
self.print_source(out_source)

0 commit comments

Comments
 (0)