This repository has been archived by the owner on Oct 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjustfile
82 lines (69 loc) · 1.78 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Change the dynamic link to a relative one,
# for breaking the dependency with the previous file path.
# The relative path will be adjusted by cgo.
fix-path:
#!/usr/bin/env bash
set -euo pipefail
case "{{os()}}" in
"macos")
shared_library=libsvm_runtime_c_api.dylib
install_name_tool -id "@rpath/${shared_library}" svm/${shared_library}
echo "{{os()}}: lib path fixed to @rpath/${shared_library}"
;;
"windows")
echo "{{os()}}: no fix is required"
exit 1
;;
*)
echo "{{os()}}: no fix is required"
exit 1
esac
# Fetch pre-compiled libs for all platforms from github.com/spacemeshos/svm CI.
fetch-artifacts branch token:
#!/usr/bin/env bash
set -euo pipefail
dest=$(pwd)/svm
pushd cmd/fetch_artifacts
go build && ./fetch_artifacts -branch={{branch}} -token={{token}} -dest=$dest
popd
# Re-build SVM on your platform.
build-svm:
#!/usr/bin/env bash
set -euo pipefail
pushd svm-dep
cargo +nightly build --release
popd
rm -f svm/svm.h
cp svm-dep/target/release/svm.h svm/svm.h
case "{{os()}}" in
"macos")
shared_library_path=$( ls -t svm-dep/target/release/deps/libsvm_runtime_c_api*.dylib | head -n 1 )
shared_library=libsvm_runtime_c_api.dylib
rm -f svm/${shared_library}
cp ${shared_library_path} svm/${shared_library}
;;
"windows")
echo "{{os()}}: local build not supported yet"
exit 1
;;
*)
echo "{{os()}}: local build not supported yet"
exit 1
esac
# Run all the tests.
test:
just example
GODEBUG=cgocheck=2 go test ./... -v
# Run the example.
example:
#!/usr/bin/env bash
set -euo pipefail
pushd examples/counter/wasm
./build.sh
popd
pushd examples/counter
go build && ./counter
popd
# Generate cgo debug objects.
debug-cgo:
cd svm && go tool cgo bridge.go && cd _obj && ls -d "$PWD/"*