-
Notifications
You must be signed in to change notification settings - Fork 61
/
Makefile
184 lines (128 loc) · 4.66 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
prefix ?= $(HOME)/.local
DESTDIR ?=
DEFAULT_TEST_TARGET ?= test
STG_PROVE_OPTS ?=
STG_PROFILE ?= release
CARGO ?= cargo --locked
CARGO_OFFLINE = $(CARGO) --offline
CARGO_RUN = $(CARGO_OFFLINE) --quiet run --profile=$(STG_PROFILE)
RM ?= rm -f
ifeq ($(STG_PROFILE),dev)
TARGET_DIR = target/debug
else
TARGET_DIR = target/$(STG_PROFILE)
endif
export DESTDIR CARGO STG_PROFILE
TEST_PATCHES ?= ..
build:
$(CARGO) build --profile=$(STG_PROFILE)
all: build doc completion contrib
completion: build
$(MAKE) -C completion all
contrib:
$(MAKE) -C contrib all
doc: build
$(MAKE) -C Documentation all
.PHONY: all build completion contrib doc
install: install-bin
install-all: install-bin install-completion install-contrib install-man install-html
install-bin: build
$(CARGO_OFFLINE) install --profile=$(STG_PROFILE) --path=. --root=$(DESTDIR)$(prefix) --no-track --force
install-completion: build
$(MAKE) -C completion install
install-man:
$(MAKE) -C Documentation install-man
install-html:
$(MAKE) -C Documentation install-html
install-contrib:
$(MAKE) -C contrib install
.PHONY: install install-all install-bin install-completion install-contrib install-man install-html
build-static-i686:
$(CARGO) build --profile=for-pkg --target i686-unknown-linux-musl --no-default-features
build-static-x86_64:
$(CARGO) build --profile=for-pkg --target x86_64-unknown-linux-musl --no-default-features
build-static-aarch64:
$(CARGO) build --profile=for-pkg --target aarch64-unknown-linux-musl --no-default-features
target/pkg:
mkdir -p $@
deb-i686: completion doc target/pkg build-static-i686
$(CARGO_OFFLINE) deb --no-build --no-strip --output target/pkg/ --profile=for-pkg --target=i686-unknown-linux-musl
deb-x86_64: completion doc target/pkg build-static-x86_64
$(CARGO_OFFLINE) deb --no-build --no-strip --output target/pkg/ --profile=for-pkg --target=x86_64-unknown-linux-musl
deb-aarch64: completion doc target/pkg build-static-aarch64
$(CARGO_OFFLINE) deb --no-build --no-strip --output target/pkg/ --profile=for-pkg --target=aarch64-unknown-linux-musl
debs: deb-i686 deb-x86_64 deb-aarch64
rpm-i686: completion doc target/pkg build-static-i686
$(CARGO_OFFLINE) generate-rpm --output target/pkg/ --profile=for-pkg --target=i686-unknown-linux-musl
rpm-x86_64: completion doc target/pkg build-static-x86_64
$(CARGO_OFFLINE) generate-rpm --output target/pkg/ --profile=for-pkg --target=x86_64-unknown-linux-musl
rpm-aarch64: completion doc target/pkg build-static-aarch64
$(CARGO_OFFLINE) generate-rpm --output target/pkg/ --profile=for-pkg --target=aarch64-unknown-linux-musl
rpms: rpm-i686 rpm-x86_64 rpm-aarch64
packages: debs rpms
.PHONY: packages
.PHONY: debs deb-i686 deb-x86_64 deb-aarch64
.PHONY: rpms rpm-i686 rpm-x86_64 rpm-aarch64
.PHONY: build-static-i686 build-static-x86_64 build-static-aarch64
lint: lint-format lint-clippy lint-api-doc lint-t unit-test
lint-format:
$(CARGO_OFFLINE) --quiet fmt --all --check
lint-clippy:
$(CARGO_OFFLINE) --quiet clippy -- --deny warnings
lint-api-doc:
$(CARGO_OFFLINE) --quiet doc --no-deps
lint-t:
$(MAKE) -C t test-lint
unit-test:
$(CARGO_OFFLINE) --quiet test
.PHONY: lint lint-format lint-clippy lint-api-doc lint-t unit-test
coverage:
$(MAKE) coverage-test
$(MAKE) coverage-html
$(MAKE) coverage-report
coverage-bin:
RUSTFLAGS="-C instrument-coverage" $(CARGO) build --profile=$(STG_PROFILE)
coverage-html: $(TARGET_DIR)/stg.profdata
llvm-cov show \
--instr-profile=$< \
--object=$(TARGET_DIR)/stg \
-ignore-filename-regex='/.cargo/registry' \
-ignore-filename-regex='rustc/' \
-Xdemangler=rustfilt \
-format=html \
-output-dir=htmlcov
coverage-report: $(TARGET_DIR)/stg.profdata
llvm-cov report \
--instr-profile=$< \
--object=$(TARGET_DIR)/stg \
-ignore-filename-regex='/.cargo/registry' \
-ignore-filename-regex='rustc/'
coverage-test: coverage-bin
$(RM) $(TARGET_DIR)/stg.profdata
$(MAKE) $(TARGET_DIR)/stg.profdata
$(TARGET_DIR)/stg.profdata:
-$(RM) -r $(TARGET_DIR)/.profraw
-mkdir $(TARGET_DIR)/.profraw
LLVM_PROFILE_FILE=$(CURDIR)/$(TARGET_DIR)/.profraw/stg-%m-%p.profraw \
$(MAKE) -C t all
llvm-profdata merge -sparse -o $@ $(TARGET_DIR)/.profraw/*.profraw
$(RM) -r $(TARGET_DIR)/.profraw
.PHONY: coverage coverage-bin coverage-html coverage-report coverage-test
format:
$(CARGO_OFFLINE) fmt
test: build
$(MAKE) -C t all
prove: build
$(MAKE) -C t prove
test-patches:
for patch in $$($(CARGO_RUN) series --noprefix $(TEST_PATCHES)); do \
$(CARGO_RUN) goto $$patch && $(MAKE) test || break; \
done
clean:
$(MAKE) -C Documentation clean
$(MAKE) -C t clean
$(MAKE) -C completion clean
$(MAKE) -C contrib clean
$(RM) -r target
$(RM) -r htmlcov
.PHONY: format prove test test-patches clean