Repository navigation
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·68 lines (57 loc) · 1.59 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·68 lines (57 loc) · 1.59 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
#!/bin/bash
#
# build.sh - Build the MF shim DLL for a specific RE Engine game
#
# Compiles shim/mfreadwrite_shim.c with -DGAME_PREFIX="<prefix>" and outputs
# the DLL to shim/out/<game>/mfreadwrite.dll.
#
# Prerequisites:
# - x86_64-w64-mingw32-gcc (brew install mingw-w64)
#
# Usage: ./build.sh <game>
# e.g. ./build.sh re3
# ./build.sh re8
#
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
if [[ $# -lt 1 ]]; then
echo "Usage: $0 <game>"
echo ""
echo "Available games:"
for conf in "$SCRIPT_DIR"/games/*.conf; do
name=$(basename "$conf" .conf)
# shellcheck disable=SC1090
source "$conf"
printf " %-6s %s (%s)\n" "$name" "$GAME_NAME" "$STATUS"
done
exit 1
fi
GAME="$1"
CONF="$SCRIPT_DIR/games/${GAME}.conf"
if [[ ! -f "$CONF" ]]; then
echo "ERROR: No config found for '$GAME' (expected $CONF)" >&2
exit 1
fi
# shellcheck disable=SC1090
source "$CONF"
# Check for compiler
CC="x86_64-w64-mingw32-gcc"
if ! command -v "$CC" &>/dev/null; then
echo "ERROR: $CC not found. Install via: brew install mingw-w64" >&2
exit 1
fi
SRC="$SCRIPT_DIR/shim/mfreadwrite_shim.c"
DEF="$SCRIPT_DIR/shim/mfreadwrite.def"
OUT_DIR="$SCRIPT_DIR/shim/out/${GAME}"
OUT_DLL="$OUT_DIR/mfreadwrite.dll"
mkdir -p "$OUT_DIR"
echo "Building MF shim DLL for $GAME_NAME ($GAME)..."
echo " GAME_PREFIX=$GAME_PREFIX"
echo " Output: $OUT_DLL"
"$CC" -shared \
-DGAME_PREFIX=\""$GAME_PREFIX"\" \
-o "$OUT_DLL" \
"$SRC" "$DEF" \
-Wl,--enable-stdcall-fixup \
-lole32
echo " Done: $(ls -lh "$OUT_DLL" | awk '{print $5}') $OUT_DLL"