[Build] 32-bit: Use Tup as a proper build system for the 32-bit part

This Tupfile does in fact date back to January 2017, and I've been
using it myself ever since. Time to finally deliver it on master!

Part of P0001, funded by GhostPhanom.
This commit is contained in:
nmlgc 2017-01-22 21:22:00 +01:00
parent 51b775bd41
commit e31d232584
6 changed files with 97 additions and 52 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
bin/*
.tup/*
!bin/masters.lib
Research/*.exe
Research/*.obj

View File

@ -53,6 +53,12 @@ These cases should gradually be removed as development goes along, though.
* Use `__asm` as the keyword for inline assembly. This form works in Borland
C++, Open Watcom, and Visual C++, which will ease future third-party ports.
## Build system
* 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`
## Code organization
* Try to avoid repeating numeric constants after all, easy moddability

View File

@ -107,6 +107,12 @@ You will need:
----
* [**Tup**](http://gittup.org/tup/), for Windows
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.
----
* **DOSBox** (if you're running a 64-bit version of Windows, or a non-Windows operating system)
For the most part, it shouldn't matter whether you use [the original DOSBox](https://dosbox.com) or your favorite fork. A DOSBox with dynamic recompilation is highly recommended for faster compilation, though. Make sure to enable that feature by setting the following options in its configuration file (`dosbox.conf` for the original version):

80
Tupfile Normal file
View File

@ -0,0 +1,80 @@
AS = tasm32 /m /mx /kh32768 /t
CXX32 = bcc32
# Silence incorrect warnings for Borland C++ 5.5
# ----------------------------------------------
# 'identifier' is assigned a value that is never used
CXX32FLAGS += -w-8004
# Comparing signed and unsigned values
CXX32FLAGS += -w-8012
# ----------------------------------------------
CXX32FLAGS += -O2 -v- -x-
BMP2ARR = bin/Pipeline/bmp2arr.exe
: Pipeline\\bmp2arr.c Pipeline\\bmp2arrl.c \
|> $(CXX32) $(CXX32FLAGS) -nbin/Pipeline/ %f \
|> bin/Pipeline/bmp2arrl.obj \
bin/Pipeline/bmp2arr.obj \
bin/Pipeline/bmp2arr.tds \
$(BMP2ARR)
!bmp2arr = | $(BMP2ARR) |> $(BMP2ARR) -i %f -o %o |> %o
: th01/sprites/pellet.bmp |> !bmp2arr -sym sPELLET -of c -sw 8 -sh 8 -pshf inner |> th01/sprites/pellet.csp
: th01/sprites/pellet_c.bmp |> !bmp2arr -sym _sPELLET_CLOUD -of asm -sw 16 -sh 16 |> th01/sprites/pellet_c.asp
: th01/sprites/shape8x8.bmp |> !bmp2arr -sym _sSHAPE8X8 -of asm -sw 8 -sh 8 |> th01/sprites/shape8x8.asp
: th02/sprites/pellet.bmp |> !bmp2arr -sym _sPELLET -of asm -sw 8 -sh 8 -pshf outer |> th02/sprites/pellet.asp
: th02/sprites/sparks.bmp |> !bmp2arr -sym _sSPARKS -of asm -sw 8 -sh 8 -pshf outer |> th02/sprites/sparks.asp
: th02/sprites/pointnum.bmp |> !bmp2arr -sym _sPOINTNUMS -of asm -sw 8 -sh 8 |> th02/sprites/pointnum.asp
: th03/sprites/score.bmp |> !bmp2arr -sym _sSCORE_FONT -of asm -sw 8 -sh 8 -u |> th03/sprites/score.asp
: th04/sprites/pelletbt.bmp |> !bmp2arr -sym _sPELLET_BOTTOM -of asm -sw 8 -sh 4 -pshf outer |> th04/sprites/pelletbt.asp
: th04/sprites/pointnum.bmp |> !bmp2arr -sym _sPOINTNUMS -of asm -sw 8 -sh 8 -pshf inner |> th04/sprites/pointnum.asp
: th05/sprites/gaiji.bmp |> !bmp2arr -sym _sGAIJI -of asm -sw 16 -sh 16 |> th05/sprites/gaiji.asp
: th05/sprites/piano_l.bmp |> !bmp2arr -sym _sPIANO_LABEL_FONT -of asm -sw 8 -sh 8 |> th05/sprites/piano_l.asp
!as = |> $(AS) %f %o |> %o
: th01_op.asm |> !as |> bin\\th01\\op.obj
: th01_reiiden.asm | \
th01/sprites/pellet_c.asp \
th01/sprites/shape8x8.asp \
|> !as |> bin\\th01\\reiiden.obj
: th01_fuuin.asm |> !as |> bin\\th01\\fuuin.obj
: th02_zuninit.asm |> !as |> bin\\th02\\zuninit.obj
: th02_op.asm |> !as |> bin\\th02\\op.obj
: th02_main.asm | \
th02/sprites/pellet.asp \
th02/sprites/sparks.asp \
th02/sprites/pointnum.asp \
|> !as |> bin\\th02\\main.obj
: th02_maine.asm |> !as |> bin\\th02\\maine.obj
: libs/sprite16/sprite16.asm |> $(AS) /DTHIEF libs\sprite16\sprite16.asm %o |> bin\\th03\\zunsp.obj
: th03_op.asm |> !as |> bin\\th03\\op.obj
: th03_main.asm | \
th03/sprites/score.asp \
|> !as |> bin\\th03\\main.obj
: th03_mainl.asm |> !as |> bin\\th03\\mainl.obj
: th04_op.asm |> !as |> bin\\th04\\op.obj
: th04_main.asm | \
th02/sprites/pellet.asp \
th04/sprites/pelletbt.asp \
th02/sprites/sparks.asp \
th04/sprites/pointnum.asp \
|> !as |> bin\\th04\\main.obj
: th04_maine.asm |> !as |> bin\\th04\\maine.obj
: th05_op.asm | \
th05/sprites/piano_l.asp \
|> !as |> bin\\th05\\op.obj
: th05_main.asm | \
th02/sprites/pellet.asp \
th04/sprites/pelletbt.asp \
th02/sprites/sparks.asp \
th04/sprites/pointnum.asp \
|> !as |> bin\\th05\\main.obj
: th05_maine.asm |> !as |> bin\\th05\\maine.obj

0
Tupfile.ini Normal file
View File

View File

@ -1,67 +1,19 @@
@echo off
echo Running the first, 32-bit part of the ReC98 build process.
set ReC98_ASM=tasm32 /m /mx /kh32768 /t /ilibs\master.lib\
set CXX32=bcc32
%ReC98_ASM% 1>NUL 2>NUL
tasm32 1>NUL 2>NUL
if errorlevel 9009 goto no_tasm32
%CXX32% 1>NUL 2>NUL
bcc32 1>NUL 2>NUL
if errorlevel 9009 goto no_bcc32
REM Silence incorrect warnings for Borland C++ 5.5
REM ----------------------------------------------
REM 'identifier' is assigned a value that is never used
set CXX32FLAGS=%CXX32FLAGS% -w-8004
REM Comparing signed and unsigned values
set CXX32FLAGS=%CXX32FLAGS% -w-8012
REM ----------------------------------------------
set CXX32FLAGS=%CXX32FLAGS% -O2 -v- -x-
: Neither BCC32 nor TASM32 automatically create nonexisting output
: directories...
: directories. Tup would, but not everybody can use it.
mkdir bin\Pipeline 2>NUL
for /L %%i in (1,1,5) do mkdir bin\th0%%i 2>NUL
set BMP2ARR=bin\Pipeline\bmp2arr.exe
tup
%CXX32% %CXX32FLAGS% -nbin/Pipeline/ Pipeline\bmp2arr.c Pipeline\bmp2arrl.c
%BMP2ARR% -i th01/sprites/pellet.bmp -o th01/sprites/pellet.csp -sym sPELLET -of c -sw 8 -sh 8 -pshf inner
%BMP2ARR% -i th01/sprites/pellet_c.bmp -o th01/sprites/pellet_c.asp -sym _sPELLET_CLOUD -of asm -sw 16 -sh 16
%BMP2ARR% -i th01/sprites/shape8x8.bmp -o th01/sprites/shape8x8.asp -sym _sSHAPE8X8 -of asm -sw 8 -sh 8
%BMP2ARR% -i th02/sprites/pellet.bmp -o th02/sprites/pellet.asp -sym _sPELLET -of asm -sw 8 -sh 8 -pshf outer
%BMP2ARR% -i th02/sprites/sparks.bmp -o th02/sprites/sparks.asp -sym _sSPARKS -of asm -sw 8 -sh 8 -pshf outer
%BMP2ARR% -i th02/sprites/pointnum.bmp -o th02/sprites/pointnum.asp -sym _sPOINTNUMS -of asm -sw 8 -sh 8
%BMP2ARR% -i th03/sprites/score.bmp -o th03/sprites/score.asp -sym _sSCORE_FONT -of asm -sw 8 -sh 8 -u
%BMP2ARR% -i th04/sprites/pelletbt.bmp -o th04/sprites/pelletbt.asp -sym _sPELLET_BOTTOM -of asm -sw 8 -sh 4 -pshf outer
%BMP2ARR% -i th04/sprites/pointnum.bmp -o th04/sprites/pointnum.asp -sym _sPOINTNUMS -of asm -sw 8 -sh 8 -pshf inner
%BMP2ARR% -i th05/sprites/gaiji.bmp -o th05/sprites/gaiji.asp -sym _sGAIJI -of asm -sw 16 -sh 16
%BMP2ARR% -i th05/sprites/piano_l.bmp -o th05/sprites/piano_l.asp -sym _sPIANO_LABEL_FONT -of asm -sw 8 -sh 8
%ReC98_ASM% th01_op.asm bin\th01\op.obj
%ReC98_ASM% th01_reiiden.asm bin\th01\reiiden.obj
%ReC98_ASM% th01_fuuin.asm bin\th01\fuuin.obj
%ReC98_ASM% th02_zuninit.asm bin\th02\zuninit.obj
%ReC98_ASM% th02_op.asm bin\th02\op.obj
%ReC98_ASM% th02_main.asm bin\th02\main.obj
%ReC98_ASM% th02_maine.asm bin\th02\maine.obj
%ReC98_ASM% /DTHIEF libs\sprite16\sprite16.asm bin\th03\zunsp.obj
%ReC98_ASM% th03_op.asm bin\th03\op.obj
%ReC98_ASM% th03_main.asm bin\th03\main.obj
%ReC98_ASM% th03_mainl.asm bin\th03\mainl.obj
%ReC98_ASM% th04_op.asm bin\th04\op.obj
%ReC98_ASM% th04_main.asm bin\th04\main.obj
%ReC98_ASM% th04_maine.asm bin\th04\maine.obj
%ReC98_ASM% th05_op.asm bin\th05\op.obj
%ReC98_ASM% th05_main.asm bin\th05\main.obj
%ReC98_ASM% th05_maine.asm bin\th05\maine.obj
goto eof
:no_tasm32