Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
76 lines (57 loc) · 2.37 KB
/
Copy pathMakefile
File metadata and controls
76 lines (57 loc) · 2.37 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
# Everyday tasks. Nothing here is needed to use the crate from Rust: cargo
# builds it. The guest library and the test programs need wasixcc
# (https://github.com/wasix-org/wasixcc).
CARGO ?= cargo
PYTHON ?= python3
WASIXCC ?= wasixcc
ifeq ($(shell command -v $(WASIXCC) 2>/dev/null),)
WASIXCC := $(HOME)/.wasixcc/bin/wasixcc
endif
EXAMPLES := $(patsubst examples/%.c,examples/out/%.wasm,$(wildcard examples/*.c))
VERSION := $(shell sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
DIST := dist/wasmer-webgpu-guest-$(VERSION)
.PHONY: all guest programs examples dist gen check fmt lint check-web test test-native test-browser clean
all: guest examples
## What guests link: lib/wasm32-wasix/libwebgpu.a
guest:
guest/build.sh
## The conformance programs: tests/programs/out/*.wasm
programs: guest
tests/build-test-wasix.sh
examples: $(EXAMPLES)
examples/out/%.wasm: examples/%.c guest
@mkdir -p examples/out
$(WASIXCC) --target=wasm32-wasix -O2 -Wall -Wextra -Werror $< -Iinclude -Llib/wasm32-wasix -lwebgpu -o $@
## What a guest toolchain needs, as one archive: the headers and the library.
dist: guest
rm -rf $(DIST) && mkdir -p $(DIST)/include/webgpu $(DIST)/lib/wasm32-wasix
cp include/webgpu/webgpu.h include/webgpu/webgpu_wasix.h $(DIST)/include/webgpu/
cp lib/wasm32-wasix/libwebgpu.a $(DIST)/lib/wasm32-wasix/
cp LICENSE NOTICE.md $(DIST)/
tar -czf $(DIST).tar.gz -C dist $(notdir $(DIST))
@echo "$(DIST).tar.gz"
## Regenerate everything derived from spec/ (the results are checked in).
gen:
$(PYTHON) codegen/gen.py
## What CI holds a change to, short of running it on a GPU.
check: lint check-web
$(PYTHON) codegen/gen.py --check
$(CARGO) fmt --check
fmt:
$(CARGO) fmt
lint:
$(CARGO) clippy --features cli,window --all-targets -- -D warnings
## The browser half of the crate, as the Wasmer SDK compiles it.
check-web:
$(CARGO) check --target wasm32-unknown-unknown --no-default-features --features js,wasix
test: test-native
## Unit tests, the ABI sweep, the conformance programs and the embedder tests.
## WEBGPU_TEST_FALLBACK_ADAPTER=1 runs them on a software adapter.
test-native: programs
$(CARGO) test --features cli
## The conformance programs against js/webgpu_host.js, in the installed Chrome.
test-browser: programs
cd tests/browser && npm install --no-audit --no-fund && node run.mjs --no-build
clean:
$(CARGO) clean
rm -rf lib dist tests/programs/out examples/out