From b18866232be79d4a625e199e92b7854a470725ee Mon Sep 17 00:00:00 2001 From: nmlgc Date: Mon, 31 Aug 2020 14:12:20 +0200 Subject: [PATCH] [Build] 32-bit: Fall back on a dumb full .bat rebuild if Tup can't run And that's how we can still have a reliable 32-bit build part that runs on XP or earlier. Completes P0001, funded by GhostPhanom. --- CONTRIBUTING.md | 2 ++ README.md | 5 ++++- Tupfile | 3 ++- Tupfile.bat | 34 ++++++++++++++++++++++++++++++++++ build32b.bat | 12 ++++++++++++ 5 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 Tupfile.bat diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c4e7bb5d..71ec7b83 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,6 +58,8 @@ C++, Open Watcom, and Visual C++, which will ease future third-party ports. * Whenever you edit the `Tupfile`: * Make sure that the `B32_OBJS` list in `build32b.bat` still matches the list of `.obj` files generated from the `Tupfile` + * Run `tup generate Tupfile.bat` to update the dumb batch fallback script, + for systems that can't run Tup. ## Code organization diff --git a/README.md b/README.md index 3f0bc528..7aac85cf 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ And while this project has made decent progress so far, completing the decompila Crossed-out files are identical to their version in the previous game. ONGCHK.COM is part of the PMD sound driver by KAJA, and therefore doesn't need to be disassembled either; we only need to keep the binary to allow bit-perfect rebuilds of ZUN.COM. ## Building + You will need: * **Borland Turbo C++ 4.0J** @@ -107,10 +108,12 @@ You will need: ---- -* [**Tup**](http://gittup.org/tup/), for Windows +* [**Tup**](http://gittup.org/tup/), for Windows (optional, but recommended) A sane, parallel build system, used to ensure minimal rebuilds during the 32-bit build part. Provides perfect tracking of dependencies via code injection and hooking a compiler's file opening syscalls, allowing it to automatically add all `#include`d files to the build dependency graph. This makes it way superior to most `make` implementations, which lack this vital feature, and are therefore inherently unsuited for pretty much any programming language imaginable. With no abstractions for specific compilers, Tup also fits perfectly with the ancient Borland tools required for this project. + As of September 2020, the Windows version of Tup requires Vista or higher. In case Tup can't run or isn't installed, the build process falls back on a dumb batch file, which always fully rebuilds the entire 32-bit part. + ---- * **DOSBox** (if you're running a 64-bit version of Windows, or a non-Windows operating system) diff --git a/Tupfile b/Tupfile index 9755dc46..87c2b704 100644 --- a/Tupfile +++ b/Tupfile @@ -11,7 +11,8 @@ CXX32FLAGS += -w-8012 CXX32FLAGS += -O2 -v- -x- -BMP2ARR = bin/Pipeline/bmp2arr.exe +# Backslashes necessary for the .bat file generated by `tup generate`! +BMP2ARR = bin\\Pipeline\\bmp2arr.exe : Pipeline\\bmp2arr.c Pipeline\\bmp2arrl.c \ |> $(CXX32) $(CXX32FLAGS) -nbin/Pipeline/ %f \ diff --git a/Tupfile.bat b/Tupfile.bat new file mode 100644 index 00000000..fd558f6b --- /dev/null +++ b/Tupfile.bat @@ -0,0 +1,34 @@ +: Dumb, full batch build script, provided as a fallback for systems that can't +: run Tup. Auto-generated via `tup generate`; make sure to re-run that command +: if the Tupfile changes. +@echo on +bcc32 -w-8004 -w-8012 -O2 -v- -x- -nbin/Pipeline/ Pipeline/bmp2arr.c Pipeline/bmp2arrl.c +bin\\Pipeline\\bmp2arr.exe -i th01/sprites/pellet.bmp -o th01/sprites/pellet.csp -sym sPELLET -of c -sw 8 -sh 8 -pshf inner +bin\\Pipeline\\bmp2arr.exe -i th01/sprites/pellet_c.bmp -o th01/sprites/pellet_c.asp -sym _sPELLET_CLOUD -of asm -sw 16 -sh 16 +bin\\Pipeline\\bmp2arr.exe -i th01/sprites/shape8x8.bmp -o th01/sprites/shape8x8.asp -sym _sSHAPE8X8 -of asm -sw 8 -sh 8 +bin\\Pipeline\\bmp2arr.exe -i th02/sprites/pellet.bmp -o th02/sprites/pellet.asp -sym _sPELLET -of asm -sw 8 -sh 8 -pshf outer +bin\\Pipeline\\bmp2arr.exe -i th02/sprites/sparks.bmp -o th02/sprites/sparks.asp -sym _sSPARKS -of asm -sw 8 -sh 8 -pshf outer +bin\\Pipeline\\bmp2arr.exe -i th02/sprites/pointnum.bmp -o th02/sprites/pointnum.asp -sym _sPOINTNUMS -of asm -sw 8 -sh 8 +bin\\Pipeline\\bmp2arr.exe -i th03/sprites/score.bmp -o th03/sprites/score.asp -sym _sSCORE_FONT -of asm -sw 8 -sh 8 -u +bin\\Pipeline\\bmp2arr.exe -i th04/sprites/pelletbt.bmp -o th04/sprites/pelletbt.asp -sym _sPELLET_BOTTOM -of asm -sw 8 -sh 4 -pshf outer +bin\\Pipeline\\bmp2arr.exe -i th04/sprites/pointnum.bmp -o th04/sprites/pointnum.asp -sym _sPOINTNUMS -of asm -sw 8 -sh 8 -pshf inner +bin\\Pipeline\\bmp2arr.exe -i th05/sprites/gaiji.bmp -o th05/sprites/gaiji.asp -sym _sGAIJI -of asm -sw 16 -sh 16 +bin\\Pipeline\\bmp2arr.exe -i th05/sprites/piano_l.bmp -o th05/sprites/piano_l.asp -sym _sPIANO_LABEL_FONT -of asm -sw 8 -sh 8 +tasm32 /m /mx /kh32768 /t th01_op.asm bin\th01\op.obj +tasm32 /m /mx /kh32768 /t th01_reiiden.asm bin\th01\reiiden.obj +tasm32 /m /mx /kh32768 /t th01_fuuin.asm bin\th01\fuuin.obj +tasm32 /m /mx /kh32768 /t th02_zuninit.asm bin\th02\zuninit.obj +tasm32 /m /mx /kh32768 /t th02_op.asm bin\th02\op.obj +tasm32 /m /mx /kh32768 /t th02_main.asm bin\th02\main.obj +tasm32 /m /mx /kh32768 /t th02_maine.asm bin\th02\maine.obj +tasm32 /m /mx /kh32768 /t /DTHIEF libs\sprite16\sprite16.asm bin\th03\zunsp.obj +tasm32 /m /mx /kh32768 /t th03_op.asm bin\th03\op.obj +tasm32 /m /mx /kh32768 /t th03_main.asm bin\th03\main.obj +tasm32 /m /mx /kh32768 /t th03_mainl.asm bin\th03\mainl.obj +tasm32 /m /mx /kh32768 /t th04_op.asm bin\th04\op.obj +tasm32 /m /mx /kh32768 /t th04_main.asm bin\th04\main.obj +tasm32 /m /mx /kh32768 /t th04_maine.asm bin\th04\maine.obj +tasm32 /m /mx /kh32768 /t th05_op.asm bin\th05\op.obj +tasm32 /m /mx /kh32768 /t th05_main.asm bin\th05\main.obj +tasm32 /m /mx /kh32768 /t th05_maine.asm bin\th05\maine.obj +@echo off diff --git a/build32b.bat b/build32b.bat index 26f0e6c6..3da2cfac 100755 --- a/build32b.bat +++ b/build32b.bat @@ -31,7 +31,19 @@ if errorlevel 1 goto no_bcc32 mkdir bin\Pipeline %STDERR_IGNORE% for %%i in (1 2 3 4 5) do mkdir bin\th0%%i %STDERR_IGNORE% +call set_errorlevel_to_1.bat +tup version >NUL +if errorlevel 1 goto fallback +: NT returns negative values for things like DLL import failures +if not errorlevel 0 goto fallback + tup +goto eof + +:fallback +echo [:(] Failed to run Tup (gittup.org/tup), falling back on a dumb full rebuild... +if not errorlevel 0 echo (Delete `tup.exe` to avoid the error message boxes in the future) +call Tupfile.bat goto eof