-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
514 lines (439 loc) · 23.8 KB
/
Copy pathMakefile
File metadata and controls
514 lines (439 loc) · 23.8 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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
# Alchemy's build and contributor workflows share the alchemy executable.
# Asset packages are described by data under games/; the shared codecs behind
# `alchemy build assets` are named for their formats, not for any resource.
GCC296_CFLAGS := -O2 -mthumb -mthumb-interwork -mcpu=arm7tdmi \
-fno-builtin -nostdinc -ffreestanding \
-fcall-used-r4 -I"games/THE BROKEN SEAL/INCLUDE"
TOOLS := tools
CARGO ?= cargo
export CARGO_TARGET_DIR := $(CURDIR)/out/cargo-target
# Bootstrap's native arm-none-eabi binutils come first for every recipe and test.
export PATH := $(CURDIR)/tools/binutils/bin:$(PATH)
CARGO_RUN := $(CARGO) run --offline --quiet --release --manifest-path
BUILD := $(CARGO_RUN) $(TOOLS)/alchemy/Cargo.toml -- build
ASSETS := $(CARGO_RUN) $(TOOLS)/alchemy/Cargo.toml -- build assets
CHECK := $(CARGO_RUN) $(TOOLS)/alchemy/Cargo.toml -- check
COMPILER := $(CARGO_RUN) $(TOOLS)/alchemy/Cargo.toml --
OVERLAY := $(CARGO_RUN) $(TOOLS)/alchemy/Cargo.toml -- overlay
HOSTS := alchemy psynergy
PORTABLE_TOOLS := alchemy psynergy
# The maintainer-owned ceiling covers the portable Rust, TypeScript,
# JavaScript, and CSS beside the decompilation. Contributors pare
# machinery; they do not raise it.
# Only Pascal moves this number; a diff touching it without his recorded
# decision is invalid regardless of how good the new machinery is.
# 100,000 set by Pascal's decision, 2026-09-15.
TOOLING_LINE_LIMIT := 100000
TARGET ?= tbs-en
TARGET_GAME := $(firstword $(subst -, ,$(TARGET)))
TARGET_GAME_DIR := $(if $(filter tbs,$(TARGET_GAME)),THE BROKEN SEAL,$(if $(filter tla,$(TARGET_GAME)),THE LOST AGE,$(TARGET_GAME)))
FULL_REPORT = out/$(TARGET)/full/rebuilt.json
FULL_ROM = out/$(TARGET)/full/rebuilt.gba
OWNER_INVENTORY = out/$(TARGET)/full/rebuilt.owner-inventory.json
REPORT_DIR = out/$(TARGET)/reports
VERIFIED_TREE = $(REPORT_DIR)/verified-tree
MAIN_CORRESPONDENCE_MATCHED_MIN := 1393
MAIN_CORRESPONDENCE_UNRESOLVED_MAX := 44
OVERLAY_CORRESPONDENCE_MATCHED_MIN := 2562
OVERLAY_CORRESPONDENCE_UNRESOLVED_MAX := 38
# Raw .byte/.2byte/.4byte/.word values (aliases included, one per operand) in
# games/*/raw/overlays/*_overlay.s. The total may only fall: lower this number
# when listing data becomes typed tables or private inputs; never raise it.
OVERLAY_DATA_DIRECTIVES_MAX := 77508
HISTORICAL_TARGETS := tbs-ja tbs-en tbs-de tbs-es tbs-fr tbs-it \
tla-ja tla-en tla-de tla-es tla-fr tla-it
CANDIDATE_SINGLE_OWNERS := \
08090824=initialize_display_transition_state.c \
08091174=initialize_battle_effect_buffers.c \
080944ec=arm_display_scroll_hblank_dma.c \
080b5ad4=initialize_battle_tile_pattern.c \
080b7f20=project_battle_object_position.c \
080b81c8=initialize_battle_object_motion.c \
080b845c=project_scaled_battle_position.c \
080b84c0=project_conditional_battle_position.c \
080c0184=upload_battle_tile_variant.c \
080c0eb8=initialize_battle_transition_entries.c \
080f377c=initialize_title_palette_buffers.c
.PHONY: help verify audit reports test lint lint-production lint-all-targets build-tools tool-tests tooling-size tooling-index-check \
build-claimed build-asm build-assets build-full build-rom \
standard-check compiler-source-check corpus-check core-retained-check \
full-rom-check tla-assets-check tla-owners-check overlay-check declared-tu-check owner-inventory-check strict-tu-check siblings-check classification-check \
candidate-corpus-check source-tracking-check index-sync-check publication-tree-check plan-tails-check overlay-data-check showcase-check check-owners progress progress-report progress-check progress-subject \
correspondence correspondence-check edition-builds edition-builds-check \
coverage coverage-check native-format-check review-images-check clean clean-preview
.PHONY: targets $(HISTORICAL_TARGETS)
help:
@printf '%s\n' \
'make bootstrap build/install missing compiler dependencies' \
'make bootstrap BUNDLE=/path/to/bundle install an approved bundle' \
'make verify-clean verify after deleting generated output' \
'make verify fast byte-exact production gate' \
'make audit exhaustive editions, candidates, and reports audit' \
'make reports refresh analysis reports and coverage figures' \
'make targets compile shared source for all 12 historical targets' \
'make tbs-ja compile one edition-qualified source target' \
'make build-rom rebuild the ROM' \
'make build-full rebuild and compare every owned byte' \
'make full-rom-check prove the complete tbs-en ROM byte-exact' \
'make tla-assets-check prove every tla-en asset region byte-exact' \
'make tla-owners-check prove every exact tla-en owner and shared source' \
'make overlay-check audit every exact overlay owner' \
'make declared-tu-check prove declared production translation-unit contracts' \
'make owner-inventory-check prove registered owner production coverage' \
'make strict-tu-check prove strict production TU composition and owner coverage' \
'make siblings-check report twin families; reject address names in instanced sources' \
'make classification-check prove retained-assembly classifications' \
'make candidate-corpus-check rescore retained reconstruction C' \
'make source-tracking-check reject ignored or untracked Proven C' \
'make build-assets rebuild source assets' \
'make test focused Rust tests and policy checks' \
'make tooling-size enforce the portable-toolkit budget' \
'make tooling-index-check prove every tool is indexed exactly once' \
'make progress print byte-exact progress' \
'make progress-subject print the required commit prefix' \
'make correspondence match exact EN owners across TBS editions' \
'make edition-builds relink exact EN C across TBS editions' \
'make coverage refresh coverage data and figures'
build-claimed:
$(BUILD) claimed --target $(TARGET)
build-asm:
$(BUILD) asm
build-assets: prepare-inputs
$(ASSETS)
build-full: prepare-inputs
$(BUILD) full --target $(TARGET)
build-rom: prepare-inputs
$(BUILD) rom --target $(TARGET)
full-rom-check: build-full
@cmp roms/$(TARGET).gba $(FULL_ROM)
@grep -Fq '"target": "$(TARGET)"' $(FULL_REPORT)
@grep -Fq '"verification": "rom"' $(FULL_REPORT)
@grep -Fq '"byte_identical": true' $(FULL_REPORT)
@grep -Fq '"unowned_bytes": 0' $(FULL_REPORT)
@grep -Fq '"rom_fallback_bytes": 0' $(FULL_REPORT)
@printf 'full ROM contract ok: %s\n' '$(TARGET)'
# The Lost Age has no full ROM contract yet; every asset region its manifest
# owns is rebuilt from source and compared with the tla-en ROM.
TLA_ASSETS = out/tla-en/assets
tla-assets-check: prepare-inputs
$(ASSETS) --target tla-en -o $(TLA_ASSETS) roms/tla-en.gba
@grep -Fq '"verification": "rom"' $(TLA_ASSETS)/manifest.json
@printf 'asset contract ok: tla-en\n'
# Every owner the TLA register gives a source, and with them the TLA half of
# every shared source in games/COMMON, scores byte-exact over its audited
# extent against the tla-en ROM.
tla-owners-check:
$(CHECK) tla-owners roms/tla-en.gba
overlay-check:
$(OVERLAY) audit --all
declared-tu-check: full-rom-check
@grep -Fq '"declared_main_translation_units_strict": true' $(FULL_REPORT)
@printf 'declared translation-unit production contract ok\n'
owner-inventory-check: full-rom-check
@test -s $(OWNER_INVENTORY)
@grep -Fq '"complete_registered_identity_coverage": true' $(OWNER_INVENTORY)
@printf 'registered owner production inventory ok\n'
strict-tu-check: declared-tu-check owner-inventory-check overlay-check
@printf 'strict production TU contracts ok; historical original boundaries remain unknown\n'
# Missed siblings (R1) and copied modules (R2) are reported until their waves
# close; semantic spelling in instanced sources (R3) is enforced.
siblings-check: full-rom-check
$(CHECK) siblings
targets: $(HISTORICAL_TARGETS)
$(HISTORICAL_TARGETS):
$(BUILD) claimed --target $@ --compile-only --output out/$@/compile
.PHONY: dashboard dashboard-service-install dashboard-restart
dashboard:
$(COMPILER) dashboard --bind 127.0.0.1:4650
# The service runs the binary it started with; restart it after tooling merges
# or the dashboard keeps computing DONE under the old rules.
dashboard-restart:
@launchctl kickstart -k 'gui/$(shell id -u)/com.pascalpixel.alchemy-dashboard'
dashboard-service-install:
@mkdir -p '$(HOME)/Library/LaunchAgents' '$(CURDIR)/out'
@sed -e 's|@ALCHEMY_ROOT@|$(CURDIR)|g' \
-e 's|@CARGO@|$(shell command -v $(CARGO))|g' \
tools/alchemy/src/dashboard/com.pascalpixel.alchemy-dashboard.plist.in \
> '$(HOME)/Library/LaunchAgents/com.pascalpixel.alchemy-dashboard.plist'
@launchctl bootout 'gui/$(shell id -u)/com.pascalpixel.alchemy-dashboard' 2>/dev/null || true
@launchctl bootstrap 'gui/$(shell id -u)' '$(HOME)/Library/LaunchAgents/com.pascalpixel.alchemy-dashboard.plist'
progress:
$(CHECK) progress
progress-check: full-rom-check
$(CHECK) progress --check
progress-report: full-rom-check | $(REPORT_DIR)
$(CHECK) progress --write-report
progress-subject:
$(CHECK) progress --subject
$(REPORT_DIR):
@mkdir -p $@
correspondence: build-full | $(REPORT_DIR)
$(COMPILER) cross-edition --all --object-dir out/tbs-en/full/claimed/obj \
--write $(REPORT_DIR)/exact-correspondence.json \
--edition-build $(REPORT_DIR)/exact-main-builds.json
$(COMPILER) cross-edition --all-overlays \
--write $(REPORT_DIR)/exact-overlay-correspondence.json \
--edition-build $(REPORT_DIR)/exact-overlay-builds.json
correspondence-check: correspondence
@set -e; \
main='$(REPORT_DIR)/exact-correspondence.json'; \
overlay='$(REPORT_DIR)/exact-overlay-correspondence.json'; \
main_matched=$$(sed -n 's/.*"matched_owners": \([0-9][0-9]*\),/\1/p' "$$main" | head -n 1); \
main_unresolved=$$(sed -n 's/.*"unresolved_owners": \([0-9][0-9]*\),/\1/p' "$$main" | head -n 1); \
overlay_matched=$$(sed -n 's/.*"matched_owners": \([0-9][0-9]*\),/\1/p' "$$overlay" | head -n 1); \
overlay_unresolved=$$(sed -n 's/.*"unresolved_owners": \([0-9][0-9]*\),/\1/p' "$$overlay" | head -n 1); \
test -n "$$main_matched" -a -n "$$main_unresolved" \
-a -n "$$overlay_matched" -a -n "$$overlay_unresolved"; \
test "$$main_matched" -ge '$(MAIN_CORRESPONDENCE_MATCHED_MIN)' \
-a "$$main_unresolved" -le '$(MAIN_CORRESPONDENCE_UNRESOLVED_MAX)'; \
test "$$overlay_matched" -ge '$(OVERLAY_CORRESPONDENCE_MATCHED_MIN)' \
-a "$$overlay_unresolved" -le '$(OVERLAY_CORRESPONDENCE_UNRESOLVED_MAX)'; \
printf 'cross-edition correspondence ok: main=%s/%s overlay=%s/%s matched/unresolved\n' \
"$$main_matched" "$$main_unresolved" "$$overlay_matched" "$$overlay_unresolved"
classification-check: core-retained-check
@printf 'classification contracts ok\n'
candidate-corpus-check:
$(CHECK) integrate --check "games/THE BROKEN SEAL/recon/en/main"
@actual=$$(find "games/THE BROKEN SEAL/recon/en/units" -maxdepth 1 -type f -name '*.c' -exec basename {} \; | LC_ALL=C sort); \
covered=$$({ for route in $(CANDIDATE_SINGLE_OWNERS); do printf '%s\n' "$${route#*=}"; done; \
awk -F '"' '/"source": "games\/THE BROKEN SEAL\/recon\/en\/units\//{n=split($$4,part,"/"); print part[n]}' \
"games/THE BROKEN SEAL/recon/translation-units.json"; } | LC_ALL=C sort -u); \
if test "$$actual" != "$$covered"; then \
printf 'unit corpus routes are incomplete\nactual:\n%s\ncovered:\n%s\n' "$$actual" "$$covered"; \
exit 1; \
fi
@set -e; total=0; \
for route in $(CANDIDATE_SINGLE_OWNERS); do \
owner=$${route%%=*}; source=$${route#*=}; \
result=$$($(COMPILER) score "games/THE BROKEN SEAL/recon/en/units/$$source" \
--owner $$owner --first); \
diff=$$(printf '%s\n' "$$result" | sed -n 's/.*differing_halfwords=\([0-9][0-9]*\).*/\1/p' | head -n 1); \
if test -z "$$diff" || test "$$diff" -eq 0; then \
printf 'single-owner candidate is exact or unscored: %s %s -- if exact, run alchemy adopt to move it out of the retained corpus; if unscored, fix the score first\n' "$$owner" "$$source"; \
exit 1; \
fi; \
total=$$((total + 1)); \
done; \
printf 'single-owner corpus scanned=%s exact_retained=0\n' "$$total"
@set -e; total=0; \
units=$$(awk -F '"' '/"id":/{id=$$4} /"source": "games\/THE BROKEN SEAL\/recon\/en\/units\//{print id}' \
"games/THE BROKEN SEAL/recon/translation-units.json"); \
for unit in $$units; do \
report=$$(mktemp /tmp/alchemy-tu-corpus.XXXXXX); \
$(COMPILER) score --unit $$unit | \
awk -F= '/^owner=/{owner=$$2} /^candidate=/{split($$0,a,"differing_halfwords="); print owner "\t" a[2]+0}' \
> "$$report"; \
for owner in $$(awk -F '"' -v unit="$$unit" '/"id":/{id=$$4} id==unit && /"state":"retained-assembly"/{print $$4}' \
"games/THE BROKEN SEAL/recon/translation-units.json"); do \
diff=$$(awk -F '\t' -v owner="$$owner" '$$1==owner{print $$2}' "$$report"); \
if test -z "$$diff" || test "$$diff" -eq 0; then \
printf 'translation-unit retained owner is exact or unscored: %s %s -- if exact, run alchemy adopt to move it out of the retained corpus; if unscored, fix the score first\n' "$$unit" "$$owner"; \
rm -f "$$report"; exit 1; \
fi; \
total=$$((total + 1)); \
done; \
rm -f "$$report"; \
done; \
printf 'translation-unit corpus retained=%s exact_retained=0\n' "$$total"
$(OVERLAY) audit --corpus
@printf 'candidate corpus ok: Proven C is installed; retained C is nonexact; nonowners are classified\n'
edition-builds: correspondence
@printf 'edition build report: %s\n' '$(REPORT_DIR)/exact-main-builds.json'
edition-builds-check: correspondence-check
@printf 'cross-edition edition-build audit ok\n'
coverage: | $(REPORT_DIR)
$(CHECK) coverage --write
coverage-check:
$(CHECK) coverage --check
core-retained-check:
$(CHECK) retained --check
source-tracking-check: prepare-inputs
$(CHECK) source-tracking
index-sync-check:
@git diff --quiet --ignore-submodules -- || { \
printf 'unstaged tracked changes found; stage the tree before make verify\n'; exit 1; \
}
@set -e; untracked=$$(git ls-files --others --exclude-standard); \
test -z "$$untracked" || { \
printf 'untracked files found; stage or ignore them before make verify:\n%s\n' "$$untracked"; exit 1; \
}
@printf 'index and worktree agree\n'
publication-tree-check:
$(CHECK) publication --tree
plan-tails-check:
$(CHECK) plan-tails
overlay-data-check:
$(CHECK) overlay-data --max $(OVERLAY_DATA_DIRECTIVES_MAX)
# Registered showcase folders must not regress; see "The Lunpa standard" in .agents/SOURCE.md.
showcase-check:
$(CHECK) showcase
check-owners: source-tracking-check
$(CHECK) owners
corpus-check:
@test -f "games/THE BROKEN SEAL/project.json"
@test -f "games/THE LOST AGE/PROJECT.JSON"
@if test -d draft; then \
printf 'legacy draft/ directory found; use games/THE BROKEN SEAL/recon/<edition>/\n'; \
exit 1; \
fi
@if find "games/THE BROKEN SEAL/semantic" -maxdepth 1 -name '*.c' -print | grep -q .; then \
printf 'source hypotheses belong in games/THE BROKEN SEAL/recon/, not games/THE BROKEN SEAL/semantic/ metadata\n'; \
exit 1; \
fi
@roots=$$(git ls-files -- games | cut -d/ -f2 | grep -vx COMMON | LC_ALL=C sort -u | tr '\n' '|'); \
test "$$roots" = 'THE BROKEN SEAL|THE LOST AGE|' || { \
printf 'games/ holds only the two game roots and the COMMON shared source root, found: %s\n' "$$roots"; exit 1; \
}
@printf 'corpus ok: two shared-source games, 12 edition targets, games/COMMON shared source only\n'
build-tools:
@set -e; for host in $(HOSTS); do \
printf ' build %-20s' "$$host"; \
$(CARGO) build --offline --quiet --release \
--manifest-path $(TOOLS)/$$host/Cargo.toml; \
printf ' ok\n'; \
done
tool-tests:
$(CARGO) test --offline --quiet --release --workspace \
--manifest-path $(TOOLS)/Cargo.toml
$(COMPILER) match --acceptance-test
tooling-size:
@for path in $(addprefix $(TOOLS)/,$(PORTABLE_TOOLS)); do \
test -d "$$path" || { printf 'missing counted tooling directory: %s\n' "$$path"; exit 1; }; \
done
@lines=$$(find $(addprefix $(TOOLS)/,$(PORTABLE_TOOLS)) -type f \
\( -name '*.rs' -o -name '*.js' -o -name '*.ts' -o -name '*.css' \) \
-not -path '*/target/*' -print0 | xargs -0 cat | wc -l | tr -d ' '); \
if [ "$$lines" -gt $(TOOLING_LINE_LIMIT) ]; then \
printf 'portable tooling is %s lines; limit is %s\n' "$$lines" '$(TOOLING_LINE_LIMIT)'; \
exit 1; \
fi; \
printf 'portable tooling ok: %s / %s lines\n' "$$lines" '$(TOOLING_LINE_LIMIT)'
tooling-index-check:
@$(CHECK) publication --documents
@set -eu; \
actual=$$(mktemp /tmp/alchemy-tool-index.actual.XXXXXX); \
indexed=$$(mktemp /tmp/alchemy-tool-index.indexed.XXXXXX); \
duplicates=$$(mktemp /tmp/alchemy-tool-index.duplicates.XXXXXX); \
trap 'rm -f "$$actual" "$$indexed" "$$duplicates"' EXIT; \
{ find tools -mindepth 2 -maxdepth 2 -name Cargo.toml -print | sed 's#tools/##;s#/Cargo.toml##'; \
find tools -mindepth 2 -maxdepth 2 -type f \( -name '*.ts' -o -name '*.js' -o -name '*.py' -o -name '*.sh' \) -print | sed 's#tools/##;s#/[^/]*$$##'; \
} | sort -u > "$$actual"; \
awk -F '[()]' '/^## Tooling index/ { inside=1; next } /^## / { inside=0 } inside && /^\| \[/ { sub(/^\.\.\/tools\//, "", $$2); sub(/\/$$/, "", $$2); print $$2 }' .agents/TOOLING.md | sort > "$$indexed"; \
uniq -d "$$indexed" > "$$duplicates"; \
test ! -s "$$duplicates" || { printf 'tooling index duplicates:\n'; cat "$$duplicates"; exit 1; }; \
diff -u "$$actual" "$$indexed"; \
printf 'tooling index ok: %s tools\n' "$$(wc -l < "$$actual" | tr -d ' ')"
# The registers are session state that a bare `git checkout -- <file>` can
# silently reset to the last commit, orphaning every source adopted since.
# `make verified-restore` puts games/<target> back to the last verified tree
# instead; `register-shrink-check` refuses a verify whose owner register has
# fewer entries than that tree unless RETIRE=1 says the shrink is deliberate.
verified-restore:
@set -eu; tree=$$(cat $(VERIFIED_TREE)); \
git cat-file -e "$$tree" || { printf 'no verified tree object: %s\n' "$$tree"; exit 1; }; \
git checkout "$$tree" -- "games/$(TARGET_GAME_DIR)"; \
git diff --cached --name-only -z --diff-filter=A "$$tree" -- "games/$(TARGET_GAME_DIR)" | xargs -0 -r git rm -q -f --cached; \
git diff --name-only -z --diff-filter=A "$$tree" -- "games/$(TARGET_GAME_DIR)" | xargs -0 -r rm -f; \
printf 'games/%s restored to verified tree %s\n' '$(TARGET_GAME_DIR)' "$$tree"
register-shrink-check:
@set -eu; test -s $(VERIFIED_TREE) || { printf 'register shrink check: no verified tree yet\n'; exit 0; }; \
tree=$$(cat $(VERIFIED_TREE)); \
git cat-file -e "$$tree:games/$(TARGET_GAME_DIR)/source-paths.json" 2>/dev/null || { printf 'register shrink check: previous tree lacks the register\n'; exit 0; }; \
before=$$(git cat-file -p "$$tree:games/$(TARGET_GAME_DIR)/source-paths.json" | grep -c '^ "'); \
after=$$(git show ":games/$(TARGET_GAME_DIR)/source-paths.json" | grep -c '^ "'); \
if [ "$$after" -lt "$$before" ] && [ "$${RETIRE:-0}" != "1" ]; then \
printf 'owner register shrank from %s to %s entries since verified tree %s; a retirement must say RETIRE=1, anything else is a wipe\n' "$$before" "$$after" "$$tree"; exit 1; fi; \
printf 'register shrink check ok: %s -> %s owners\n' "$$before" "$$after"
# Tooling and dashboard behavior are Rust.
# Asset and game source directories carry no scripts.
language-check:
@set -eu; \
scripts=$$(git ls-files --cached --others --exclude-standard | grep -E '\.(ts|js|mjs|cjs|py|sh)$$' || true); \
if [ -n "$$scripts" ]; then printf 'TypeScript, JavaScript, Python, or shell implementation files are not allowed:\n%s\n' "$$scripts"; exit 1; fi; \
printf 'language gate ok: Rust tooling and dashboard\n'
lint: lint-all-targets
lint-production: standard-check compiler-source-check
@set -e; git ls-files --cached --others --exclude-standard '*.rs' | while IFS= read -r source; do \
test ! -f "$$source" || rustfmt --edition 2021 --check "$$source"; \
done
$(CHECK) no-asm --target $(TARGET)
lint-all-targets: standard-check compiler-source-check
@set -e; git ls-files --cached --others --exclude-standard '*.rs' | while IFS= read -r source; do \
test ! -f "$$source" || rustfmt --edition 2021 --check "$$source"; \
done
$(CHECK) no-asm
test: toolchain-check native-format-check lint tooling-size tooling-index-check tool-tests compiler-source-check
$(CHECK) publication --self-test
$(CHECK) publication --tree
$(CHECK) commit-progress --self-test
$(CHECK) progress --self-test
$(CHECK) no-asm --self-test
native-format-check:
$(CARGO_RUN) $(TOOLS)/alchemy/Cargo.toml -- format --check
review-images-check: source-tracking-check
$(ASSETS) --review-images out/tbs-en/graphics-review
verify: toolchain-check native-format-check index-sync-check publication-tree-check plan-tails-check overlay-data-check source-tracking-check review-images-check $(if $(wildcard roms/tla-en.gba),tla-assets-check tla-owners-check) corpus-check language-check register-shrink-check lint-production tooling-size tooling-index-check \
strict-tu-check check-owners core-retained-check full-rom-check coverage-check showcase-check siblings-check | $(REPORT_DIR)
@tree=$$(git write-tree) || exit; \
printf '%s\n' "$$tree" > $(VERIFIED_TREE).tmp; \
mv $(VERIFIED_TREE).tmp $(VERIFIED_TREE); \
printf 'verified staged tree: %s\n' "$$tree"
audit: verify test targets classification-check candidate-corpus-check \
correspondence-check progress-report coverage-check
reports: correspondence progress-report coverage
standard-check:
@set -e; actual=$$($(CHECK) routes --standard | grep -v '^-I' | sort); \
expected=$$(printf '%s\n' $(GCC296_CFLAGS) | grep -v '^-I' | sort); \
test "$$actual" = "$$expected" || { printf 'compiler flags differ\nexpected:\n%s\nactual:\n%s\n' "$$expected" "$$actual"; exit 1; }
@printf 'compiler standard ok\n'
.PHONY: bootstrap compiler-sources compilers toolchain-check verify-clean prepare-inputs
# Every game's registered private inputs are checked by source tracking, so
# both indexed editions are restored whatever TARGET selects. A clone without
# The Lost Age ROM cannot restore that game's inputs; source tracking then
# checks their registration but not their absent bytes.
prepare-inputs:
$(ASSETS) --extract-missing-sources roms/tbs-en.gba
$(if $(wildcard roms/tla-en.gba),$(ASSETS) --extract-missing-sources roms/tla-en.gba --target tla-en)
bootstrap:
$(COMPILER) bootstrap $(if $(BUNDLE),--from "$(BUNDLE)")
toolchain-check:
$(COMPILER) bootstrap --check
# Check dependencies before cleaning so a missing installation leaves the
# current reports intact. Repeat after cleanup to enforce the storage boundary.
verify-clean: toolchain-check
$(MAKE) clean
$(MAKE) toolchain-check
$(MAKE) verify
compilers:
$(MAKE) compiler-sources
compiler-sources: compiler-source-check
sh agscc/build.sh
$(MAKE) -C agbcc/gcc old -j1
compiler-source-check:
@set -e; for repo in agbcc agscc; do \
case "$$repo" in \
agbcc) approved=da598c1d918402c42c0c0d7128ba14567f3175e9;; \
agscc) approved=f2095030ce7fa3b8991a5b5bdbe32a1860c6fa34;; \
esac; \
test "$$(git rev-parse :$$repo)" = "$$approved" || { printf '%s gitlink is not approved\n' "$$repo"; exit 1; }; \
test "$$(git -C "$$repo" rev-parse HEAD)" = "$$approved" || { printf '%s checkout is not approved\n' "$$repo"; exit 1; }; \
state=$$(git -C "$$repo" status --porcelain --untracked-files=all -- . ':(exclude,glob)**/.DS_Store'); \
test -z "$$state" || { printf '%s compiler source is dirty\n' "$$repo"; exit 1; }; \
done
@printf 'compiler sources match approved submodules\n'
CLEAN_TREES := out work build builds dist cmatch comparisons compiler-output \
diffs disassembly dumps m2c objdump reports analysis .cache target
clean-preview:
@printf 'would remove generated trees (never roms/):\n'; \
for tree in $(CLEAN_TREES); do \
if [ -e "$$tree" ]; then printf ' %-22s %s\n' "$$tree" "$$(du -sh "$$tree" | cut -f1)"; fi; \
done
clean:
@for tree in $(CLEAN_TREES); do \
if [ -e "$$tree" ]; then rm -rf -- "$$tree"; fi; \
done
@find $(TOOLS) -type d -name target -prune -exec rm -rf -- {} +
@printf 'generated trees removed; roms/ untouched\n'
# Both games build the licensed agscc submodule; TLA selects -mgs2 at compile time.
.PHONY: compilers-tla
compilers-tla: compilers