forked from stacked-git/stgit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
142 lines (101 loc) · 3.04 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
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
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