Skip to content

Commit

Permalink
Try #40:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored Aug 17, 2020
2 parents 0e9bfcd + b2a8220 commit 3b909d5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
23 changes: 19 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,32 @@ build-runtime:
case "{{os()}}" in
"macos")
shared_library_path=$( ls -t target/release/deps/libwasmer_runtime_c_api*.dylib | head -n 1 )
shared_library=libwasmer_runtime_c_api.dylib
static_library_path=$( ls -t target/release/deps/libwasmer_runtime_c_api*.a | head -n 1 )
shared_library=libwasmer.dylib
static_library=libwasmer.a
;;
"windows")
shared_library_path=$( ls -t target/release/deps/wasmer_runtime_c_api*.dll | head -n 1 )
shared_library=wasmer_runtime_c_api.dll
static_library_path=$( ls -t target/release/deps/wasmer_runtime_c_api*.lib | head -n 1 )
shared_library=wasmer.dll
static_library=wasmer.lib
;;
*)
shared_library_path=$( ls -t target/release/deps/libwasmer_runtime_c_api*.so | head -n 1 )
shared_library=libwasmer_runtime_c_api.so
static_library_path=$( ls -t target/release/deps/libwasmer_runtime_c_api*.a | head -n 1 )
shared_library=libwasmer.so
static_library=libwasmer.a
esac

# Link `wasmer/*wasmer_runtime_c_api.*`.
rm -f wasmer/${shared_library}
ln -s "../${shared_library_path}" wasmer/${shared_library}
rm -f wasmer/static/${static_library}
ln -s "../../${static_library_path}" wasmer/static/${static_library}

# Build the `wasmer` library.
build go-build-args='-v':
cd wasmer && go build {{go-build-args}} .
cd wasmer && go build {{go-build-args}} . && go build {{go-build-args}} -tags "static_build" .

# Build the `go-wasmer` bin.
build-bin go-build-args='-v':
Expand Down Expand Up @@ -55,6 +63,13 @@ test:
# Run the long examples.
go test -test.v $(find . -type f \( -name "example_*_test.go" \! -name "_example_import_test.go" \) )
# Run the tests using static lib.
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" \) )

# 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
// #include "./wasmer.h"
//
import "C"
Expand Down
Binary file added wasmer/static/libwasmer.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
import "C"
7 changes: 7 additions & 0 deletions wasmer/wasmer_link_static.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// +build static_build

package wasmer

// #cgo !darwin LDFLAGS: -L${SRCDIR}/static -lwasmer -lm -ldl -lrt
// #cgo darwin LDFLAGS: -L${SRCDIR}/static -lwasmer -lm -ldl
import "C"

0 comments on commit 3b909d5

Please sign in to comment.