build for steam-runtime

This commit is contained in:
RandomityGuy 2026-06-06 00:33:16 +01:00
parent b4e3179193
commit fe7b1942b3

View file

@ -453,116 +453,154 @@ jobs:
# path: ~/project/MBHaxe-Platinum-Win.zip
build-linux:
machine: # executor type
image: ubuntu-2204:current
docker:
- image: registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest
environment:
#HOMEBREW_NO_AUTO_UPDATE: 1
#NPROC: 4
COMMIT_TAG: pipeline.git.tag
steps:
#- add_ssh_keys:
# fingerprints:
# - "82:42:56:a0:57:43:95:4e:00:c0:8c:c1:7f:70:74:47"
- run:
name: Install build dependencies
command: |
apt-get update
apt-get install -y \
git curl ca-certificates openssh-client patchelf \
cmake pkg-config \
libpng-dev libturbojpeg0-dev libvorbis-dev libopenal-dev \
libsdl2-dev libmbedtls-dev libuv1-dev libsqlite3-dev
- add_ssh_keys:
fingerprints:
- "82:42:56:a0:57:43:95:4e:00:c0:8c:c1:7f:70:74:47"
- checkout:
path: ~/MBHaxe
- run:
name: Install apt dependencies
command: |
sudo apt install cmake pkg-config
sudo apt-get install libpng-dev libturbojpeg-dev libvorbis-dev libopenal-dev libsdl2-dev libmbedtls-dev libuv1-dev libsqlite3-dev
- run:
name: Install Haxe
command: |
set -eux
download_url="https://github.com/HaxeFoundation/haxe/releases/download/4.3.6/haxe-4.3.6-linux64.tar.gz"
echo "Downloading [$download_url]..."
mkdir ~/haxe
curl -fsSL --retry 3 --retry-delay 5 "$download_url" -o ~/haxe.tar.gz
tar xzvf ~/haxe.tar.gz -C ~/haxe --strip-components=1
download_url="https://github.com/HaxeFoundation/neko/releases/download/v2-4-0/neko-2.4.0-linux64.tar.gz"
echo "Downloading [$download_url]..."
mkdir ~/neko
curl -fsSL --retry 3 --retry-delay 5 "$download_url" -o ~/neko.tar.gz
tar xzvf ~/neko.tar.gz -C ~/neko --strip-components=1
export PATH=~/haxe/:"$PATH"
export HAXE_STD_PATH=~/haxe/std
export PATH=~/neko/:"$PATH"
export LD_LIBRARY_PATH=~/neko
sudo chmod +x ~/neko/neko
haxelib setup ~/haxelib
haxelib list
mkdir $HOME/haxe $HOME/neko
curl -fsSL --retry 3 --retry-delay 5 \
https://github.com/HaxeFoundation/haxe/releases/download/4.3.6/haxe-4.3.6-linux64.tar.gz \
| tar xz -C $HOME/haxe --strip-components=1
curl -fsSL --retry 3 --retry-delay 5 \
https://github.com/HaxeFoundation/neko/releases/download/v2-4-0/neko-2.4.0-linux64.tar.gz \
| tar xz -C $HOME/neko --strip-components=1
export PATH=$HOME/haxe:$HOME/neko:"$PATH"
export HAXE_STD_PATH=$HOME/haxe/std
export LD_LIBRARY_PATH=$HOME/neko
haxelib setup $HOME/haxelib
- run:
name: Install hashlink
name: Install HashLink
command: |
mkdir -p ~/deps
cd ~/deps
mkdir -p $HOME/deps
cd $HOME/deps
git clone --depth=1 https://github.com/RandomityGuy/hashlink
git clone --depth=1 https://github.com/RandomityGuy/hxDatachannel
cd hashlink
ln -s ~/deps/hxDatachannel/cpp libs/datachannel
ln -s $HOME/deps/hxDatachannel/cpp libs/datachannel
echo -e "\nadd_subdirectory(datachannel)" >> libs/CMakeLists.txt
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_FIND_FRAMEWORK=LAST -DWITH_SQLITE=OFF -DBUILD_TESTING=OFF -DHASHLINK_INCLUDE_DIR="~/deps/hashlink/src" -DHASHLINK_LIBRARY_DIR="/usr/local/lib/"
cmake --build build --config Release -j$NPROC
sudo cmake --install build
cmake -S. -Bbuild \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_FIND_FRAMEWORK=LAST \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DWITH_SQLITE=OFF \
-DBUILD_TESTING=OFF \
-DHASHLINK_INCLUDE_DIR="$HOME/deps/hashlink/src" \
-DHASHLINK_LIBRARY_DIR="/usr/local/lib/"
cmake --build build --config Release -j$(nproc)
cmake --install build
ldconfig
- run:
name: Install haxe dependencies
name: Install Haxe dependencies
command: |
export PATH=~/haxe/:"$PATH"
export HAXE_STD_PATH=~/haxe/std
export PATH=~/neko/:"$PATH"
export LD_LIBRARY_PATH=~/neko
haxelib dev hashlink ~/deps/hashlink/other/haxelib
export PATH=$HOME/haxe:$HOME/neko:"$PATH"
export HAXE_STD_PATH=$HOME/haxe/std
export LD_LIBRARY_PATH=$HOME/neko
haxelib dev hashlink $HOME/deps/hashlink/other/haxelib
haxelib git heaps https://github.com/RandomityGuy/heaps
haxelib dev hlopenal ~/deps/hashlink/libs/openal
haxelib dev hlsdl ~/deps/hashlink/libs/sdl
haxelib dev datachannel ~/deps/hxDatachannel
haxelib dev hlopenal $HOME/deps/hashlink/libs/openal
haxelib dev hlsdl $HOME/deps/hashlink/libs/sdl
haxelib dev datachannel $HOME/deps/hxDatachannel
haxelib install colyseus-websocket
- save_cache:
key: mbhaxe-deps-v1
paths:
- /usr/local/lib/datachannel.hdll
- /usr/local/lib/fmt.hdll
- /usr/local/lib/openal.hdll
- /usr/local/lib/sdl.hdll
- /usr/local/lib/ssl.hdll
- /usr/local/lib/ui.hdll
- /usr/local/lib/uv.hdll
- run:
name: Compile MBHaxe
command: |
export PATH=~/haxe/:"$PATH"
export HAXE_STD_PATH=~/haxe/std
export PATH=~/neko/:"$PATH"
export LD_LIBRARY_PATH=~/neko
cd ~/MBHaxe
haxe compile.hxml
export PATH=$HOME/haxe:$HOME/neko:"$PATH"
export HAXE_STD_PATH=$HOME/haxe/std
export LD_LIBRARY_PATH=$HOME/neko
cd $HOME/MBHaxe
haxe compile-linux.hxml
cd native
cp ~/deps/hashlink/src/hlc_main.c .
gcc -o marblegame -O2 -I . -L /usr/local/lib marblegame.c /usr/local/lib/{ui.hdll,openal.hdll,fmt.hdll,sdl.hdll,uv.hdll,ssl.hdll,datachannel.hdll} -lSDL2 -lhl -lm -luv
cp $HOME/deps/hashlink/src/hlc_main.c .
gcc -o marblegame -O2 \
-I . \
-L /usr/local/lib \
marblegame.c \
/usr/local/lib/{ui.hdll,openal.hdll,fmt.hdll,sdl.hdll,uv.hdll,ssl.hdll,datachannel.hdll} \
-lSDL2 -lhl -lm -luv \
-Wl,-rpath,'$ORIGIN'
strip marblegame
- run:
name: Package Bundle
name: Package portable bundle
command: |
mkdir -p ~/MBHaxe-Ultra-Linux
cd ~/MBHaxe-Ultra-Linux
cp ~/MBHaxe/marblegame.hl .
cp ~/MBHaxe/native/marblegame .
cp ~/MBHaxe/linux-dist/* .
cp -r ~/MBHaxe/data data
cp /usr/local/lib/{{fmt,openal,sdl,ssl,ui,uv,datachannel}.hdll,libhl.so.1.13.0} .
cp /usr/local/bin/hl .
ln -s libhl.so.1.13.0 libhl.so.1
ln -s libhl.so.1 libhl.so
cd ..
DIST=$HOME/MBHaxe-Ultra-Linux
mkdir -p "$DIST"
# Native binary
cp $HOME/MBHaxe/native/marblegame "$DIST/"
# HashLink plugins
cp /usr/local/lib/{fmt,openal,sdl,ssl,ui,uv,datachannel}.hdll "$DIST/"
# libhl — copy versioned file and create soname symlink
LIBHL_REAL=$(realpath /usr/local/lib/libhl.so)
LIBHL_BASE=$(basename "$LIBHL_REAL")
cp "$LIBHL_REAL" "$DIST/$LIBHL_BASE"
LIBHL_SONAME=$(readelf -d "$LIBHL_REAL" | grep -oP '(?<=\[)libhl\.so[^\]]+(?=\])')
if [ -n "$LIBHL_SONAME" ] && [ "$LIBHL_SONAME" != "$LIBHL_BASE" ]; then
ln -sf "$LIBHL_BASE" "$DIST/$LIBHL_SONAME"
fi
ln -sf "${LIBHL_SONAME:-$LIBHL_BASE}" "$DIST/libhl.so"
# Bundle Steam Runtime system libs for portability
get_lib() {
ldconfig -p | grep "^\s*$1\b" | awk '{print $NF}' | head -n 1
}
for soname in libSDL2-2.0.so.0 libopenal.so.1 libuv.so.1 libturbojpeg.so.0; do
path=$(get_lib "$soname")
[ -n "$path" ] && cp -L "$path" "$DIST/$soname" || echo "Warning: $soname not found"
done
# mbedtls soname varies by version — find and copy by library basename
for libbase in libmbedtls libmbedx509 libmbedcrypto; do
path=$(ldconfig -p | grep "^\s*${libbase}\.so\." | awk '{print $NF}' | head -n 1)
if [ -n "$path" ]; then
cp -L "$path" "$DIST/$(basename $path)"
fi
done
# Game data
cp -r $HOME/MBHaxe/data "$DIST/"
# Set rpath=$ORIGIN so the bundle is self-contained
patchelf --set-rpath '$ORIGIN' "$DIST/marblegame"
for f in "$DIST"/*.hdll; do
patchelf --set-rpath '$ORIGIN' "$f" || true
done
patchelf --set-rpath '$ORIGIN' "$DIST/$LIBHL_BASE" || true
cd $HOME
tar -czvf MBHaxe-Ultra-Linux.tar.gz MBHaxe-Ultra-Linux
- run:
name: Upload to Artifact Storage
command: |
scp -o StrictHostKeyChecking=no -i $KEYPATH -P $PORT \
$HOME/MBHaxe-Ultra-Linux.tar.gz \
$REMOTEDIR/MBHaxe-Ultra-Linux.tar.gz
build-uwp:
executor:
name: win/server-2022