Skip to content

Commit

Permalink
feat(go-bindgen)!: generate non-test bindings by default
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Volosatovs <[email protected]>
  • Loading branch information
rvolosatovs committed Sep 27, 2024
1 parent a9316e0 commit 93812a2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
*.wasm
*.a
*.lib
wadge_bindings_test.go
bindings.wadge.go
/go/internal/tests/*/bindings/*
2 changes: 2 additions & 0 deletions bindings/bindings.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions cmd/wadge-bindgen-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

var (
output = flag.String("output", "wadge_bindings_test.go", "output file path from the root of the package directory")
output = flag.String("output", "bindings.wadge.go", "output file path from the root of the package directory")
gofmt = flag.Bool("gofmt", true, "whether to format the generated code")
pkgName = flag.String("package", "", "package name, defaults to test package at path specified")

Expand Down Expand Up @@ -455,7 +455,7 @@ func generate(path string) error {
}
name := *pkgName
if name == "" {
name = fmt.Sprintf("%s_test", pkg.Name)
name = pkg.Name
}
importSpecs := []*ast.ImportSpec{
{
Expand Down Expand Up @@ -513,7 +513,11 @@ func generate(path string) error {
decls = append(decls, wi.decl)
}
var buf bytes.Buffer
buf.WriteString("// Code generated by wadge-bindgen-go DO NOT EDIT\n\n")
buf.WriteString(`//go:build !wasm && !wasi && !wasip1 && !wasip2 && !wasm_unknown && !tinygo.wasm
// Code generated by wadge-bindgen-go DO NOT EDIT
`)
f := &ast.File{
Name: &ast.Ident{Name: name},
Imports: importSpecs,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 93812a2

Please sign in to comment.