Repository navigation
Expand file tree
/
Copy pathbuild.sh
More file actions
87 lines (79 loc) · 3.97 KB
/
Copy pathbuild.sh
File metadata and controls
87 lines (79 loc) · 3.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
# Linux build: build.sh [debug] (debug: the release build's optimisation with the info lines in the log)
# The same steps as build.bat, all on Linux: the recompiler, default.xbe (from an ISO if need be), the symbols, the
# recompiled code in generated/game, then the game as out/build/linux/underground2.
set -e
GAME_TITLE="Need for Speed Underground 2"
GAME_XBE=default.xbe
cd "$(dirname "$0")"
OUT=out/build/linux
TOOLS=out/build/linux-tools
VERBOSE=OFF
[ "$1" = debug ] && VERBOSE=ON
echo
echo " $GAME_TITLE for Linux"
echo " ======================================"
echo
fail() {
echo
echo " BUILD FAILED. $1"
echo
exit 1
}
# ---------------------------------------------------------------- tools
echo "[1/5] Tools"
missing=
for tool in clang clang++ cmake ninja git pkg-config python3; do
command -v $tool >/dev/null || missing="$missing $tool"
done
pkg-config --exists vulkan 2>/dev/null || missing="$missing vulkan"
if [ -n "$missing" ]; then
echo " missing:$missing"
echo " Arch: sudo pacman -S clang lld cmake ninja git pkgconf python vulkan-headers vulkan-icd-loader sdl3"
echo " Debian/Ubuntu: sudo apt install clang lld cmake ninja-build git pkg-config python3 libvulkan-dev"
echo " and libsdl3-dev, or SDL3's build dependencies (libx11-dev libxext-dev libwayland-dev"
echo " libxkbcommon-dev libpipewire-0.3-dev libpulse-dev libasound2-dev libudev-dev libdecor-0-dev)"
echo " Fedora: sudo dnf install clang lld cmake ninja-build git pkgconf python3 vulkan-loader-devel SDL3-devel"
fail "Install the missing tools, then run this again."
fi
echo " $(clang++ --version | head -1)"
pkg-config --exists sdl3 2>/dev/null && echo " SDL3 $(pkg-config --modversion sdl3) from the system" ||
echo " no system SDL3: it is downloaded and built in"
# ---------------------------------------------------------------- the xbe
echo "[2/5] $GAME_XBE"
if [ ! -f "assets/$GAME_XBE" ]; then
ISO=$(ls assets/*.iso iso/*.iso 2>/dev/null | head -1 || true)
if [ -z "$ISO" ]; then
echo " Put the game in the assets folder first: $GAME_XBE from the USA release, or its disc image (.iso)"
echo " $PWD/assets"
fail
fi
mkdir -p assets
echo " taking it from $ISO"
python3 -I tools/xdvdfs.py "$ISO" $GAME_XBE "assets/$GAME_XBE" || fail "Read the last message above."
fi
# ---------------------------------------------------------------- recompiler
echo "[3/5] Recompiler"
cmake -S tools -B "$TOOLS" -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
>/dev/null || fail "Read the last message above."
cmake --build "$TOOLS" >/dev/null || fail "Read the last message above."
SDK=$(head -1 "$TOOLS/sdk_dir.txt")
if ! grep -q '^\[symbols\]' config/game.toml 2>/dev/null; then
"$TOOLS/xbe_symbols" "assets/$GAME_XBE" "$SDK/xdk" --out config/game.toml || fail "Read the last message above."
fi
# ---------------------------------------------------------------- recompile
echo "[4/5] Recompiling $GAME_XBE into generated/game"
"$TOOLS/xbe_recomp" config/game.toml --xdk "$SDK/xdk" >/dev/null || fail "Read the last message above."
# ---------------------------------------------------------------- the game
echo "[5/5] Game: the first build compiles the recompiled code, 15 to 60 minutes"
cmake -S . -B "$OUT" -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_FLAGS=-march=x86-64-v2 -DCMAKE_CXX_FLAGS=-march=x86-64-v2 -DXBE_VERBOSE_LOG=$VERBOSE \
>/dev/null || fail "Read the last message above."
cmake --build "$OUT" --target main || fail "Read the last message above."
echo
echo " $GAME_TITLE for Linux built."
echo " $OUT/underground2"
echo
echo " The game is found in assets (its files or the .iso) beside the executable or in any folder above it."
echo " Settings, saves (hdd), logs and the shader cache are written beside the executable."
echo