This repository has been archived by the owner on Jun 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
59 lines (44 loc) · 1.5 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
RUSTUP = rustup
FMT_TOOLCHAIN = nightly-2020-01-15
FMT_CARGO = $(RUSTUP) run --install $(FMT_TOOLCHAIN) cargo --color always
TOOLCHAIN = $(shell cat rust-toolchain)
CARGO = $(RUSTUP) run --install $(TOOLCHAIN) cargo --color always
INSTALLED_COMPONENTS = $(shell $(RUSTUP) component list --installed --toolchain $(TOOLCHAIN))
FMT_INSTALLED_COMPONENTS = $(shell $(RUSTUP) component list --installed --toolchain $(FMT_TOOLCHAIN))
install_rust_fmt:
ifeq (,$(findstring $(FMT_TOOLCHAIN),$(INSTALLED_TOOLCHAINS)))
$(RUSTUP) install $(FMT_TOOLCHAIN)
endif
ifeq (,$(findstring rustfmt,$(FMT_INSTALLED_COMPONENTS)))
$(RUSTUP) component add rustfmt --toolchain $(FMT_TOOLCHAIN)
endif
install_rust:
ifeq (,$(findstring $(TOOLCHAIN),$(INSTALLED_TOOLCHAINS)))
$(RUSTUP) install $(TOOLCHAIN)
endif
install_clippy: install_rust
ifeq (,$(findstring clippy,$(INSTALLED_COMPONENTS)))
$(RUSTUP) component add clippy --toolchain $(TOOLCHAIN)
endif
install_wasm_pack:
which wasm-pack || $(CARGO) install wasm-pack
format: install_rust_fmt
$(FMT_CARGO) fmt -- --files-with-diff
check_format: install_rust_fmt
$(FMT_CARGO) fmt -- --check
build: install_wasm_pack
mkdir -p ./pkg/
cp ./static/* ./pkg/
wasm-pack build --debug --target web --out-name wasm
build_release: install_wasm_pack
mkdir -p ./pkg/
cp ./static/* ./pkg/
wasm-pack build --target web --out-name wasm
serve:
python3 -m http.server --directory pkg
clippy: install_clippy
$(CARGO) clippy --all-targets -- -D warnings
clean:
$(CARGO) clean
test:
$(CARGO) test