OverviewFilesCommitsIssuesDocsReleasesPeers

hyper-tps / tools / build-portable-engine.sh

54 lines · bash ref:
#!/bin/bash
# Build the Linux export template (the shipped `hypertps` binary) PORTABLE:
# against glibc 2.35, inside an ubuntu:22.04 container.
#
# Why: a template built on tabertron links its glibc 2.39 and needs GLIBC_2.38.
# ashatron (Ubuntu 22.04, glibc 2.35) refused to start 0.1229.0:
#   hypertps: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.38' not found
# One portable build serves every host; there is no separate "compat" install.
# CI's verify-gdextension step fails the release if build/linux/hypertps needs
# more than GLIBC_2.35.
#
# The source is a `git archive` of the engine's HEAD, never the working tree, so
# what ships is a commit. thirdparty/ngx (the DLSS SDK) is gitignored and copied
# in. .git/HEAD holds the commit so `hypertps --version` names it.
#
#   tools/build-portable-engine.sh [engine-repo] [work-dir]
#
# Then install it where export_presets.cfg custom_template/release points:
#   cp <work>/bin/godot.linuxbsd.template_release.x86_64 <engine-repo>/bin/
set -euo pipefail
ENGINE=${1:-/storage/projects/code/godot/nvidia-rtx-godot-v3}
WORK=${2:-$(mktemp -d /tmp/engine-portable.XXXXXX)}
[ -z "$(git -C "$ENGINE" status --porcelain --untracked-files=no)" ] || {
  echo "ERROR: $ENGINE has uncommitted changes; the build is of HEAD, commit first"; exit 1; }
HASH=$(git -C "$ENGINE" rev-parse HEAD)
mkdir -p "$WORK"
git -C "$ENGINE" archive HEAD | tar -x -C "$WORK"
cp -r "$ENGINE/thirdparty/ngx" "$WORK/thirdparty/"
mkdir -p "$WORK/.git" && echo "$HASH" > "$WORK/.git/HEAD"
cat > "$WORK/build_in_2204.sh" <<'EOF'
#!/bin/bash
set -e
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get install -y -qq build-essential pkg-config libx11-dev libxcursor-dev libxinerama-dev \
    libgl1-mesa-dev libglu1-mesa-dev libasound2-dev libpulse-dev libudev-dev libxi-dev \
    libxrandr-dev libwayland-dev python3 python3-pip >/dev/null
pip3 install -q "scons>=4.7"      # apt's 4.0.1 is too old for Godot
gcc --version | head -1
ldd --version | head -1
cd /src
rc=0
scons platform=linux target=template_release -j"$(nproc)" || rc=$?
chown -R "$HOST_UID:$HOST_GID" /src
exit $rc
EOF
chmod +x "$WORK/build_in_2204.sh"
docker run --rm -e HOST_UID="$(id -u)" -e HOST_GID="$(id -g)" -v "$WORK:/src" ubuntu:22.04 /src/build_in_2204.sh
OUT=$WORK/bin/godot.linuxbsd.template_release.x86_64
NEED=$(objdump -T "$OUT" | grep -oE 'GLIBC_[0-9]+\.[0-9]+' | sort -V | tail -1)
echo "built: $OUT"
echo "  glibc: $NEED   version: $("$OUT" --headless --version 2>/dev/null | tail -1)"
[ "$(printf '%s\nGLIBC_2.35\n' "$NEED" | sort -V | tail -1)" = "GLIBC_2.35" ] || { echo "ERROR: $NEED > 2.35"; exit 1; }