-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
82 lines (71 loc) · 3.39 KB
/
Copy pathMakefile
File metadata and controls
82 lines (71 loc) · 3.39 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
# The Harper release everything here is built from. Keep it in step with
# HARPER_REF in .github/workflows/main.yml: a rule read from one version of a
# linter and measured against another is measured against the wrong thing.
HARPER_REF ?= v2.7.0
# Not ../harper: this repo is Harper/, and on a case-insensitive filesystem --
# macOS by default -- ../harper resolves back to it. The checkout would then be
# this repo, check-ref would look for v2.7.0 among its tags, and the failure
# ("No names found, cannot describe anything") says nothing about the cause.
HARPER ?= ../harper-upstream
HARPER_CLI ?= $(HARPER)/target/release/harper-cli
CORPUS ?= corpus.txt
WEIR := $(HARPER)/harper-core/src/linting/weir_rules
LINT := $(HARPER)/harper-core/src/linting
DICT := generated/harper.dict
# Where verify unpacks the built package to check it as installed.
STAGE := generated/stage
# Rules kept by hand live in Harper/ and are never generated over; see
# cmd/pack for how the two halves become one package.
#
# The output is cleared first. A rule the generators stop emitting -- because
# it was wrong, or because it now lives in Harper/ by hand -- has to disappear,
# not linger from the last run. `BackInTheDay` survived a fix that way and
# stayed the top source of false positives.
.PHONY: generate
generate: check-ref $(DICT)
rm -f generated/*.yml
go run ./cmd/weirgen -dir $(WEIR) -out generated -model harper
go run ./cmd/rustgen -dir $(LINT) -dict $(DICT) -out generated -model harper
go run ./cmd/adjgen -dict $(DICT) -out generated
# The dictionary comes out of harper-cli a word at a time and takes minutes to
# build, so it is a file target: it only rebuilds when it is missing.
$(DICT): | generated
go run ./cmd/dictgen -cli $(HARPER_CLI) -out $@
generated:
mkdir -p generated
# A silent version mismatch is expensive: rules written from a linter that a
# checkout does not contain still fire, and Harper never agrees with them, so
# they read as a precision problem rather than as the wrong checkout. Override
# HARPER_REF to work against something else deliberately.
.PHONY: check-ref
check-ref:
@git -C $(HARPER) describe --tags --exact-match 2>/dev/null | grep -qx '$(HARPER_REF)' || { \
echo "$(HARPER) is not at $(HARPER_REF) -- pass HARPER_REF= to override"; \
exit 1; \
}
.PHONY: package
package: generate
go run ./cmd/pack
# weircheck reads the style as a reader would install it, so it needs the two
# rule directories merged -- `-styles .` only ever saw the hand-written half and
# reported that nothing was generated.
.PHONY: verify
verify: check-ref package
rm -rf $(STAGE) && mkdir -p $(STAGE)
cd $(STAGE) && unzip -q $(CURDIR)/dist/Harper.zip
go run ./cmd/weircheck -dir $(WEIR) -styles $(STAGE)/Harper/styles -style Harper
go run ./cmd/offcheck -harper $(HARPER_CLI)
# measure reports precision and recall against Harper itself. `-ported` limits
# the comparison to rules this style claims to implement, which is the number
# to watch while porting; drop it to see the whole gap.
.PHONY: measure
measure: $(CORPUS)
go run ./cmd/oracle -ported -harper $(HARPER_CLI) $(CORPUS)
# The corpus is Harper's own examples. It is a file target because the line
# numbers in it are what two tools' findings are matched on: rebuilding it
# mid-comparison would make the run incomparable to the last one.
$(CORPUS):
go run ./cmd/corpusgen -harper $(HARPER) -out $@
.PHONY: clean
clean:
rm -rf generated dist $(CORPUS)