-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathMakefile
More file actions
127 lines (105 loc) · 3.4 KB
/
Makefile
File metadata and controls
127 lines (105 loc) · 3.4 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
LIND_ROOT ?= src/tmp
BUILD_DIR ?= build
SYSROOT_DIR ?= $(BUILD_DIR)/sysroot
WASMTIME_BIN ?= $(BUILD_DIR)/wasmtime
WASMTIME_DEBUG_BIN ?= $(BUILD_DIR)/wasmtime-debug
.PHONY: build
build: sysroot wasmtime
@echo "Build complete"
.PHONY: prepare-lind-root
prepare-lind-root:
mkdir -p $(LIND_ROOT)/dev
touch $(LIND_ROOT)/dev/null
.PHONY: all
all: build
.PHONY: sysroot
sysroot: build-dir
./scripts/make_glibc_and_sysroot.sh
$(MAKE) sync-sysroot
.PHONY: wasmtime
wasmtime: build-dir
# Build wasmtime with `--release` flag for faster runtime (e.g. for tests)
cargo build --manifest-path src/wasmtime/Cargo.toml --release
cp src/wasmtime/target/release/wasmtime $(WASMTIME_BIN)
.PHONY: lind-debug
lind-debug: build-dir
# Build glibc with LIND_DEBUG enabled (by setting the LIND_DEBUG variable)
$(MAKE) build_glibc LIND_DEBUG=1
# Build Wasmtime with the lind_debug feature enabled
cargo build --manifest-path src/wasmtime/Cargo.toml --features lind_debug
cp src/wasmtime/target/debug/wasmtime $(WASMTIME_BIN)
build_glibc:
# build sysroot passing -DLIND_DEBUG if LIND_DEBUG is set
if [ "$(LIND_DEBUG)" = "1" ]; then \
echo "Building glibc with LIND_DEBUG enabled"; \
./scripts/make_glibc_and_sysroot.sh; \
$(MAKE) sync-sysroot; \
fi
.PHONY: build-dir
build-dir:
mkdir -p $(BUILD_DIR)
.PHONY: sync-sysroot
sync-sysroot:
$(RM) -r $(SYSROOT_DIR)
cp -R src/glibc/sysroot $(SYSROOT_DIR)
.PHONY: test
test: prepare-lind-root
# NOTE: `grep` workaround required for lack of meaningful exit code in wasmtestreport.py
LIND_WASM_BASE=. LIND_ROOT=$(LIND_ROOT) \
./scripts/wasmtestreport.py && \
cat results.json; \
if grep -q '"number_of_failures": [^0]' results.json; then \
echo "E2E_STATUS=fail" > e2e_status; \
else \
echo "E2E_STATUS=pass" > e2e_status; \
fi; \
exit 0
.PHONY: md_generation
OUT ?= .
REPORT ?= report.html
md_generation:
python3 -m pip install --quiet jinja2
REPORT_PATH=$(REPORT) OUT_DIR=$(OUT) python3 scripts/render_e2e_templates.py
@echo "Wrote $(OUT)/e2e_comment.md"
.PHONY: lint
lint:
cargo fmt --check --all --manifest-path src/wasmtime/Cargo.toml
cargo clippy \
--manifest-path src/wasmtime/Cargo.toml \
--all-features \
--keep-going \
-- \
-A warnings \
-A clippy::not_unsafe_ptr_arg_deref \
-A clippy::absurd_extreme_comparisons
.PHONY: format
format:
cargo fmt --all --manifest-path src/wasmtime/Cargo.toml
.PHONY: docs-serve
docs-serve:
mkdocs serve
.PHONY: clean
clean:
@echo "cleaning glibc artifacts"
# Remove only generated sysroot and intermediate .o files,
# but KEEP required objects used by subsequent builds.
$(RM) -r src/glibc/sysroot
@find src/glibc -type f -name '*.o' \
! -path 'src/glibc/csu/wasm32/wasi_thread_start.o' \
! -path 'src/glibc/target/lib/Mcrt1.o' \
! -path 'src/glibc/target/lib/Scrt1.o' \
! -path 'src/glibc/target/lib/crt1.o' \
! -path 'src/glibc/target/lib/crti.o' \
! -path 'src/glibc/target/lib/crtn.o' \
! -path 'src/glibc/target/lib/gcrt1.o' \
! -path 'src/glibc/target/lib/grcrt1.o' \
! -path 'src/glibc/target/lib/rcrt1.o' \
-exec rm -f {} +
@echo "cargo clean (wasmtime)"
cargo clean --manifest-path src/wasmtime/Cargo.toml
.PHONY: distclean
distclean: clean
@echo "removing test outputs & temp files"
$(RM) -f results.json report.html e2e_status
$(RM) -r $(LIND_ROOT)/testfiles || true
find tests -type f \( -name '*.wasm' -o -name '*.cwasm' -o -name '*.o' \) -delete