9d0a0d5798
build / build (push) Successful in 2m52s
- engine-debug-tools/: a debug dump hotkey + dump2png to inspect decoded critter frames independent of the renderer (see root README.md's "Debugging" section). - engine-patches/04,05: fix critter sprite scale and an OpenGL texture cache collision, found using that tooling. - mdlp: fix encodeFrames RLE-diffing upscaled frames against a previous-frame reference the real RSD8 decoder never implements (verified against Night Dive's original Mac source down to the 68K assembly) - was rendering as scattered static in-game. - Upscale pipeline: better color quantization (dithering, pure-ramp exclusion) and per-resource model selection.
103 lines
4.4 KiB
Bash
Executable File
103 lines
4.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Compiles engine/ (the vendored Shockolate snapshot) against the
|
|
# dependencies prebuilt into this image at /opt/prebuilt - no network
|
|
# access needed. Must be run with the repo root as the working directory
|
|
# - either via ../run-image.sh (which docker-runs this image with the
|
|
# repo bind-mounted at /workspace and WORKDIR set there), or directly
|
|
# when already inside this image (e.g. a CI job using this image as its
|
|
# container - see the Makefile's `engine` target, which picks whichever
|
|
# of these applies).
|
|
#
|
|
# Builds from a scratch copy of engine/, patched with engine-patches/
|
|
# (see that directory and README.md section 4.4) - same reasoning as
|
|
# build-engine-win.sh's own scratch copy: engine/ itself is never modified in
|
|
# place (README.md section 1).
|
|
#
|
|
# Output lands in engine/.build-output/: the systemshock binary, the
|
|
# shared libraries it needs at runtime (lib/), and a default MIDI
|
|
# soundfont - everything the root Makefile needs to assemble dist/.
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(pwd)"
|
|
SCRATCH_ENGINE="$REPO_ROOT/build/linux-engine"
|
|
OUT_DIR="$REPO_ROOT/engine/.build-output"
|
|
|
|
echo "== Preparing a scratch copy of engine/, patched with engine-patches/ =="
|
|
rm -rf "$SCRATCH_ENGINE"
|
|
mkdir -p "$(dirname "$SCRATCH_ENGINE")"
|
|
cp -a "$REPO_ROOT/engine" "$SCRATCH_ENGINE"
|
|
|
|
# A checkout built in place by an older version of this script (before it
|
|
# staged a scratch copy) can still have build_ext/CMakeCache.txt etc.
|
|
# sitting in the real engine/ - copied along above, they'd make CMake
|
|
# refuse to configure this copy ("directory is different than the
|
|
# directory where CMakeCache.txt was created"). Same cleanup
|
|
# build-engine-win.sh's own scratch copy does.
|
|
rm -rf "$SCRATCH_ENGINE"/build_ext "$SCRATCH_ENGINE"/CMakeCache.txt \
|
|
"$SCRATCH_ENGINE"/CMakeFiles "$SCRATCH_ENGINE"/cmake_install.cmake \
|
|
"$SCRATCH_ENGINE"/Makefile "$SCRATCH_ENGINE"/systemshock \
|
|
"$SCRATCH_ENGINE"/src/Libraries/CMakeFiles
|
|
|
|
for p in "$REPO_ROOT"/engine-patches/*.patch; do
|
|
patch -p1 -d "$SCRATCH_ENGINE" < "$p"
|
|
done
|
|
|
|
# ENGINE_DEBUG_TOOLS=1 (set by the Makefile's dist_debug target) additionally
|
|
# applies engine-debug-tools/engine-patches/ - debug-only instrumentation
|
|
# (see root README.md's "Debugging" section) that stays out of every normal
|
|
# build.
|
|
if [ -n "${ENGINE_DEBUG_TOOLS:-}" ]; then
|
|
echo "== ENGINE_DEBUG_TOOLS set - also applying engine-debug-tools/engine-patches/ =="
|
|
for p in "$REPO_ROOT"/engine-debug-tools/engine-patches/*.patch; do
|
|
patch -p1 -d "$SCRATCH_ENGINE" < "$p"
|
|
done
|
|
fi
|
|
|
|
cd "$SCRATCH_ENGINE"
|
|
|
|
echo "== Wiring up prebuilt SDL2/SDL2_mixer/fluidsynth-lite from the image =="
|
|
rm -rf build_ext
|
|
mkdir -p build_ext
|
|
|
|
# Some filesystems the repo might be checked out on (e.g. a VirtualBox
|
|
# vboxsf shared folder) refuse to create symlinks at all ("Operation not
|
|
# permitted"), which plain `cp -a` needs for SDL2/SDL2_mixer's
|
|
# libFoo.so -> libFoo.so.N -> libFoo.so.N.M dev-symlink chain. Detect
|
|
# that up front, once, and copy real file content instead of recreating
|
|
# links if so, rather than failing partway through. `-a` implies
|
|
# --preserve=all (which includes hard-link relationships between files,
|
|
# not just symlinks - SDL2's install hard-links the two most-specific
|
|
# version files together), so --no-preserve=links is needed alongside
|
|
# --dereference to avoid that too.
|
|
CP_FLAGS=(-a)
|
|
if ! ln -s test-target build_ext/.symlink-test 2>/dev/null; then
|
|
echo "(destination filesystem doesn't support symlinks - copying real file content instead)"
|
|
CP_FLAGS=(-a --dereference --no-preserve=links)
|
|
else
|
|
rm -f build_ext/.symlink-test
|
|
fi
|
|
|
|
cp "${CP_FLAGS[@]}" /opt/prebuilt/built_sdl build_ext/
|
|
cp "${CP_FLAGS[@]}" /opt/prebuilt/built_sdl_mixer build_ext/
|
|
cp "${CP_FLAGS[@]}" /opt/prebuilt/fluidsynth-lite build_ext/
|
|
|
|
echo "== Configuring (CMake, BUNDLED SDL2/SDL2_mixer/FluidSynth) =="
|
|
rm -f CMakeCache.txt
|
|
cmake -DENABLE_SDL2=BUNDLED -DENABLE_SOUND=BUNDLED -DENABLE_FLUIDSYNTH=BUNDLED .
|
|
|
|
echo "== Compiling =="
|
|
make -j"$(nproc)" systemshock
|
|
|
|
echo "== Assembling engine/.build-output =="
|
|
rm -rf "$OUT_DIR"
|
|
mkdir -p "$OUT_DIR/lib"
|
|
cp systemshock "$OUT_DIR/"
|
|
find build_ext/built_sdl/lib build_ext/built_sdl_mixer/lib build_ext/fluidsynth-lite/src \
|
|
-name '*.so*' -not -name '*.la' -exec cp "${CP_FLAGS[@]}" {} "$OUT_DIR/lib/" \;
|
|
cp /opt/prebuilt/soundfont/default.sf2 "$OUT_DIR/soundfont.sf2"
|
|
|
|
echo "== Done =="
|
|
echo "Binary: $OUT_DIR/systemshock"
|
|
echo "Libraries: $OUT_DIR/lib/"
|
|
echo "Soundfont: $OUT_DIR/soundfont.sf2"
|