feature: add boardgen command for generating parts files.#29
feature: add boardgen command for generating parts files.#29deadprogram wants to merge 1 commit intomainfrom
Conversation
This adds a Go utility that generates SVG and JSON files for adding a new board to the TinyGo Playground simulator parts library. Signed-off-by: deadprogram <ron@hybridgroup.com>
|
Not necessarily opposed to this, but wouldn't it be easier to just copy an existing SVG file and modify it? The thing that took a lot of time was special boards like the Circuit Playground, not the standard rectangular ones. |
I would like to add the ability to auto-modify an existing SVG in an updated version of this. Mainly I was trying to semi-automate a rather tedious process. |
| w := func(f string, a ...any) { fmt.Fprintf(&b, f, a...) } | ||
|
|
||
| w("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n") | ||
| w("<!-- Generated by boardgen for the TinyGo Playground simulator. -->\n") |
There was a problem hiding this comment.
Suggestion: add the parameters used to generate this file in the file itself, to make it easier to later re-generate with slightly different parameters.
There was a problem hiding this comment.
This file has no indentation??
Also, while I'm normally a big fan of extensive testing, in this case it doesn't seem super necessary? You'd need to manually review the generated files afterwards anyway.
Or, alternative idea: instead of doing unit test you could have a few "gold tests" where you generate files with particular parameters and test that they match. Similar to compiler/testdata/ tests for exaple. (That also makes it a bit easier to review this PR because it's possible to see what it is generating and whether it makes sense). I think that would be more practical and clearly show changes over time instead of having to dig through the test files when boardgen gets updated.
Anyway, I'll leave it up to you - just some ideas.
If we do this, those can also be used as test cases! That would certainly validate that any future changes to the code do not have unintentional side effects. |
This adds an experimental Go utility that generates SVG and JSON files for adding a new board to the TinyGo Playground simulator parts library.
Pico-like board (horizontal, 20 pins top/bottom, USB on the left, built-in LED):
boardgen \ -name my-pico \ -human "My Pico Board" \ -pins-top 20 -pins-bottom 20 \ -usb left -led \ -output ./parts