selfhost: migrate tool sources to directory packages

Build w6a and w6l from package-main directories and expose the wcc backend through a narrow package API so w6c and wwdump no longer import implementation files. Retarget the remaining load-bearing fixtures and example sources to directory packages; retain the one intentional flat compiler collision as an explicitly composed raw unit.
This commit is contained in:
2026-08-12 17:12:03 +09:00
parent 90f9d60291
commit c7d9dc92de
38 changed files with 197 additions and 252 deletions

View File

@@ -3,17 +3,14 @@
#
# Layout
# lisp.ww entry point. `use lispcore;` + `main()` = repl().
# lispcore.ww interpreter module. Types/functions are `export`-ed
# lispcore/ interpreter package. Types/functions are `export`-ed
# so both lisp.ww and lisp_test.ww consume them via
# the same `use lispcore;`.
# lisp_test.ww in-process test driver, executed by `make test`
# (which invokes `ww test`).
#
# `ww`'s module resolver uses the *directory's basename* as the module
# name when finding `lispcore.ww` through `-I <dir>`. Passing the
# absolute path of the current directory keeps that name stable
# (otherwise `-I.` collapses to ".", and the cgen mangles symbols as
# `..helper`, which then breaks the assembler).
# The absolute include root makes `import lispcore` resolve the canonical
# lispcore/ directory regardless of the caller's working directory.
# Drive the wwstage cgen (w6c_ww) by default. The C-stage cgen has
# unfixed silent-miscompilation traps that lispcore used to dodge by
@@ -25,7 +22,7 @@ W6CWW := $(shell cd ../..; pwd)/out/bin/w6c_ww
HERE := $(shell pwd)
WWENV := WW_W6C=$(W6CWW)
lisp: lisp.ww lispcore.ww
lisp: lisp.ww lispcore/lispcore.ww
$(WWENV) $(WW) build lisp.ww -I $(HERE)
# `ww test <file.ww>` in single-file mode discards extra args, so we
@@ -34,7 +31,7 @@ lisp: lisp.ww lispcore.ww
test: lisp_test lisp
./lisp_test
lisp_test: lisp_test.ww lispcore.ww
lisp_test: lisp_test.ww lispcore/lispcore.ww
$(WWENV) $(WW) build lisp_test.ww -I $(HERE)
# Demo programs in tree. `make demo` runs every test_*.lisp through