-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathMakefile
More file actions
188 lines (168 loc) · 5.77 KB
/
Makefile
File metadata and controls
188 lines (168 loc) · 5.77 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
LINDFS_ROOT ?= lindfs
BUILD_DIR ?= build
SYSROOT_DIR ?= $(BUILD_DIR)/sysroot
LINDBOOT_BIN ?= $(BUILD_DIR)/lind-boot
LINDBOOT_DEBUG_BIN ?= $(BUILD_DIR)/lind-boot-debug
LINDFS_DIRS := \
bin \
dev \
etc \
lib \
sbin \
tmp \
usr/bin \
usr/lib \
usr/lib/locale \
usr/local/bin \
usr/share/zoneinfo \
var \
var/log \
var/run
WITH_FPCAST ?=
.PHONY: build
build: lindfs lind-boot sysroot
@echo "Build complete"
.PHONY: all
all: build
.PHONY: sysroot
sysroot: build-dir
./scripts/make_glibc_and_sysroot.sh $(if $(WITH_FPCAST),--with-fpcast)
$(MAKE) sync-sysroot
.PHONY: lind-boot
lind-boot: build-dir
# Build lind-boot with `--release` flag for faster runtime (e.g. for tests)
cargo build --manifest-path src/lind-boot/Cargo.toml --release
cp src/lind-boot/target/release/lind-boot $(LINDBOOT_BIN)
.PHONY: lindfs
lindfs:
@for d in $(LINDFS_DIRS); do \
mkdir -p $(LINDFS_ROOT)/$$d; \
done
touch $(LINDFS_ROOT)/dev/null
cp -rT scripts/lindfs-conf/etc $(LINDFS_ROOT)/etc
cp -rT scripts/lindfs-conf/usr/lib/locale $(LINDFS_ROOT)/usr/lib/locale
cp -rT scripts/lindfs-conf/usr/share/zoneinfo $(LINDFS_ROOT)/usr/share/zoneinfo
.PHONY: lind-debug
lind-debug: lindfs build-dir
# Build lind-boot with the lind_debug feature enabled
cargo build --manifest-path src/lind-boot/Cargo.toml --features lind_debug
cp src/lind-boot/target/debug/lind-boot $(LINDBOOT_BIN)
# Build glibc with LIND_DEBUG enabled (by setting the LIND_DEBUG variable)
$(MAKE) build_glibc LIND_DEBUG=1
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: lindfs
# Unified harness entry point (run all discovered harnesses for e2e signal)
alias_path='$(LIND_RUNTIME_LINDFS_ALIAS)'; \
prebuilt_lindfs_root='$(PREBUILT_LINDFS_ROOT)'; \
cleanup() { \
if [ -n "$$alias_path" ]; then \
alias_parent="$$(dirname "$$alias_path")"; \
rm -f "$$alias_path"; \
rmdir "$$alias_parent" 2>/dev/null || true; \
rmdir "$$(dirname "$$alias_parent")" 2>/dev/null || true; \
fi; \
}; \
if [ -n "$$alias_path" ]; then \
mkdir -p "$$(dirname "$$alias_path")"; \
rm -f "$$alias_path"; \
case '$(LINDFS_ROOT)' in \
/*) lindfs_root='$(LINDFS_ROOT)' ;; \
*) lindfs_root="$$PWD/$(LINDFS_ROOT)" ;; \
esac; \
ln -s "$$lindfs_root" "$$alias_path"; \
trap cleanup EXIT; \
fi; \
if [ -n "$$prebuilt_lindfs_root" ] && [ -d "$$prebuilt_lindfs_root/lib" ]; then \
mkdir -p "$(LINDFS_ROOT)/lib"; \
cp -a "$$prebuilt_lindfs_root/lib/." "$(LINDFS_ROOT)/lib/"; \
fi; \
if LIND_WASM_BASE=. LINDFS_ROOT=$(LINDFS_ROOT) \
python3 ./scripts/test_runner.py --export-report report.html && \
find reports -maxdepth 1 -name '*.json' -print -exec cat {} \; && \
if [ "$(LIND_DEBUG)" = "1" ]; then \
python3 ./scripts/check_reports.py --debug; \
else \
python3 ./scripts/check_reports.py; \
fi; then \
echo "E2E_STATUS=pass" > e2e_status; \
else \
echo "E2E_STATUS=fail" > e2e_status; \
mkdir -p reports; \
if [ ! -f report.html ]; then \
printf '%s\n' '<!DOCTYPE html><html><body><h1>E2E failed before report generation</h1></body></html>' > report.html; \
fi; \
if [ ! -f reports/report.html ]; then cp report.html reports/report.html; fi; \
if [ ! -f reports/wasm.json ]; then printf '%s\n' '{"number_of_failures":1,"results":[],"error":"missing wasm report"}' > reports/wasm.json; fi; \
if [ ! -f reports/grates.json ]; then printf '%s\n' '{"number_of_failures":1,"results":[],"error":"missing grate report"}' > reports/grates.json; fi; \
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 fmt --check --all --manifest-path src/lind-boot/Cargo.toml
cargo clippy \
--manifest-path src/lind-boot/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
cargo fmt --all --manifest-path src/lind-boot/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
@echo "removing build artifacts"
$(RM) -r $(BUILD_DIR)
@echo "removing lindfs root"
$(RM) -r $(LINDFS_ROOT)
@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 (lind-boot)"
cargo clean --manifest-path src/lind-boot/Cargo.toml
.PHONY: distclean
distclean: clean
@echo "removing test outputs & temp files"
$(RM) -f results.json report.html e2e_status
$(RM) -r reports || true
$(RM) -r $(LINDFS_ROOT)/testfiles || true
find tests -type f \( -name '*.wasm' -o -name '*.cwasm' -o -name '*.o' \) -delete