Skip to content

gen-device: only generate device files for supported devices#5456

Open
niaow wants to merge 1 commit into
tinygo-org:devfrom
niaow:only-used-devices
Open

gen-device: only generate device files for supported devices#5456
niaow wants to merge 1 commit into
tinygo-org:devfrom
niaow:only-used-devices

Conversation

@niaow

@niaow niaow commented Jun 9, 2026

Copy link
Copy Markdown
Member

This changes the make gen-device command such that it only converts relevant device files. This saves a lot of build time.

The process of determining which files to convert is now handled by make. Incremental builds are now supported.
Appropriate parallel building is now done for all device generation (previously it was only handled properly for AVR).

The generated file names were updated to match their source name formatting. I could probbably lowercase everything when converting them, but this would complicate the makefile. I don't really think this is worth it.

This changes the make gen-device command such that it only converts relevant device files.
This saves a lot of build time.

The process of determining which files to convert is now handled by make.
Incremental builds are now supported.
Appropriate parallel building is now done for all device generation (previously it was only handled properly for AVR).

The generated file names were updated to match their source name formatting.
I could probbably lowercase everything when converting them, but this would complicate the makefile.
I don't really think this is worth it.
@niaow

niaow commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

Before:

real    0m48.662s
user    6m5.821s
sys     0m42.683s
539505021 total

After:

real    0m1.934s
user    0m26.767s
sys     0m3.649s
77640936 total

This is much faster and it reduces the storage used by device files by 86%.

}

func formatText(text string) string {
text = regexp.MustCompile(`[ \t\n]+`).ReplaceAllString(text, " ") // Collapse whitespace (like in HTML)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might not be in scope of this actual PR but I stumbled across this some time ago - this regex is unnecessarily compiled multiple times

@dgryski dgryski left a comment

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.

Seems reasonable, although I'll leave it to someone who actually deals with this files for the final word.

@deadprogram

Copy link
Copy Markdown
Member

The generated file names were updated to match their source name formatting. I could probbably lowercase everything when converting them, but this would complicate the makefile. I don't really think this is worth it.

I think we should probably preserve the lowercase file names if we can to avoid case issues on OS like Windows.

@niaow

niaow commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

The generated file names were updated to match their source name formatting. I could probbably lowercase everything when converting them, but this would complicate the makefile. I don't really think this is worth it.

I think we should probably preserve the lowercase file names if we can to avoid case issues on OS like Windows.

I am not entirely sure what you mean by this. I understand that Windows is case-insensitive, but we are just matching the source case here?

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.

4 participants