-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
136 lines (91 loc) · 2.63 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
###############################
# Common defaults/definitions #
###############################
comma := ,
# Checks two given strings for equality.
eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\
$(findstring $(2),$(1))),1)
###########
# Aliases #
###########
all: fmt lint docs test
docs: cargo.doc
fmt: cargo.fmt
lint: cargo.lint
release: cargo.release
test: test.cargo
##################
# Cargo commands #
##################
# Generate crates documentation from Rust sources.
#
# Usage:
# make cargo.doc [crate=<crate-name>]
# [private=(yes|no)] [docsrs=(no|yes)]
# [open=(yes|no)] [clean=(no|yes)]
cargo.doc:
ifeq ($(clean),yes)
@rm -rf target/doc/
endif
$(if $(call eq,$(docsrs),yes),RUSTDOCFLAGS='--cfg docsrs',) \
cargo $(if $(call eq,$(docsrs),yes),+nightly,) doc \
$(if $(call eq,$(crate),),--workspace,-p $(crate)) \
--all-features \
$(if $(call eq,$(private),no),,--document-private-items) \
$(if $(call eq,$(open),no),,--open)
# Format Rust sources with rustfmt.
#
# Usage:
# make cargo.fmt [check=(no|yes)]
cargo.fmt:
cargo +nightly fmt --all $(if $(call eq,$(check),yes),-- --check,)
# Lint Rust sources with Clippy.
#
# Usage:
# make cargo.lint
cargo.lint:
cargo clippy --workspace --all-features -- -D warnings
# Prepare Rust crate release.
#
# Read more about bump levels here:
# https://github.com/crate-ci/cargo-release/blob/master/docs/reference.md#bump-level
#
# Usage:
# make cargo.release [ver=(release|<bump-level>)] [exec=(no|yes)]
# [install=(yes|no)]
cargo.release:
ifneq ($(install),no)
cargo install cargo-release
endif
cargo release -p delegation-codegen --all-features \
$(if $(call eq,$(exec),yes),\
--no-publish --no-push --execute,\
-v $(if $(call eq,$(CI),),,--no-publish)) \
$(or $(ver),release)
cargo.test: test.cargo
####################
# Testing commands #
####################
# Run Rust tests of project.
#
# Usage:
# make test.cargo [crate=<crate-name>] [careful=(no|yes)]
test.cargo:
ifeq ($(careful),yes)
ifeq ($(shell cargo install --list | grep cargo-careful),)
cargo install cargo-careful
endif
ifeq ($(shell rustup component list --toolchain=nightly \
| grep 'rust-src (installed)'),)
rustup component add --toolchain=nightly rust-src
endif
endif
cargo $(if $(call eq,$(careful),yes),+nightly careful,) test \
$(if $(call eq,$(crate),),--workspace,-p $(crate)) \
--all-features
##################
# .PHONY section #
##################
.PHONY: all docs fmt lint release test \
cargo.doc cargo.fmt cargo.lint cargo.release cargo.test \
test.cargo