From 3338a617cccd61484e078459cb235c303cd1e241 Mon Sep 17 00:00:00 2001 From: Steve Dunham Date: Sun, 29 Mar 2026 09:11:27 -0700 Subject: [PATCH] Move build products to `build` directory --- .gitignore | 7 +--- Makefile | 88 ++++++++++++++++++++--------------------- playground/build | 7 ++-- scripts/aoc | 2 +- scripts/aoc25 | 2 +- scripts/compile-chez.ss | 2 +- scripts/test | 4 +- 7 files changed, 54 insertions(+), 58 deletions(-) diff --git a/.gitignore b/.gitignore index 9aee438..a8ca8a4 100644 --- a/.gitignore +++ b/.gitignore @@ -4,21 +4,18 @@ build/ *.swp *.log *.bak -*.agda -*.agdai -/newt*.js input.txt node_modules mkday.py tmp min.js.gz src/Revision.newt -newt.ss -newt.so .calva .clj-kondo .joyride .lsp .vscode +.helix bootstrap/serializer.js /newt-vscode-lsp/src/newt.js +/playground/src/newt.js diff --git a/Makefile b/Makefile index a91089f..7cd2249 100644 --- a/Makefile +++ b/Makefile @@ -1,51 +1,24 @@ SRCS=$(shell find src -name "*.newt") -# Node shaves off 40% of the time. -# RUNJS=bun run -RUNJS=node - .PHONY: -all: newt.js +all: build/newt.js +newt2: build/newt2.js -src/Revision.newt: .PHONY - sh ./scripts/mkrevision +newt3: build/newt3.js -newt.js: ${SRCS} src/Revision.newt - $(RUNJS) bootstrap/newt.js src/Main.newt -o newt.js - -newt2.js: newt.js - $(RUNJS) newt.js src/Main.newt -o newt2.js - -newt3.js: newt2.js - time $(RUNJS) newt2.js src/Main.newt -o newt3.js - cmp newt2.js newt3.js - -newt.ss: newt.js - $(RUNJS) newt.js src/Main.newt -o newt.ss - -newt.so: newt.ss prim.ss - chez --script scripts/compile-chez.ss - -newt2.ss: newt.so - time chez --program newt.so src/Main.newt -o newt2.ss - -test: newt.js +test: build/newt.js scripts/test -cheztest: newt.so - make test NEWT='chez --program newt.so' RUNOUT="chez --script" OUTFILE=tmp/out.ss +cheztest: build/newt.so + make test NEWT='chez --program build/newt.so' RUNOUT="chez --script" OUTFILE=tmp/out.ss -aoctest: newt.js +aoctest: build/newt.js scripts/aoc scripts/aoc25 -# Misc - -# build / install old vscode extension -# vscode: - # cd newt-vscode && vsce package && code --install-extension *.vsix +lsp: newt-vscode-lsp/dist/lsp.js playground/src/newt.js # build / install new LSP vscode extension vscode-lsp vscode: lsp @@ -55,29 +28,56 @@ playground: .PHONY cd playground && ./build profile: .PHONY - rm isolate* build/*; node --prof newt.js -o newt2.js src/Main.newt + rm isolate* build/* + node --prof build/newt.js -o build/newt2.js src/Main.newt node --prof-process isolate* > profile.txt clean: - rm newt*.js iife.js min.js min.js.gz + rm build/* audit: .PHONY (cd playground && npm audit) (cd newt-vscode && npm audit) (cd newt-vscode-lsp && npm audit) -lsp.js: ${SRCS} - node newt.js src/LSP.newt -o lsp.js +## -newt-vscode-lsp/src/newt.js: lsp.js - cp lsp.js $@ +build: + mkdir -p build -playground/src/newt.js: lsp.js - cp lsp.js $@ +src/Revision.newt: .PHONY build + sh ./scripts/mkrevision + +build/newt.js: ${SRCS} src/Revision.newt build + node bootstrap/newt.js src/Main.newt -o build/newt.js + +build/newt2.js: build/newt.js + node build/newt.js src/Main.newt -o build/newt2.js + +build/newt3.js: build/newt2.js + time node build/newt2.js src/Main.newt -o build/newt3.js + cmp build/newt2.js build/newt3.js + +build/newt.ss: build/newt.js + node build/newt.js src/Main.newt -o build/newt.ss + +build/newt.so: build/newt.ss prim.ss + chez --script scripts/compile-chez.ss + +build/newt2.ss: build/newt.so + time chez --program build/newt.so src/Main.newt -o build/newt2.ss + +build/lsp.js: ${SRCS} build/newt.js + node build/newt.js src/LSP.newt -o build/lsp.js + +newt-vscode-lsp/src/newt.js: build/lsp.js + cp build/lsp.js $@ + +playground/src/newt.js: build/lsp.js + cp build/lsp.js $@ newt-vscode-lsp/dist/lsp.js: newt-vscode-lsp/src/lsp.ts newt-vscode-lsp/src/newt.js (cd newt-vscode-lsp && node esbuild.js) chmod +x $@ -lsp: newt-vscode-lsp/dist/lsp.js playground/src/newt.js diff --git a/playground/build b/playground/build index 861788c..4b3a64a 100755 --- a/playground/build +++ b/playground/build @@ -1,8 +1,7 @@ -#!/bin/bash +#!/bin/bash mkdir -p public -echo copy newt -(cd .. && make lsp.js) -cp ../lsp.js src/newt.js +echo build lsp.js +(cd .. && make lsp) echo build newt worker esbuild src/worker.ts --bundle --format=esm --platform=browser > public/worker.js esbuild src/frame.ts --bundle --format=esm --platform=browser > public/frame.js diff --git a/scripts/aoc b/scripts/aoc index 56a539f..bfb515a 100755 --- a/scripts/aoc +++ b/scripts/aoc @@ -2,7 +2,7 @@ mkdir -p tmp echo "Test AoC 2024 solutions" # FIXME - it turns out there are some stack issues here (including length) -NCC="bun run newt.js" +NCC="bun run build/newt.js" total=0 failed=0 for fn in aoc2024/Day*.newt; do diff --git a/scripts/aoc25 b/scripts/aoc25 index 7293507..4156f22 100755 --- a/scripts/aoc25 +++ b/scripts/aoc25 @@ -1,7 +1,7 @@ #!/bin/sh mkdir -p tmp echo "Test AoC 2025 solutions" -NCC="node newt.js" +NCC="node build/newt.js" total=0 failed=0 for fn in aoc2025/Day*.newt; do diff --git a/scripts/compile-chez.ss b/scripts/compile-chez.ss index 9861f67..69fda53 100644 --- a/scripts/compile-chez.ss +++ b/scripts/compile-chez.ss @@ -1 +1 @@ -(parameterize ([optimize-level 3]) (compile-program "newt.ss")) +(parameterize ([optimize-level 3]) (compile-program "build/newt.ss")) diff --git a/scripts/test b/scripts/test index 995ce90..362a370 100755 --- a/scripts/test +++ b/scripts/test @@ -1,7 +1,7 @@ #!/bin/sh SAMPLES=$(find playground/samples -name "*.newt") -# NEWT ="bun run newt.js" -NEWT=${NEWT:="node newt.js"} +# NEWT ="bun run build/newt.js" +NEWT=${NEWT:="node build/newt.js"} OUTFILE=${OUTFILE:="tmp/out.js"} RUNOUT=${RUNOUT:="node"} mkdir -p tmp