mirror of
https://github.com/micropython/micropython.git
synced 2026-04-30 21:00:12 +02:00
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>
This commit is contained in:
committed by
Damien George
parent
2c37f0612f
commit
ca85a1eb23
+5
-2
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user