forked from Wandalen/wTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
151 lines (116 loc) · 2.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
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
# abc def
# === common
#
# Comma
comma := ,
# Checks two given strings for equality.
eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\
$(findstring $(2),$(1))),1)
#
# === Parameters
#
VERSION ?= $(strip $(shell grep -m1 'version = "' Cargo.toml | cut -d '"' -f2))
#
# === Git
#
# Sync local repostiry.
#
# Usage :
# make git.sync [message='description of changes']
git.sync :
git add --all && git commit -am $(message) && git pull
sync : git.sync
#
# === External cargo crates commands
#
# Check vulnerabilities with cargo-audit.
#
# Usage :
# make audit
audit :
cargo audit
#
# === General commands
#
# Generate crates documentation from Rust sources.
#
# Usage :
# make doc [private=(yes|no)] [open=(yes|no)] [clean=(no|yes)] [manifest_path=(|[path])]
doc :
ifeq ($(clean),yes)
@rm -rf target/doc/
endif
cargo doc --all-features \
$(if $(call eq,$(private),no),,--document-private-items) \
$(if $(call eq,$(manifest_path),),--manifest-path ./Cargo.toml,--manifest-path $(manifest_path)) \
$(if $(call eq,$(open),no),,--open)
# Lint Rust sources with Clippy.
#
# Usage :
# make lint [warnings=(no|yes)] [manifest_path=(|[path])]
lint :
cargo clippy --all-features \
$(if $(call eq,$(manifest_path),),--manifest-path ./Cargo.toml,--manifest-path $(manifest_path)) \
$(if $(call eq,$(warnings),no),-- -D warnings,)
# Check Rust sources `check`.
#
# Usage :
# make check [manifest_path=(|[path])]
check :
cargo check \
$(if $(call eq,$(manifest_path),),--manifest-path ./Cargo.toml,--manifest-path $(manifest_path))
# Format and lint Rust sources.
#
# Usage :
# make normalize
normalize : fmt lint
# Perform common checks on the module.
#
# Usage :
# make checkmate
checkmate : doc lint check
# Format Rust sources with rustfmt.
#
# Usage :
# make fmt [check=(no|yes)]
fmt :
{ find -L module -name *.rs -print0 ; } | xargs -0 rustfmt +nightly $(if $(call eq,$(check),yes),-- --check,)
# cargo +nightly fmt --all $(if $(call eq,$(check),yes),-- --check,)
# Run project Rust sources with Cargo.
#
# Usage :
# make up
up :
cargo up
# Run project Rust sources with Cargo.
#
# Usage :
# make clean
clean :
cargo clean && rm -rf Cargo.lock && cargo cache -a && cargo update
# Run Rust tests of project.
#
# Usage :
# make test
test :
cargo test --all-features
# Run format link test and tests.
#
# Usage :
# make all
all : fmt lint test
#
# === .PHONY section
#
.PHONY : \
all \
audit \
docs \
lint \
check \
fmt \
normalize \
checkmate \
test \
up \
doc