-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
82 lines (69 loc) · 2.35 KB
/
Makefile
File metadata and controls
82 lines (69 loc) · 2.35 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
FEATURES := \
min-usize-32 \
min-usize-64 \
from_usize \
min-usize-32,from_usize \
min-usize-64,from_usize
DOC_FEATURES_32 := min-usize-32,from_usize
DOC_FEATURES_64 := min-usize-64,from_usize
TARGET_POINTER_WIDTH := $(shell cargo rustc -q -- --print cfg | sed -n 's/^target_pointer_width="\([0-9]*\)"/\1/p')
MSRV := $(shell sed -n 's/^rust-version *= *"\(.*\)"/\1/p' Cargo.toml)
ifeq ($(TARGET_POINTER_WIDTH),32)
DOC_FEATURES := $(DOC_FEATURES_32)
else
DOC_FEATURES := $(DOC_FEATURES_64)
endif
.PHONY: all clean test doctest clippy fmt ci doc check-msrv-badge
all: ci
clean:
cargo clean
test:
@for f in $(FEATURES); do \
case "$(TARGET_POINTER_WIDTH):$$f" in \
32:min-usize-64|32:min-usize-64,from_usize) \
echo "expect fail: cargo check --features $$f"; \
if cargo check --features "$$f" >/dev/null 2>&1; then \
echo "Expected failure for $$f on $(TARGET_POINTER_WIDTH)-bit target"; \
exit 1; \
else \
echo "Got expected failure for $$f on $(TARGET_POINTER_WIDTH)-bit target"; \
fi; \
;; \
*) \
echo "expect pass: cargo test --lib --features $$f"; \
cargo test --lib --features "$$f"; \
;; \
esac; \
done; \
cargo check --no-default-features
doctest:
cargo test --doc --features "$(DOC_FEATURES)"
clippy:
@for f in $(FEATURES); do \
case "$(TARGET_POINTER_WIDTH):$$f" in \
32:min-usize-64|32:min-usize-64,from_usize) \
echo "expect fail: cargo clippy --features $$f"; \
if cargo clippy --features "$$f" -- -D warnings >/dev/null 2>&1; then \
echo "Expected clippy failure for $$f on $(TARGET_POINTER_WIDTH)-bit target"; \
exit 1; \
else \
echo "Got expected clippy failure for $$f on $(TARGET_POINTER_WIDTH)-bit target"; \
fi; \
;; \
*) \
echo "expect pass: cargo clippy --features $$f"; \
cargo clippy --features "$$f" -- -D warnings; \
;; \
esac; \
done; \
cargo clippy --no-default-features -- -D warnings
fmt:
cargo fmt --check
ci: fmt clippy check-msrv-badge test doctest
doc:
cargo doc --features "$(DOC_FEATURES)" --no-deps --open
check-msrv-badge:
@grep -q "^\[MSRV\]: https://img.shields.io/badge/MSRV-$(MSRV)-blue" README.md || \
( echo "MSRV badge mismatch (Cargo.toml: $(MSRV))"; exit 1 )
@grep -q "^\[rust_rel\]: https://blog.rust-lang.org/.*/Rust-$(MSRV)\.0/" README.md || \
( echo "Rust release link mismatch (Cargo.toml: $(MSRV))"; exit 1 )