Skip to content

Commit

Permalink
Merge #40
Browse files Browse the repository at this point in the history
40: Add static build when tag "static_build" is used r=Hywan a=yaslama



Co-authored-by: Yaacov Akiba Slama <[email protected]>
  • Loading branch information
bors[bot] and yaslama committed Aug 14, 2019
2 parents 605a12a + eb5b2ec commit 64d0276
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
18 changes: 18 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@ build go-build-args='-v':
;;
*)
dylib_extension="so"
staticlib_extension="a"
esac
if ! test -f libwasmer_runtime_c_api.${dylib_extension}; then
cargo build --release
ln -s ../target/release/deps/libwasmer_runtime_c_api-*.${dylib_extension} libwasmer_runtime_c_api.${dylib_extension}
fi
go build {{go-build-args}} .
if test -n "${staticlib_extension}"; then
if ! test -f libwasmer_runtime_c_api.${staticlib_extension}; then
cargo build --release
ln -s ../target/release/deps/libwasmer_runtime_c_api-*.${staticlib_extension} libwasmer_runtime_c_api.${staticlib_extension}
fi
go build {{go-build-args}} -tags "static_build" .
fi
# Build the `go-wasmer` bin.
build-bin go-build-args='-v':
cd go-wasmer && go build {{go-build-args}} -o ../target/go/go-wasmer .
Expand All @@ -45,6 +54,15 @@ test:
# Run the long examples.
go test -test.v $(find . -type f \( -name "example_*_test.go" \! -name "_example_import_test.go" \) )
if test -f libwasmer_runtime_c_api.a; then
# Run the tests.
GODEBUG=cgocheck=2 go test -tags "static_build" -test.v $(find test -type f \( -name "*_test.go" \! -name "example_*.go" \! -name "benchmark*.go" \) ) test/imports.go
# Run the short examples.
go test -tags "static_build" -test.v example_test.go
# Run the long examples.
go test -tags "static_build" -test.v $(find . -type f \( -name "example_*_test.go" \! -name "_example_import_test.go" \) )
fi
# Run benchmarks. Subjects can be `wasmer`, `wagon` or `life`. Filter is a regex to select the benchmarks.
bench subject='wasmer' filter='.*':
cd benchmarks/{{subject}} && go test -bench '{{filter}}' benchmarks_test.go
Expand Down
1 change: 0 additions & 1 deletion wasmer/bridge.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package wasmer

// #cgo LDFLAGS: -Wl,-rpath,${SRCDIR} -L${SRCDIR} -lwasmer_runtime_c_api
// #include "./wasmer.h"
//
import "C"
Expand Down
Binary file added wasmer/libwasmer_runtime_c_api.a
Binary file not shown.
6 changes: 6 additions & 0 deletions wasmer/wasmer_link_dynamic.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// +build !static_build

package wasmer

// #cgo LDFLAGS: -Wl,-rpath,${SRCDIR} -L${SRCDIR} -lwasmer_runtime_c_api
import "C"
6 changes: 6 additions & 0 deletions wasmer/wasmer_link_static.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// +build static_build

package wasmer

// #cgo LDFLAGS: -lm -ldl -lrt -L${SRCDIR} -l:libwasmer_runtime_c_api.a
import "C"

0 comments on commit 64d0276

Please sign in to comment.