Skip to content

Commit

Permalink
Make build directories as valid (empty) go packages. (#45)
Browse files Browse the repository at this point in the history
go mod vendor will not copy the header and library directory contents
not referred in any go source code. A common workaround is to add "_"
imports to such directories with necessary cgo files, but doing so
requires rendering such directories as valid go packages. This patch
does exactly that.

With this patch, one can vendor the C headers and libraries by
introducing the following imports in the code using the wasmtime-go
bindings.

import (
	_ "github.com/bytecodealliance/wasmtime-go/build/include"
        _ "github.com/bytecodealliance/wasmtime-go/build/linux-x86_64"
        _ "github.com/bytecodealliance/wasmtime-go/build/macos-x86_64"
        _ "github.com/bytecodealliance/wasmtime-go/build/windows-x86_64"
)

Optionally, one could consider introducing these imports to the
"github.com/bytecodealliance/wasmtime-go" package itself.

For more information about the underlying limitation of vendoring, see
for example: golang/go#26366
  • Loading branch information
koponen-styra authored Nov 25, 2020
1 parent 986b514 commit e5fed01
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions build/include/empty.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package include
1 change: 1 addition & 0 deletions build/linux-x86_64/empty.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package linux_x86_64
1 change: 1 addition & 0 deletions build/macos-x86_64/empty.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package macos_x86_64
1 change: 1 addition & 0 deletions build/windows-x86_64/empty.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package windows_x86_64

0 comments on commit e5fed01

Please sign in to comment.