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

wit: sort packages in topological order when rendering WIT #208

Merged
merged 18 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

- Method `wit.(*Package).WIT()` now interprets the non-empty string `name` argument as signal to render in single-file, multi-package braced form.
- `wit.(*Resolve).WIT()` and `wit.(*Package).WIT()` now accept a `*wit.World` as context to filter serialized WIT to a specific world.
- Packages are now sorted topologically by dependency in generated WIT files. For example, `wasi:cli` would be followed by its dependencies like `wasi:io`, `wasi:filesystem`, or `wasi:random`.

## [v0.2.4] — 2024-10-06

Expand Down Expand Up @@ -165,7 +166,7 @@ Initial version, supporting [TinyGo](https://tinygo.org/) + [WASI](https://wasi.
- Support for mainline [Go](https://go.dev/).

[Unreleased]: <https://github.com/bytecodealliance/wasm-tools-go/compare/v0.2.4..HEAD>
[v0.2.3]: <https://github.com/bytecodealliance/wasm-tools-go/compare/v0.2.3..v0.2.4>
[v0.2.4]: <https://github.com/bytecodealliance/wasm-tools-go/compare/v0.2.3..v0.2.4>
[v0.2.3]: <https://github.com/bytecodealliance/wasm-tools-go/compare/v0.2.2..v0.2.3>
[v0.2.2]: <https://github.com/bytecodealliance/wasm-tools-go/compare/v0.2.1..v0.2.2>
[v0.2.1]: <https://github.com/bytecodealliance/wasm-tools-go/compare/v0.2.0...v0.2.1>
Expand Down
2 changes: 1 addition & 1 deletion cmd/wit-bindgen-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func main() {

err := cmd.Run(context.Background(), os.Args)
if err != nil {
fmt.Printf("error: %v\n", err)
fmt.Fprintf(os.Stderr, "error: %v\n", err)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is unrelated to the PR, but a bug I caught when debugging the new logic.

os.Exit(1)
}
}
2 changes: 1 addition & 1 deletion internal/witcli/witcli.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func LoadWIT(ctx context.Context, forceWIT bool, path string) (*wit.Resolve, err
return wit.ParseWIT(bytes)
}
}
if forceWIT || !strings.HasSuffix(path, ".json") {
if forceWIT || (path != "" && path != "-" && !strings.HasSuffix(path, ".json")) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Another logic bug that was forced WIT parsing of stdin.

return wit.LoadWIT(path)
}
return wit.LoadJSON(path)
Expand Down
Loading