Skip to content

feature: add boardgen command for generating parts files.#29

Draft
deadprogram wants to merge 1 commit intomainfrom
boardgen
Draft

feature: add boardgen command for generating parts files.#29
deadprogram wants to merge 1 commit intomainfrom
boardgen

Conversation

@deadprogram
Copy link
Copy Markdown
Member

@deadprogram deadprogram commented Mar 1, 2026

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

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>
@aykevl
Copy link
Copy Markdown
Member

aykevl commented Apr 16, 2026

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.

@deadprogram
Copy link
Copy Markdown
Member Author

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.

Comment thread cmd/boardgen/main.go
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")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread cmd/boardgen/main_test.go
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@aykevl
Copy link
Copy Markdown
Member

aykevl commented Apr 17, 2026

I would like to add the ability to auto-modify an existing SVG in an updated version of this.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants