Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
226 lines (197 loc) · 10.9 KB
/
Copy pathMakefile
File metadata and controls
226 lines (197 loc) · 10.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
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
.PHONY: help build test vet palette-page sync-test-cases gen-test-md gen-invalid-sidecars update-test-docs \
refs-rehash layout-test layout-fitness layout-check layout-check-baseline \
layout-audit layout-audit-ext layout-audit-published layout-timeline layout-timeline-build \
build-rpc build-all build-dev build-notrace
BIN_DIR ?= bin
help:
@echo "Available targets:"
@echo " build - go build ./..."
@echo " build-notrace - build + test with the debug trace compiled out (-tags l7notrace)"
@echo " test - go test ./..."
@echo " vet - go vet ./..."
@echo " build-rpc - Build the ipm-rpc LSP binary into $(BIN_DIR)/ (for the VS Code extension)"
@echo " build-all - Build every shipping + dev binary into $(BIN_DIR)/"
@echo " build-dev - Build just the dev binaries (layout-debug, layout-explain, layout-audit, layout-timeline)"
@echo ""
@echo "Layout regression testing:"
@echo " layout-test - Run layout regression tests (verbose)"
@echo " layout-fitness - Show the fitness score only"
@echo " layout-check - Ratchet the universal-invariant findings vs the baseline"
@echo " layout-audit - HTML report: which diagrams a change moved, ranked (OLD=<ref>)"
@echo " layout-audit-ext - the same over an extended corpus (needs CORPUS=<file>, outliers skipped)"
@echo " layout-audit-published - what the engine does that is NOT published yet (PUBLISHED=<ref>)"
@echo " layout-timeline - HTML report: today's diagrams through each engine in history"
@echo " layout-timeline-build - Phase 1 only: build every engine into the cache, then stop"
@echo " (a corpus over OTHER checkouts is driven from those repos, via --corpus)"
@echo ""
@echo "Fixture maintenance (dev):"
@echo " sync-test-cases - Verify and update generated fixture coverage"
@echo " gen-test-md - Generate per-case .md files from sources.json"
@echo " gen-invalid-sidecars - Regenerate ipmt-invalid corpus rejection sidecars"
@echo " regen-fixtures - Print the ordered plan to regenerate every fixture (regen-fixtures-run runs it)"
@echo " refs-rehash - Refresh _refs.json outputs hashes after regenerating fixtures"
@echo " update-test-docs - Generate test documentation in temp/test-docs"
build:
go build ./...
# proves the debug-stripped engine builds and passes its tests
# (docs/dev/layout-gen/layout-debug.md)
build-notrace:
go build -tags l7notrace ./...
go test -tags l7notrace ./pkg/layout7/
vet:
go vet ./...
test:
go test ./...
# Build the ipm-rpc language server consumed by the VS Code extension.
# Point the extension at this binary via the `ipm.serverPath` setting
# (or add ./bin to PATH).
build-rpc:
@mkdir -p $(BIN_DIR)
go build -trimpath -ldflags='-s -w' -o $(BIN_DIR)/ipm-rpc ./cmd/ipm-rpc
@echo "ipm-rpc built: $(BIN_DIR)/ipm-rpc"
# Build every shipping command into $(BIN_DIR)/.
SHIPPING := ipmt-parse layout-gen ipmsvg-gen ipm-validate md-embed md-html ipm-rpc
build-all: build-dev
@mkdir -p $(BIN_DIR)
@for c in $(SHIPPING); do \
echo "building $$c"; \
go build -trimpath -ldflags='-s -w' -o $(BIN_DIR)/$$c ./cmd/$$c || exit 1; \
done
@echo "binaries in $(BIN_DIR)/"
# Dev-only commands that are worth keeping in $(BIN_DIR)/ as binaries.
# They are NOT shipped, but they run the ENGINE — so a stale one silently
# disagrees with source and reports a layout nobody can reproduce
# (bin/layout-debug did exactly that, 2026-07-27, and sent a diagnosis the
# wrong way). build-all rebuilds them alongside the shipping set so the two
# can never drift; `make build-dev` refreshes just these.
DEV := layout-debug layout-explain layout-audit layout-timeline
build-dev:
@mkdir -p $(BIN_DIR)
@for c in $(DEV); do \
echo "building $$c (dev)"; \
go build -trimpath -o $(BIN_DIR)/$$c ./cmd-dev/$$c || exit 1; \
done
# Layout regression testing — one lane per way of running the engine: the base
# corpus and the layout-alg-ext combinations on default options, layout-alg-anchor
# with Options.Anchor built from each case's reference, layout-alg-containers with
# Options.Containers alone, layout-alg-shells with Options.Shells on top, and
# layout-alg-dupe through pkg/layoutdupe with its size gate lifted so the cases
# can stay small.
layout-test:
@go run ./cmd-dev/layout-test-runner -v
@go run ./cmd-dev/layout-test-runner -v --dir tests/layout-gen-ext
@go run ./cmd-dev/layout-test-runner -v --anchor --dir tests/layout-gen-anchor
@go run ./cmd-dev/layout-test-runner -v --containers --dir tests/layout-gen-containers
@go run ./cmd-dev/layout-test-runner -v --shells --dir tests/layout-gen-shells
@go run ./cmd-dev/layout-test-runner -v --duplicate --duplicate-min-nodes 1 --dir tests/layout-gen-dupe
layout-fitness:
@go run ./cmd-dev/layout-test-runner
@go run ./cmd-dev/layout-test-runner --dir tests/layout-gen-ext
@go run ./cmd-dev/layout-test-runner --anchor --dir tests/layout-gen-anchor
@go run ./cmd-dev/layout-test-runner --containers --dir tests/layout-gen-containers
@go run ./cmd-dev/layout-test-runner --shells --dir tests/layout-gen-shells
@go run ./cmd-dev/layout-test-runner --duplicate --duplicate-min-nodes 1 --dir tests/layout-gen-dupe
# Universal-invariant check (no node overlaps, no edge through/grazing a box,
# no crossings/covers, badges & chips clear of boxes, nothing reads-as-paired)
# over the fitness corpora (CHECK_PATHS below), ratcheted
# against the committed baseline: FAILS when any file's finding count grows.
# When your change shrinks the counts, tighten the ratchet with
# `make layout-check-baseline` and commit the updated baseline.
# (not tests/layout-gen-shells: the flat invariant checker counts shells as
# boxes; not tests/layout-gen-dupe: it re-runs the DEFAULT engine, so it would
# check those cases without the duplication they exist to show)
CHECK_PATHS := tests/layout-gen tests/layout-gen-ext
ENGINE_PATHS ?= pkg/layout7 pkg/layout cmd/layout-gen
layout-check:
@go run ./cmd-dev/layout-debug --check --baseline tests/layout-check-baseline.txt $(CHECK_PATHS) 2>/dev/null
layout-check-baseline:
@go run ./cmd-dev/layout-debug --check --write-baseline tests/layout-check-baseline.txt $(CHECK_PATHS) 2>/dev/null
# What a change DID, rather than whether it passed: builds the engine at OLD
# (default HEAD), sweeps both engines over the same diagrams and writes an HTML
# report ranked by significance. docs/dev-tools/layout-audit.md.
# make layout-audit # HEAD vs the working tree
# make layout-audit OLD=v0.4.2
# make layout-audit OLD=abc123~1 NEW=abc123
OLD ?= HEAD
NEW ?= workdir
AUDIT_PATHS ?= $(CHECK_PATHS) examples docs
layout-audit:
@go run ./cmd-dev/layout-audit --old "$(OLD)" --new "$(NEW)" $(AUDIT_PATHS)
# The EXTENDED corpus (other checkouts, the lab's SST corpus), its outliers
# skipped. Run after an engine change: the default set is small diagrams only.
#
# CORPUS has NO DEFAULT, deliberately. A corpus that names other checkouts
# belongs to the repository that owns them, and this one is published — it must
# not carry the name of a private sibling. Drive it from there, or pass the
# path explicitly:
#
# make layout-audit-ext CORPUS=../<that-repo>/layout-corpus.json
CORPUS ?=
# WHAT IS NOT OUT YET: the engine the remote holds, against what is on disk.
# The one question a published repository asks that no date range can — "is
# this change still mine to change, or has it shipped".
#
# make layout-audit-published # origin/main (or the upstream) vs the working tree
# make layout-audit-published PUBLISHED=v0.6.0
PUBLISHED ?= $(shell git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null || echo origin/main)
layout-audit-published:
@git rev-parse "$(PUBLISHED)^{commit}" >/dev/null 2>&1 || { \
echo "no published ref at $(PUBLISHED) — fetch first, or pass PUBLISHED=<ref>"; exit 1; }
@echo "published $(PUBLISHED) ($$(git rev-parse --short $(PUBLISHED))) vs $(NEW):"
@echo " $$(git rev-list --count $(PUBLISHED)..HEAD) commit(s) here are not published,"
@echo " $$(git rev-list --count $(PUBLISHED)..HEAD -- $(ENGINE_PATHS)) of them touching the engine"
@go run ./cmd-dev/layout-audit --old "$(PUBLISHED)" --new "$(NEW)" $(AUDIT_PATHS)
layout-audit-ext:
@test -f "$(CORPUS)" || { echo "no corpus at $(CORPUS) — write one with:"; \
echo " go run ./cmd-dev/layout-timeline --corpus-example > $(CORPUS)"; exit 1; }
@go run ./cmd-dev/layout-audit --old "$(OLD)" --new "$(NEW)" --corpus "$(CORPUS)"
# When each diagram last moved: a column per engine in history, and TODAY's
# diagrams run through all of them — so a cell in the grid means the ENGINE
# changed the picture, never that someone edited the diagram.
# docs/dev-tools/layout-timeline.md.
# make layout-timeline # the whole history
# make layout-timeline WEEKS=6
# make layout-timeline HEAD_COMMITS=6 # more of the newest work, one column each
#
# The engine cache lives OUTSIDE this repository (~/.cache/ipm-layout-engines):
# it is keyed by commit, shared with layout-audit, and putting 2 GB of built
# engines inside a directory the editor watches is what it is not for.
WEEKS ?=
HEAD_COMMITS ?=
TIMELINE_FLAGS = $(if $(WEEKS),--weeks $(WEEKS),) $(if $(HEAD_COMMITS),--head-commits $(HEAD_COMMITS),)
layout-timeline:
@go run ./cmd-dev/layout-timeline $(TIMELINE_FLAGS) $(AUDIT_PATHS)
# Phase 1 alone. A long history is mostly `go build`, and that half never
# changes — a commit's engine is the same today as last week — so it is worth
# doing once, and separately, before a report anyone is waiting on. Idempotent:
# a commit already in the cache is skipped.
layout-timeline-build:
@go run ./cmd-dev/layout-timeline --build-only $(TIMELINE_FLAGS) $(AUDIT_PATHS)
# Fixture maintenance. These REWRITE tracked files, so CI never runs them; CI
# runs the read-only counterparts instead (`sync-test-cases --check`,
# `md-embed --root . --check`) and fails if what is committed no longer matches
# the sources it was generated from.
sync-test-cases:
go run ./cmd-dev/sync-test-cases --rm-extra
# Print the ordered fixture regeneration plan (runs nothing), or run it and
# report what changed. See docs/dev-tools/regen-fixtures.md.
regen-fixtures:
@go run ./cmd-dev/regen-fixtures
regen-fixtures-run:
@go run ./cmd-dev/regen-fixtures -run
gen-test-md:
@go run ./cmd-dev/gen-test-md --sources-config tests/sources.json
# Regenerate the ipmt-invalid corpus rejection sidecars (.parser.error.json /
# .validate.error.json). Run after editing the invalid examples in
# docs/ipmt-spec.md or the tests/ipmt/invalid corpus.
gen-invalid-sidecars:
@go run ./cmd-dev/gen-invalid-sidecars
# Refresh the "outputs" SHA1 maps in the layout corpora's _refs.json after
# layout-test-runner / ipmsvg-gen / gen-test-md regenerated artifact files.
refs-rehash:
@go run ./cmd-dev/refs-rehash
update-test-docs:
@go run ./cmd-dev/gen-test-doc -sources-config tests/sources.json -out-dir temp/test-docs
palette-page:
@mkdir -p temp
@go run ./cmd-dev/palette-page --out temp/palette.html