Skip to content

Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.

fix file structure build

Lily Pitiot266691958bff
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index f3764a16..149a0984 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -42,23 +42,23 @@ jobs:
rustup target add thumbv7em-none-eabihf
- name: Build
- run: make -j4 nwa apps check NWLINK=nwlink && make lang NWLINK=nwlink
+ run: python3 tools/build.py -j 4
- uses: actions/upload-artifact@v4
with:
name: nwa
path: |
- build/NumPlay*.nwa
- build/apps/*.nwa
+ build/compiled/NumPlay*.nwa
+ build/compiled/games/*.nwa
- name: Test
run: |
- python3 tests/test_games.py build/apps
- python3 tests/test_uninstall.py build/NumPlay.nwa --game numdrive
- python3 tests/test_progress.py build/NumPlay.nwa
- python3 tests/test_numblocks_progress.py build/apps/NumBlocks.nwa
- python3 tests/test_upsilon.py build/NumPlay-Upsilon.nwa
- python3 tests/test_small_ram.py build/NumPlay.nwa
+ python3 tests/test_games.py build/compiled/games
+ python3 tests/test_uninstall.py build/compiled/NumPlay.nwa --game numdrive
+ python3 tests/test_progress.py build/compiled/NumPlay.nwa
+ python3 tests/test_numblocks_progress.py build/compiled/games/NumBlocks.nwa
+ python3 tests/test_upsilon.py build/compiled/NumPlay-Upsilon.nwa
+ python3 tests/test_small_ram.py build/compiled/NumPlay.nwa
make -C games/numblocks host test
make -C games/championisland host test
make -C games/undertale host test
@@ -98,9 +98,9 @@ jobs:
echo "$tag is already released"
exit 0
fi
- python3 tools/release.py --tag "$tag" --notes build/release-notes.md > build/release-files.txt
- mapfile -t files < build/release-files.txt
+ python3 tools/release.py --tag "$tag" --notes build/data/release-notes.md --build build/compiled > build/data/release-files.txt
+ mapfile -t files < build/data/release-files.txt
gh release create "$tag" "${files[@]}" --target "$GITHUB_SHA" \
- --title "NumPlay $tag" --notes-file build/release-notes.md
+ --title "NumPlay $tag" --notes-file build/data/release-notes.md
# the README's version and downloads badges come from the site (docs/badges): deploy it again
gh workflow run pages.yml --ref main || echo "(the site was not deployed again)"
diff --git a/Makefile b/Makefile
index 452bba02..03d5bc26 100644
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,11 @@ ARM_LD = arm-none-eabi-ld
ARM_OBJCOPY = arm-none-eabi-objcopy
PY ?= python3
CARGO ?= cargo
-B = build
+B = build/data
+# Conventional games honor a configurable output directory; special layouts are kept local.
+GAMES_REDIRECT = balatro blockblast breakout buckshot celeste championisland chess connectfour cookieclicker coreball dinorun donkeykong doodlejump doom finalearth2 flappybird flappydunk fnaf g2048 hillclimb hollowknight invaders isaac jetpackjoyride leveldevil minesweeper numblocks numpowder numvisuals pacman portal pvz snake sokoban solitaire sonic stickmanhook subway sudoku suika towerblock twoplayer undertale uttt
+GAMES_OUT = dinorun
+GAME_REDIRECT_ARG = $(if $(filter $(1),$(GAMES_OUT)),OUT=../../$(B)/games/$(1),BUILD_DIR=../../$(B)/games/$(1))
# the RAM the oldest calculator software that runs apps gives them (23.2: 148928 bytes; 25.2 gives 153676).
# NumPlay itself takes less: a game goes on past it into the RAM the software has left (see
# tools/gen_games.py), so it installs with less too, custom builds of the software say, where a game that
@@ -76,10 +80,10 @@ $(B):
MOD_numdash = games/numdash/build/module.o
MOD_crossyroad = games/crossyroad/output/module.o
MOD_numdrive = games/numdrive/output/device/module.o
-MOD_balatro = games/balatro/output/module.o
-MOD_buckshot = games/buckshot/output/module.o
-MOD_portal = games/portal/output/module.o
-MOD_chess = games/chess/output/module.o
+MOD_balatro = $(B)/games/balatro/module.o
+MOD_buckshot = $(B)/games/buckshot/module.o
+MOD_portal = $(B)/games/portal/module.o
+MOD_chess = $(B)/games/chess/module.o
MOD_tetris = $(B)/tetris/raw.o
ENTRY = main
ENTRY_tetris = np_tetris_main
@@ -91,7 +95,7 @@ $(B)/tetris/raw.o: FORCE | $(B)
games/tetris/tetris/target/thumbv7em-none-eabihf/release/libtetris.a -o $@
$(B)/modules/%.o: FORCE | $(B)
- @if [ "$*" != tetris ]; then $(MAKE) --no-print-directory -C games/$* module NWLINK="$(NWLINK)"; \
+ @if [ "$*" != tetris ]; then $(MAKE) --no-print-directory -C games/$* module NWLINK="$(NWLINK)" $(if $(filter $*,$(GAMES_REDIRECT)),$(call GAME_REDIRECT_ARG,$*),); \
else $(MAKE) --no-print-directory $(MOD_tetris); fi
$(ARM_LD) -r -d -T tools/module.ld $(MOD_$*) -o $(B)/modules/$*.1.o
$(ARM_OBJCOPY) --keep-global-symbol=$(or $(ENTRY_$*),$(ENTRY)) \
@@ -102,7 +106,7 @@ $(B)/modules/%.o: FORCE | $(B)
--entry $(or $(ENTRY_$*),$(ENTRY)) --json $(B)/modules/$*.json
# games in the standard layout (see tools/games_mk.py)
-$(foreach g,$(STD_GAMES),$(eval MOD_$(g) = games/$(g)/output/module.o)$(eval SIM_$(g) = games/$(g)/output/sim-module.o))
+$(foreach g,$(STD_GAMES),$(eval MOD_$(g) = $(if $(filter $(g),$(GAMES_REDIRECT)),$(B)/games/$(g)/module.o,games/$(g)/output/module.o))$(eval SIM_$(g) = $(if $(filter $(g),$(GAMES_REDIRECT)),$(B)/games/$(g)/sim-module.o,games/$(g)/output/sim-module.o)))
MODULES = $(foreach g,$(GAMES),$(B)/modules/$(g).o)
@@ -183,75 +187,75 @@ lang: $(foreach l,$(LANGS),$(B)/NumPlay-$(LANG_$(l)).nwa)
$(foreach l,$(LANGS),$(B)/NumPlay-$(LANG_$(l)).nwa): $(B)/NumPlay-%.nwa: FORCE | $(B)
$(eval L := $(if $(filter French,$*),fr,zh))
$(PY) tools/lang.py tree $(L) $(B)/lang/$(L)
- $(MAKE) -C $(B)/lang/$(L) build/NumPlay.nwa NWLINK="$(NWLINK)"
- $(NWLINK) nwa-bin --ram-length $$(( $(CUSTOM_RAM) - $$(cat $(B)/lang/$(L)/build/gen/arena_extra) )) \
- $(B)/lang/$(L)/build/NumPlay.nwa $(B)/lang/$(L)/build/NumPlay.bin
- @n=$$(wc -c < $(B)/lang/$(L)/build/NumPlay.bin); echo "NumPlay-$*.nwa installs as $$n bytes ($$(( $(APP_SPACE) - n )) to spare)"; \
+ $(MAKE) -C $(B)/lang/$(L) build/data/NumPlay.nwa NWLINK="$(NWLINK)"
+ $(NWLINK) nwa-bin --ram-length $$(( $(CUSTOM_RAM) - $$(cat $(B)/lang/$(L)/build/data/gen/arena_extra) )) \
+ $(B)/lang/$(L)/build/data/NumPlay.nwa $(B)/lang/$(L)/build/data/NumPlay.bin
+ @n=$$(wc -c < $(B)/lang/$(L)/build/data/NumPlay.bin); echo "NumPlay-$*.nwa installs as $$n bytes ($$(( $(APP_SPACE) - n )) to spare)"; \
[ $$n -le $(APP_SPACE) ] || { echo "NumPlay-$*.nwa is bigger than the calculator's app space"; exit 1; }
- cp $(B)/lang/$(L)/build/NumPlay.nwa $@
+ cp $(B)/lang/$(L)/build/data/NumPlay.nwa $@
# ------------------------------------------------------------------ games on their own
APP_numdash = games/numdash/build/numdash.nwa:NumDash.nwa
APP_crossyroad = games/crossyroad/output/crossyroad.nwa:CrossyRoad.nwa
APP_numdrive = games/numdrive/output/device/numdrive.nwa:NumDrive.nwa
-APP_balatro = games/balatro/output/balatro.nwa:Balatro.nwa
-APP_buckshot = games/buckshot/output/buckshot.nwa:BuckshotRoulette.nwa
-APP_portal = games/portal/output/portal.nwa:PortalReturns.nwa
-APP_chess = games/chess/output/chess.nwa:NumChess.nwa
+APP_balatro = $(B)/games/balatro/balatro.nwa:Balatro.nwa
+APP_buckshot = $(B)/games/buckshot/buckshot.nwa:BuckshotRoulette.nwa
+APP_portal = $(B)/games/portal/portal.nwa:PortalReturns.nwa
+APP_chess = $(B)/games/chess/chess.nwa:NumChess.nwa
APP_tetris = games/tetris/tetris/target/thumbv7em-none-eabihf/release/tetris:Tetris.nwa
# Tetris on its own, without building every game (tools/build.py --game tetris)
tetris-app: | $(B)
cd games/tetris/tetris && NWLINK="$(NWLINK)" $(CARGO) build --release --quiet
cp $(word 1,$(subst :, ,$(APP_tetris))) $(B)/apps/Tetris.nwa
arm-none-eabi-strip --strip-unneeded $(B)/apps/Tetris.nwa
-APP_numvisuals = games/numvisuals/output/numvisuals.nwa:NumVisuals.nwa
+APP_numvisuals = $(B)/games/numvisuals/numvisuals.nwa:NumVisuals.nwa
# too big to share the calculator's app space with NumPlay: only on their own
-APP_celeste = games/celeste/output/celeste.nwa:Celeste.nwa
-APP_championisland = games/championisland/output/championisland.nwa:ChampionIsland.nwa
-APP_hollowknight = games/hollowknight/output/hollowknight.nwa:HollowKnight.nwa
-APP_undertale = games/undertale/output/undertale.nwa:Undertale.nwa
-APP_subway = games/subway/output/subway.nwa:SubwaySurfers.nwa
-APP_fnaf = games/fnaf/output/fnaf.nwa:FiveNightsAtFreddys.nwa
-APP_hillclimb = games/hillclimb/output/hillclimb.nwa:HillClimbRacing.nwa
-APP_finalearth2 = games/finalearth2/output/finalearth2.nwa:FinalEarth2.nwa
-APP_numpowder = games/numpowder/output/numpowder.nwa:NumPowder.nwa
-APP_doom = games/doom/output/doom.nwa:Doom.nwa
-APP_isaac = games/isaac/output/isaac.nwa:BindingOfIsaac.nwa
-APP_pvz = games/pvz/output/pvz.nwa:PlantsVsZombies.nwa
-APP_sonic = games/sonic/output/sonic.nwa:SonicTheHedgehog.nwa
-APP_cookieclicker = games/cookieclicker/output/cookieclicker.nwa:CookieClicker.nwa
-APP_leveldevil = games/leveldevil/output/leveldevil.nwa:LevelDevil.nwa
-APP_jetpackjoyride = games/jetpackjoyride/output/jetpackjoyride.nwa:JetpackJoyride.nwa
-APP_stickmanhook = games/stickmanhook/output/stickmanhook.nwa:StickmanHook.nwa
-APP_donkeykong = games/donkeykong/output/donkeykong.nwa:DonkeyKong.nwa
+APP_celeste = $(B)/games/celeste/celeste.nwa:Celeste.nwa
+APP_championisland = $(B)/games/championisland/championisland.nwa:ChampionIsland.nwa
+APP_hollowknight = $(B)/games/hollowknight/hollowknight.nwa:HollowKnight.nwa
+APP_undertale = $(B)/games/undertale/undertale.nwa:Undertale.nwa
+APP_subway = $(B)/games/subway/subway.nwa:SubwaySurfers.nwa
+APP_fnaf = $(B)/games/fnaf/fnaf.nwa:FiveNightsAtFreddys.nwa
+APP_hillclimb = $(B)/games/hillclimb/hillclimb.nwa:HillClimbRacing.nwa
+APP_finalearth2 = $(B)/games/finalearth2/finalearth2.nwa:FinalEarth2.nwa
+APP_numpowder = $(B)/games/numpowder/numpowder.nwa:NumPowder.nwa
+APP_doom = $(B)/games/doom/doom.nwa:Doom.nwa
+APP_isaac = $(B)/games/isaac/isaac.nwa:BindingOfIsaac.nwa
+APP_pvz = $(B)/games/pvz/pvz.nwa:PlantsVsZombies.nwa
+APP_sonic = $(B)/games/sonic/sonic.nwa:SonicTheHedgehog.nwa
+APP_cookieclicker = $(B)/games/cookieclicker/cookieclicker.nwa:CookieClicker.nwa
+APP_leveldevil = $(B)/games/leveldevil/leveldevil.nwa:LevelDevil.nwa
+APP_jetpackjoyride = $(B)/games/jetpackjoyride/jetpackjoyride.nwa:JetpackJoyride.nwa
+APP_stickmanhook = $(B)/games/stickmanhook/stickmanhook.nwa:StickmanHook.nwa
+APP_donkeykong = $(B)/games/donkeykong/donkeykong.nwa:DonkeyKong.nwa
apps: | $(B)
$(MAKE) -C games/numdash build NWLINK="node node_modules/nwlink/bin/nwlink"
$(MAKE) -C games/crossyroad NWLINK="$(NWLINK)"
$(MAKE) -C games/numdrive NWLINK="$(NWLINK)"
- $(MAKE) -C games/balatro build NWLINK="$(NWLINK)"
- $(MAKE) -C games/buckshot build NWLINK="$(NWLINK)"
- $(MAKE) -C games/portal build NWLINK="$(NWLINK)"
- $(MAKE) -C games/chess build NWLINK="$(NWLINK)"
- $(MAKE) -C games/numvisuals build NWLINK="$(NWLINK)"
- $(MAKE) -C games/celeste build NWLINK="$(NWLINK)"
- $(MAKE) -C games/championisland build NWLINK="$(NWLINK)"
- $(MAKE) -C games/hollowknight build NWLINK="$(NWLINK)"
- $(MAKE) -C games/undertale build NWLINK="$(NWLINK)"
- $(MAKE) -C games/subway build NWLINK="$(NWLINK)"
- $(MAKE) -C games/fnaf build NWLINK="$(NWLINK)"
- $(MAKE) -C games/hillclimb build NWLINK="$(NWLINK)"
- $(MAKE) -C games/finalearth2 build NWLINK="$(NWLINK)"
- $(MAKE) -C games/numpowder build NWLINK="$(NWLINK)"
- $(MAKE) -C games/doom build NWLINK="$(NWLINK)"
- $(MAKE) -C games/isaac build NWLINK="$(NWLINK)"
- $(MAKE) -C games/pvz build NWLINK="$(NWLINK)"
- $(MAKE) -C games/sonic build NWLINK="$(NWLINK)"
- $(MAKE) -C games/cookieclicker build NWLINK="$(NWLINK)"
- $(MAKE) -C games/leveldevil build NWLINK="$(NWLINK)"
- $(MAKE) -C games/jetpackjoyride build NWLINK="$(NWLINK)"
- $(MAKE) -C games/stickmanhook build NWLINK="$(NWLINK)"
- $(MAKE) -C games/donkeykong build NWLINK="$(NWLINK)"
+ $(MAKE) -C games/balatro build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/balatro
+ $(MAKE) -C games/buckshot build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/buckshot
+ $(MAKE) -C games/portal build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/portal
+ $(MAKE) -C games/chess build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/chess
+ $(MAKE) -C games/numvisuals build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/numvisuals
+ $(MAKE) -C games/celeste build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/celeste
+ $(MAKE) -C games/championisland build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/championisland
+ $(MAKE) -C games/hollowknight build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/hollowknight
+ $(MAKE) -C games/undertale build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/undertale
+ $(MAKE) -C games/subway build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/subway
+ $(MAKE) -C games/fnaf build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/fnaf
+ $(MAKE) -C games/hillclimb build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/hillclimb
+ $(MAKE) -C games/finalearth2 build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/finalearth2
+ $(MAKE) -C games/numpowder build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/numpowder
+ $(MAKE) -C games/doom build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/doom
+ $(MAKE) -C games/isaac build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/isaac
+ $(MAKE) -C games/pvz build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/pvz
+ $(MAKE) -C games/sonic build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/sonic
+ $(MAKE) -C games/cookieclicker build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/cookieclicker
+ $(MAKE) -C games/leveldevil build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/leveldevil
+ $(MAKE) -C games/jetpackjoyride build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/jetpackjoyride
+ $(MAKE) -C games/stickmanhook build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/stickmanhook
+ $(MAKE) -C games/donkeykong build NWLINK="$(NWLINK)" BUILD_DIR=../../$(B)/games/donkeykong
cd games/tetris/tetris && NWLINK="$(NWLINK)" $(CARGO) build --release --quiet
cp $(word 1,$(subst :, ,$(APP_numdash))) $(B)/apps/$(word 2,$(subst :, ,$(APP_numdash)))
cp $(word 1,$(subst :, ,$(APP_crossyroad))) $(B)/apps/$(word 2,$(subst :, ,$(APP_crossyroad)))
@@ -285,17 +289,17 @@ apps: | $(B)
STD_APPS = $(foreach g,$(STD_GAMES),$(B)/apps/$(NWA_$(g)))
apps: $(STD_APPS)
$(STD_APPS): $(B)/apps/%.nwa: FORCE | $(B)
- $(MAKE) --no-print-directory -C games/$(APPID_$*) build NWLINK="$(NWLINK)"
- cp games/$(APPID_$*)/output/$(APPID_$*).nwa $@
+ $(MAKE) --no-print-directory -C games/$(APPID_$*) build NWLINK="$(NWLINK)" $(if $(filter $(APPID_$*),$(GAMES_REDIRECT)),$(call GAME_REDIRECT_ARG,$(APPID_$*)),)
+ cp $(if $(filter $(APPID_$*),$(GAMES_REDIRECT)),$(B)/games/$(APPID_$*)/$(APPID_$*).nwa,games/$(APPID_$*)/output/$(APPID_$*).nwa) $@
# ------------------------------------------------------------------ simulator
SIM_numdash = games/numdash/build/sim-module.o
SIM_crossyroad = games/crossyroad/output/sim-module.o
SIM_numdrive = games/numdrive/output/sim-module.o
-SIM_balatro = games/balatro/output/sim-module.o
-SIM_buckshot = games/buckshot/output/sim-module.o
-SIM_portal = games/portal/output/sim-module.o
-SIM_chess = games/chess/output/sim-module.o
+SIM_balatro = $(B)/games/balatro/sim-module.o
+SIM_buckshot = $(B)/games/buckshot/sim-module.o
+SIM_portal = $(B)/games/portal/sim-module.o
+SIM_chess = $(B)/games/chess/sim-module.o
SIM_tetris = $(B)/sim/tetris.o
SIM_CFLAGS = -std=gnu11 -O2 -fPIC -DNP_SIMULATOR=1 -DNP_VERSION='"$(VERSION)"' $(EADK_SIM_CFLAGS) -Ilauncher/src -Wall -Wno-unused-parameter
@@ -305,7 +309,7 @@ $(B)/sim/tetris.o: FORCE | $(B)
games/tetris/tetris/target/aarch64-apple-darwin/release/libtetris.a -o $@
$(B)/sim/%.mod: FORCE | $(B)
- @if [ "$*" != tetris ]; then $(MAKE) --no-print-directory -C games/$* sim-module NWLINK="$(NWLINK)"; \
+ @if [ "$*" != tetris ]; then $(MAKE) --no-print-directory -C games/$* sim-module NWLINK="$(NWLINK)" $(if $(filter $*,$(GAMES_REDIRECT)),$(call GAME_REDIRECT_ARG,$*),); \
else $(MAKE) --no-print-directory $(SIM_tetris); fi
$(B)/sim/gen/gametable.c: games/games.json tools/gen_games.py $(MODULES)
@@ -322,31 +326,4 @@ emu: $(B)/NumPlay.nwa
$(PY) tools/emu.py $< --ms 4000 --shots 3000 --out $(B)/emu
clean:
- rm -rf $(B)
- -$(MAKE) -C games/numdash clean
- -$(MAKE) -C games/crossyroad clean
- -$(MAKE) -C games/numdrive clean
- -$(MAKE) -C games/balatro clean
- -$(MAKE) -C games/buckshot clean
- -$(MAKE) -C games/portal clean
- -$(MAKE) -C games/chess clean
- -$(MAKE) -C games/numvisuals clean
- -$(MAKE) -C games/championisland clean
- -$(MAKE) -C games/hollowknight clean
- -$(MAKE) -C games/undertale clean
- -$(MAKE) -C games/subway clean
- -$(MAKE) -C games/fnaf clean
- -$(MAKE) -C games/hillclimb clean
- -$(MAKE) -C games/finalearth2 clean
- -$(MAKE) -C games/numpowder clean
- -$(MAKE) -C games/doom clean
- -$(MAKE) -C games/isaac clean
- -$(MAKE) -C games/pvz clean
- -$(MAKE) -C games/sonic clean
- -$(MAKE) -C games/cookieclicker clean
- -$(MAKE) -C games/leveldevil clean
- -$(MAKE) -C games/jetpackjoyride clean
- -$(MAKE) -C games/stickmanhook clean
- -$(MAKE) -C games/donkeykong clean
- -cd games/tetris/tetris && $(CARGO) clean
- -$(foreach g,$(STD_GAMES),$(MAKE) -C games/$(g) clean;)
+ rm -rf $(B) build/compiled
diff --git a/tools/build.py b/tools/build.py
index 6fadd947..529027c0 100644
--- a/tools/build.py
+++ b/tools/build.py
@@ -10,7 +10,7 @@ Run from PowerShell (Windows) or a terminal (macOS/Linux):
python tools/build.py --organize-only
python tools/build.py --watch --launcher-only --skip-languages -j2
-It keeps Make's intermediate outputs untouched under build/ and atomically
+It keeps Make's intermediate outputs under build/data/ and atomically
exports finished calculator apps into top-level build/compiled/, including the stable
live-emulator input build/compiled/NumPlay.nwa. `--watch` monitors source edits and
rebuilds incrementally, publishing only after successful builds. `--organize-only`
@@ -354,17 +354,17 @@ def install_arm() -> Path:
def ensure_build_directories(build: Path | None = None) -> tuple[Path, ...]:
"""Repair an incomplete build tree without deleting any existing outputs.
- The root Makefile creates build/arm, build/modules, etc. inside the recipe
- for the `build` directory. If build/ *already exists* (for example after
+ The root Makefile creates build/data/arm, build/data/modules, etc. inside the recipe
+ for the `build` directory. If build/data/ *already exists* (for example after
an interrupted attempt, or after a previous failed Make invocation), Make
skips that recipe. Parallel ARM compiler jobs then fail with an interleaved
- `can't create build/arm/*.o: No such file or directory` error.
+ `can't create build/data/arm/*.o: No such file or directory` error.
These directories are always safe to create ahead of Make, and the rest
remain governed by the repo's Makefile. Creating them before starting
any parallel build jobs also removes a directory-creation race.
"""
- build = ROOT / "build" if build is None else build
+ build = ROOT / "build" / "data" if build is None else build
relative = ("modules", "gen", "arm", "apps", "sim", "variant",
"tetris", "gen-upsilon", "arm-upsilon", "lang")
created = []
@@ -499,8 +499,8 @@ command -v nwlink >/dev/null || { echo 'Tetris nwlink bridge is unavailable from
invoke(["lang"])
-# Publish end-user .nwa files outside Make's internal build/ directory.
-# build/ is intentionally left alone: NumPlay's Makefile hard-codes B = build.
+# Publish end-user .nwa files outside Make's internal build/data directory.
+# The root Makefile uses B = build/data.
# The stable live path can later be supplied to emulator.py for auto-reload.
LIVE_DIR = "live"
VARIANT_DIR = "variants"
@@ -552,7 +552,7 @@ def atomic_copy(src: Path, dest: Path) -> None:
def collect_sources(*, apps: bool, langs: bool) -> list[Path]:
- build = ROOT / "build"
+ build = ROOT / "build" / "data"
# Never include existing build/compiled/ files: only fresh Makefile output sources.
sources = list(sorted(build.glob("NumPlay*.nwa")))
if not langs:
@@ -564,14 +564,14 @@ def collect_sources(*, apps: bool, langs: bool) -> list[Path]:
def publish_outputs(*, apps: bool, langs: bool, output: Path = OUTPUT,
verbose: bool = True) -> list[Path]:
- """Organize completed binaries, leaving compiler artifacts in build/.
+ """Organize completed binaries, leaving compiler artifacts in build/data/.
If a build fails this function isn't called, so the last successful live
binary remains untouched. No .nwa source or compiler object is deleted.
"""
sources = collect_sources(apps=apps, langs=langs)
if not sources:
- raise RuntimeError("No .nwa files found inside build/. Run a build first.")
+ raise RuntimeError("No .nwa files found inside build/data/. Run a build first.")
# Keep these generated binary exports out of git status without touching
# the project's tracked root .gitignore. A lone '*' ignores this file too.
output.mkdir(parents=True, exist_ok=True)
@@ -784,11 +784,20 @@ def _game_output(game: str) -> tuple[str, Path]:
if not game_dir.is_dir():
raise ValueError(f"Missing game directory: {game}")
file = labels[game]
- # Each game's own output: output/, output/device/ (NumDrive) or build/ (NumDash); Tetris, Cargo's.
- candidate = [game_dir / "output" / f"{game}.nwa", game_dir / "output" / "device" / f"{game}.nwa",
- game_dir / "build" / f"{game}.nwa"]
+ # Conventional Makefiles can put all standalone intermediates in build/data.
+ # Special layouts still use their original output paths until migrated.
+ makefile = (game_dir / "Makefile").read_text(encoding="utf-8") if (game_dir / "Makefile").exists() else ""
+ active = "\n".join(line for line in makefile.splitlines()
+ if not line.lstrip().startswith("#"))
+ conventional = ("output/" not in active) and any(
+ re.search(rf"(?m)^{variable}\s*=\s*output\s*$", makefile)
+ for variable in ("BUILD_DIR", "OUT"))
+ candidate = ([ROOT / "build" / "data" / "games" / game / f"{game}.nwa"]
+ if conventional else [game_dir / "output" / f"{game}.nwa",
+ game_dir / "output" / "device" / f"{game}.nwa",
+ game_dir / "build" / f"{game}.nwa"])
if game == "tetris":
- candidate = [ROOT / "build" / "apps" / "Tetris.nwa"]
+ candidate = [ROOT / "build" / "data" / "apps" / "Tetris.nwa"]
return file, next((p for p in candidate if p.is_file()), candidate[0])
@@ -811,7 +820,15 @@ def _build_once(a) -> None:
_publish_game("tetris")
return
_game_output(a.game) # Fail before launching a compiler on invalid IDs.
- _run_make(["-C", f"games/{a.game}", "build"], jobs=a.jobs)
+ source_makefile = (ROOT / "games" / a.game / "Makefile").read_text(encoding="utf-8")
+ active = "\n".join(x for x in source_makefile.splitlines()
+ if not x.lstrip().startswith("#"))
+ variable = next((v for v in ("BUILD_DIR", "OUT")
+ if re.search(rf"(?m)^{v}\s*=\s*output\s*$", source_makefile)), None)
+ make_args = ["-C", f"games/{a.game}", "build"]
+ if variable and "output/" not in active:
+ make_args.append(f"{variable}=../../build/data/games/{a.game}")
+ _run_make(make_args, jobs=a.jobs)
_publish_game(a.game)
return
if os.name == "nt":
@@ -875,7 +892,7 @@ def main() -> int:
if a.clean:
# Do not call `make clean`: several game recipes erase local build/
# folders also used by host tests (including host-saves).
- for location in (OUTPUT,):
+ for location in (ROOT / "build" / "data", OUTPUT):
if location.is_symlink():
raise RuntimeError(f"Refusing to clean symlink: {location}")
if location.is_dir():
diff --git a/tools/release.py b/tools/release.py
index 86cda0c5..d8ae5d73 100644
--- a/tools/release.py
+++ b/tools/release.py
@@ -70,7 +70,7 @@ def main():
ap = argparse.ArgumentParser()
ap.add_argument("--tag", required=True)
ap.add_argument("--notes", required=True)
- ap.add_argument("--build", default="build")
+ ap.add_argument("--build", default="build/compiled")
a = ap.parse_args()
games = json.load(open(os.path.join(ROOT, "games", "games.json")))
apps = standalone_names()
@@ -99,7 +99,7 @@ def main():
for gid in alone:
title, what = ALONE[gid]
name, what = apps[gid], f"{title}: {what}"
- files.append((os.path.join(a.build, "apps", name), f"{name} · {what}"))
+ files.append((os.path.join(a.build, "games", name), f"{name} · {what}"))
notes.append(f"| {link(name)} | {what} |")
name, what = UPSILON
notes += ["", "### On Upsilon", "", "| File | |", "| --- | --- |", f"| {link(name)} | {what} |"]
@@ -112,7 +112,7 @@ def main():
continue
tagline = g["tagline"][0].lower() + g["tagline"][1:]
what = f"Only {g['title']}: {tagline}"
- files.append((os.path.join(a.build, "apps", name), f"{name} · {what}"))
+ files.append((os.path.join(a.build, "games", name), f"{name} · {what}"))
notes.append(f"| {link(name)} | {what} |")
notes += ["", "<sub>The file list below is sorted A to Z by GitHub. Each file's label says what it is.</sub>"]