-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
108 lines (88 loc) · 2.51 KB
/
Makefile
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
ifeq (${OS}, Windows_NT)
PLATFORM = Windows
ifeq ($(PROCESSOR_ARCHITEW6432), AMD64)
ARCH = x86_64
else
ifeq ($(PROCESSOR_ARCHITECTURE), AMD64)
ARCH = x86_64
endif
ifeq ($(PROCESSOR_ARCHITECTURE), x86)
ARCH = i386
endif
endif
else
PLATFORM = $(shell uname -s)
ARCH = $(shell uname -m)
endif
ifeq (${PLATFORM}, Windows)
DYLIB_EXT = dll
endif
ifeq (${PLATFORM}, Darwin)
DYLIB_EXT = dylib
endif
ifeq (${PLATFORM}, Linux)
DYLIB_EXT = so
endif
ifeq (${RELEASE}, --release)
DYLIB_PATH=release
else
DYLIB_PATH=debug
endif
WASMTIME_TARGET_DIR := ${PWD}/target
NATIVE_TARGET_DIR := ${PWD}/target/native/${PLATFORM}/${ARCH}
WASM_TESTS := $(wildcard tests/*/Cargo.toml)
RUSTV := "+stable"
## This can be changed to the different wasm targets
# WASM_TARGET := wasm32-unknown-unknown
WASM_TARGET := wasm32-wasi
.PHONY: init
init:
@echo "====> Testing for all tools"
@mvn -version || (echo maven is required, e.g. 'brew install maven' && mvn -version)
@cargo ${RUSTV} --version || (echo rust is required, e.g. 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh' && cargo --version)
rustup target add ${WASM_TARGET}
.PHONY: clean
clean:
@echo "====> Cleaning"
cd wasmtime-jni && cargo clean
mvn clean
target/native:
@echo "====> Building wasmtime-jni for ${PLATFORM} arch ${ARCH}"
cd wasmtime-jni && cargo ${RUSTV} build ${RELEASE} --lib
@mkdir -p ${NATIVE_TARGET_DIR}
@cp -rpf ${WASMTIME_TARGET_DIR}/${DYLIB_PATH}/*.${DYLIB_EXT} ${NATIVE_TARGET_DIR}/
.PHONY: build
build:
@echo "====> Building"
cd wasmtime-jni && cargo ${RUSTV} build ${RELEASE} --lib
$(MAKE) ${WASM_TESTS}
rm -rf ${PWD}/target/native
$(MAKE) mvn-compile
.PHONY: ${WASM_TESTS}
${WASM_TESTS}:
@echo "====> Building $(dir $@)"
cd $(dir $@) && cargo ${RUSTV} build --target ${WASM_TARGET}
.PHONY: test
test: build
@echo "====> Testing"
cd wasmtime-jni && cargo ${RUSTV} test ${RELEASE}
$(MAKE) mvn-test
.PHONY: mvn-test
mvn-test: target/native
PLATFORM=${PLATFORM} ARCH=${ARCH} mvn verify
.PHONY: mvn-compile
mvn-compile: target/native
PLATFORM=${PLATFORM} ARCH=${ARCH} mvn compile
.PHONY: package
package: build
PLATFORM=${PLATFORM} ARCH=${ARCH} mvn package
.PHONY: install
install:
RELEASE=--release make package
PLATFORM=${PLATFORM} ARCH=${ARCH} mvn install
.PHONY: cleanliness
cleanliness:
cargo ${RUSTV} clean -p wasmtime-jni -p wasmtime-jni-exports -p math -p slices -p strings
cargo ${RUSTV} clippy -- -D warnings
cargo ${RUSTV} fmt -- --check
cargo ${RUSTV} audit