Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: encode version to the header of generated files #210

Open
Mossaka opened this issue Oct 12, 2024 · 4 comments
Open

proposal: encode version to the header of generated files #210

Mossaka opened this issue Oct 12, 2024 · 4 comments
Labels
proposal Proposed changes to this repository

Comments

@Mossaka
Copy link
Member

Mossaka commented Oct 12, 2024

Essentially, replace

// Code generated by wit-bindgen-go. DO NOT EDIT.

to

// Code generated by wit-bindgen-go version v0.3.0. DO NOT EDIT.

@ydnar
Copy link
Collaborator

ydnar commented Oct 14, 2024

Because generated Go code is written to the filesystem and committed, this means that updating the version of wasm-tools-go can create (noisy) diffs for otherwise unchanged files.

Second, this is only available when examining the source code.

What if we implemented something for each generated package along the lines of Go’s debug.ReadBuildInfo(), but for generated Go packages? Thinking something along the lines of:

package cm

// BuildInfo contains debugging information about the WIT package
// and toolchain that generated a Go package.
type BuildInfo struct {
	WITPackage       string // "wasi:http"
	WITVersion       string // "0.2.0"
	Generator        string // "wit-bindgen-go"
	GeneratorVersion string // "0.3.1"
}

Then each generated Go package could have a build.go file with a single export func ReadBuildInfo() cm.BuildInfo.

@Mossaka
Copy link
Member Author

Mossaka commented Oct 15, 2024

I like the idea of reducing noisy diffs. How will this impact our release process? Do we need to bump up this version whenever we release a new version?

The release CI knows the tag version. Maybe BuildInfo could pick up the tag version at linking time and populate the GeneratorVersion field?

@ydnar
Copy link
Collaborator

ydnar commented Oct 15, 2024

We can generate this in code. The package cm struct would only be used for the API. The values would be generated in a build.go file.

@Mossaka
Copy link
Member Author

Mossaka commented Oct 15, 2024

Ah okay that makes sense!

@ydnar ydnar changed the title Encode version to the header of generated files proposal: encode version to the header of generated files Jan 19, 2025
@ydnar ydnar added the proposal Proposed changes to this repository label Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Proposed changes to this repository
Projects
None yet
Development

No branches or pull requests

2 participants