Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
106 lines (74 loc) · 5.9 KB
/
Copy pathMakefile
File metadata and controls
106 lines (74 loc) · 5.9 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# TScert: an independent checker, proved in Lean, for TypeScript type claims.
# `make help` lists the targets.
OUT ?= $(or $(TMPDIR),/tmp)/semantic-diff.html
REV ?= HEAD
.PHONY: help setup build build-lean test test-checks test-infra test-cases cases check lowering compiler-api-shapes semantic-diff deck fmt \
check-fmt setup-git-hooks clean-store census build-runner test-pretext generate-sections rules-page
help: ## list the targets
@grep -E '^[a-z-]+:.*## ' $(MAKEFILE_LIST) | sed -E 's/:.*## /\t/' | expand -t 16
setup: ## install the node dependencies (tools, the library fixture's Node types, Prettier) and link the fixtures' installations
npm ci --prefix tools
npm ci --prefix pipeline/library-project
npm install --no-save
node pipeline/fixture-links.mts
build: build-lean build-runner ## build the Lean verifier and the stage runner
RUNNER := pipeline/runner/_build/stage-runner
build-runner: $(RUNNER) ## build the stage runner, which reports the CPU time and peak memory of process stages
$(RUNNER): pipeline/runner/stage-runner.c
mkdir -p $(dir $@)
cc -O2 -Wall -Wextra -Werror -o $@ $<
build-lean: ## build the Lean verifier
cd lean && lake build --log-level=warning
CLI_VERSION ?= 1.0.0-dev
CLI_ARCHIVE = _build/npm/tscert-$(CLI_VERSION)-$(shell node -p 'process.platform + "-" + process.arch').tgz
package-cli: build ## pack the CLI tarball for this platform (CLI_VERSION sets its version)
node dev/pack-cli.mts "$(CLI_VERSION)"
test-installed-cli: package-cli ## install the CLI tarball in a clean project and check acceptance and refusal
node tests/installed-cli.mts "$(CLI_ARCHIVE)"
test: test-checks test-cases ## build, then the fast checks and the controls, then the pipeline cases
test-checks: build ## build, then the fast checks and the controls no case can make (replayed from the stage store) [CONTROLS=0: without the controls]
@./test-all.sh $(if $(filter 0,$(CONTROLS)),--no-controls)
test-infra: build ## build, then the tests of the test infrastructure: the stage store, the runner, replay, observed stages, declaration sessions (CI runs them when their code changes)
@./test-all.sh --infra
test-cases: build ## build, then the pipeline cases [SHARD=i/n: every n-th case from the i-th]
node pipeline/run-cases.mts $(if $(SHARD),--shard $(SHARD))
cases: ## the pipeline cases whose file names contain P (all of them when P is empty)
node pipeline/run-cases.mts $(P)
test-pretext: build ## the pretext tier: the bounds pattern cases, the bounds cases of tests/pretext-tier.mts and pretext's functions: PRETEXT=checkout [FILES=a.ts,…] [UPDATE=1 records the functions for its commit]
@test -n "$(PRETEXT)" || { echo "make test-pretext needs PRETEXT=<pretext checkout>"; exit 2; }
node tests/pretext-tier.mts --pretext $(PRETEXT) $(if $(FILES),--files $(FILES)) $(if $(UPDATE),--update)
check: ## one source file through the pipeline: FILE=path.ts [PROJECT=dir] [CONTRACTS=1, the external contracts its verdict relies on; CONTRACTS=ts, as TypeScript declarations]
node pipeline/verify-source.mts $(FILE) $(if $(PROJECT),--project $(PROJECT)) $(if $(CONTRACTS),--contracts$(if $(filter ts,$(CONTRACTS)),=ts))
clean-store: ## remove stage entries, timeouts and the source snapshots no running process holds; FORGET_HOST=h counts host h's owners stopped (TSCERT_STAGE_STORE, default ~/.cache/tscert/stages)
node pipeline/stages.mts clean $(if $(FORGET_HOST),--forget-host=$(FORGET_HOST))
census: ## the census of a directory's units: DIR=tools, FILES=a.mts,…, FUNCTIONS=f,… (with their dependency closure; SHALLOW=1 without it), SHARD=i/n; a record per run; each stage limited to 300 s unless TSCERT_STEP_LIMIT says otherwise; TSCERT_RETRY_TIMEOUTS=1 runs recorded timeouts again
TSCERT_STEP_LIMIT=$${TSCERT_STEP_LIMIT:-300} node dev/census.mts --dir $(or $(DIR),tools) $(if $(FILES),--files $(FILES)) $(if $(FUNCTIONS),--functions $(FUNCTIONS)) $(if $(SHARD),--shard $(SHARD)) $(if $(SHALLOW),--shallow)
lowering: ## the execution graphs a source's functions lower to: FILE=path.ts [FN=function]
node dev/lowering-dump.mts $(FILE) $(FN)
compiler-api-shapes: ## C3 and C4: every node of the corpus holds the members its shape states required, or a correction covers them, each read stable
node tests/compiler-api-shapes.mts
deck: ## build the deep-dive deck NAME (docs/deep-dives/NAME/deck.mts): its project/ files, the format and layout checks, and a page to view it; OPEN=1 opens the page; SINCE=rev marks on the page what changed since rev
node dev/deck-cli.mts $(NAME) $(if $(OPEN),--open) $(if $(SINCE),--since $(SINCE))
semantic-diff: ## render the commit records of REV (a commit or base..tip, default HEAD) to OUT and open it
node dev/commit-records.mts --out $(OUT) $(REV)
@if command -v open >/dev/null; then open $(OUT); \
elif command -v xdg-open >/dev/null; then xdg-open $(OUT); fi
generate-sections: build-lean ## rewrite every generated section of the documents from its producer (docs/GENERATED-SECTIONS.md)
node dev/generated-sections.mts
RULES_PAGE ?= $(or $(TMPDIR),/tmp)/arithmetic-rules.html
rules-page: build-lean ## write the step rules' page to RULES_PAGE (default $$TMPDIR/arithmetic-rules.html) and open it
node dev/generated-sections.mts --page $(RULES_PAGE)
@if command -v open >/dev/null; then open $(RULES_PAGE); \
elif command -v xdg-open >/dev/null; then xdg-open $(RULES_PAGE); fi
fmt: ## format with Prettier
npx prettier --write .
check-fmt: ## check formatting with Prettier
npx prettier --check .
# the commit-record check on every commit, of the main checkout and of every
# worktree: they share the repository's hooks directory, whose hook is the main
# checkout's script
HOOKS_DIR = $(shell git rev-parse --path-format=absolute --git-path hooks)
MAIN_CHECKOUT = $(patsubst %/,%,$(dir $(shell git rev-parse --path-format=absolute --git-common-dir)))
setup-git-hooks: ## install the commit-record check
mkdir -p $(HOOKS_DIR)
ln -sfn $(MAIN_CHECKOUT)/bin/git_hooks/commit_record.sh $(HOOKS_DIR)/commit-msg