Centralize configuration, logging, database decryption and resource metadata. Use task dependencies for development, SDK and release builds; move source tools and game downloads to Go with ordered client preparation. Rename the client to BD2 Launcher, add native icons, and update packaging and SDK checks.
52 lines
1.6 KiB
Bash
Executable File
52 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
root=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)
|
|
|
|
tool_dir="$root/.build/tools"
|
|
tool="$tool_dir/bd2w"
|
|
|
|
tool_is_current() {
|
|
[ -f "$tool" ] || return 1
|
|
newer_sources=$(find "$root/go/build" "$root/go/internal/common" "$root/go/internal/client" "$root/go/go.mod" "$root/go/go.sum" -type f -newer "$tool" -print) || {
|
|
printf 'bd2w: cannot check build tool source timestamps.\n' >&2
|
|
exit 1
|
|
}
|
|
[ -z "$newer_sources" ]
|
|
}
|
|
|
|
if ! tool_is_current; then
|
|
mkdir -p "$tool_dir"
|
|
lock="$tool_dir/.bootstrap.lock"
|
|
attempts=0
|
|
while ! tool_is_current; do
|
|
if mkdir "$lock" 2>/dev/null; then
|
|
temporary="$tool_dir/.bd2w-$$"
|
|
trap 'rm -f "$temporary"; rmdir "$lock" 2>/dev/null || true' 0
|
|
trap 'exit 130' INT TERM
|
|
if ! tool_is_current; then
|
|
printf 'bd2w: compiling the build tool...\n'
|
|
(
|
|
cd "$root/go"
|
|
GOCACHE="$root/go/.cache/go-build"
|
|
GOOS=$(go env GOHOSTOS)
|
|
GOARCH=$(go env GOHOSTARCH)
|
|
CGO_ENABLED=0
|
|
export GOCACHE GOOS GOARCH CGO_ENABLED
|
|
go build -buildvcs=false -trimpath -o "$temporary" ./build
|
|
)
|
|
mv "$temporary" "$tool"
|
|
fi
|
|
rmdir "$lock"
|
|
trap - 0 INT TERM
|
|
break
|
|
fi
|
|
attempts=$((attempts + 1))
|
|
if [ "$attempts" -ge 120 ]; then
|
|
printf 'bd2w: bootstrap lock still held at %s; check the first launcher.\n' "$lock" >&2
|
|
exit 1
|
|
fi
|
|
sleep 1
|
|
done
|
|
fi
|
|
exec "$tool" "$@"
|