Commit 0329df95
0329df9568dcMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 7 files · +5 added · ~2 modified
Description
Ship spinel-doctor / spinel-reduce / spinel-flatten in tools/
Three developer tools that ride along with the compiler, written in the
spinel subset and compiled by spinel itself so their only runtime
dependency is cc (the same as the compiler) -- no Ruby and no python at
run time. They are companion executables (spinel-doctor, the git-* style)
rather than subcommands, because spinel's command line is
spinel [flags] <app.rb> with the source file as the first positional;
a verb there would fork the argument parser. The companion form reads
like a subcommand to users while leaving the compiler's parser untouched.
- spinel-doctor: one health report -- build (compile + C-build, line- mapped), unsupported (codegen stubs), unresolved (silent nil/0 calls, via SPINEL_WARN_UNRESOLVED), requires (native/no-op requires), and an optional behavior leg (compiled output vs CRuby) that skips cleanly when ruby is absent.
- spinel-reduce: ddmin a degrading program to a minimal repro, with the doctor checks (or a custom --oracle-cmd) as the interestingness test.
- spinel-flatten: inline a require_relative graph into one file.
Build/install: make compiles each tools/.rb to build/spinel-
(wired into all); make install places them on PATH beside spinel
so each is found next to the compiler it drives, and the run-time
discovery is $SPINEL / $SPINEL_DIR / PATH. A tool that stops fitting the
subset breaks the build, keeping them honest.
Behavior and ideas adapted from the spinel-dev tooling (RFC #1381); implemented in-tree here. Refs #1381
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- 0329df9568dc
- Parent
- e25d8e3e2050
MakefilemodifiedView file
.PHONY: all parse legacy bootstrap codegen regexp rbs_extract rbs-test rbs-seed-test \ analyze-fail-test test test-run clean-test-results regen-rbs-expected \ regen-expected bench optcarrot gate check gate-legs gate-test gate-bench \ gate-optcarrot clean install uninstall deps gate-optcarrot clean install uninstall deps tools# `make all` includes spinel_rbs_extract when vendor/rbs has been fetched# (via `make deps`); without it the extractor is silently omitted.# `all` rule, because a rule's prerequisites are expanded as it is read.SPINEL = build/spinel$(EXE)all: parse regexp $(SPINEL) $(RBS_EXTRACT_TARGET)all: parse regexp $(SPINEL) $(RBS_EXTRACT_TARGET) tools# ---- Dependencies ----deps: vendor/prism/include/prism/diagnostic.h vendor/rbs/include/rbs/parser.hregexp: $(SP_RT_LIB)# ---- In-tree developer tools ----# spinel-doctor / spinel-reduce / spinel-flatten: written in the spinel subset# and compiled by spinel itself (dogfood), so their only runtime dependency is# cc — the same as the compiler. Each tools/<name>.rb becomes build/spinel-<name>;# install places them beside `spinel` so the `spinel-<name>` command is found# next to the compiler it drives. A tool that no longer fits the subset breaks# the build, which keeps them honest.TOOL_NAMES = doctor reduce flattenTOOL_BINS = $(addprefix build/spinel-,$(TOOL_NAMES))tools: $(TOOL_BINS)build/spinel-%$(EXE): tools/%.rb tools/tool_common.rb $(SPINEL) $(SP_RT_LIB) $(SPINEL) $< -o $@# ---- Test ----TESTS := $(wildcard test/*.rb) install -m 644 lib/*.rb $(SPNLDIR)/lib/ install -d $(PREFIX)/bin ln -sf $(SPNLDIR)/spinel $(PREFIX)/bin/spinel for t in $(TOOL_NAMES); do \ install -m 755 build/spinel-$$t$(EXE) $(PREFIX)/bin/spinel-$$t$(EXE); \ doneuninstall: rm -f $(PREFIX)/bin/spinel for t in $(TOOL_NAMES); do rm -f $(PREFIX)/bin/spinel-$$t$(EXE); done rm -rf $(SPNLDIR)# ---- Clean ----README.mdmodifiedView file
Loading diff…
tools/README.mdaddedView file
Loading diff…
tools/doctor.rbaddedView file
Loading diff…
tools/flatten.rbaddedView file
Loading diff…
tools/reduce.rbaddedView file
Loading diff…
tools/tool_common.rbaddedView file
Loading diff…