Skip to content

Commit

Permalink
ci: enable ffmpeg by default for Windows and Linux x86 targets
Browse files Browse the repository at this point in the history
  • Loading branch information
a1batross committed Dec 13, 2024
1 parent c8bf7e5 commit 8b4b047
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ jobs:
targetarch: amd64
env:
SDL_VERSION: 2.30.9
FFMPEG_VERSION: 7.1
GH_CPU_ARCH: ${{ matrix.targetarch }}
GH_CPU_OS: ${{ matrix.targetos }}
GH_CROSSCOMPILING: ${{ matrix.cross }}
steps:
- name: Checkout
Expand Down
22 changes: 15 additions & 7 deletions scripts/gha/build_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ for i in arm64 armhf riscv64 ppc64el; do
CROSS_COMPILE_CC[$i]=${ARCH_TRIPLET[$i]}-gcc
CROSS_COMPILE_CXX[$i]=${ARCH_TRIPLET[$i]}-g++
done
export PKG_CONFIG_PATH=${ARCH_TRIPLET[$GH_CPU_ARCH]}
export PKG_CONFIG_PATH=$PWD/ffmpeg/lib/pkgconfig:${ARCH_TRIPLET[$GH_CPU_ARCH]}
export CC=${CROSS_COMPILE_CC[$GH_CPU_ARCH]}
export CXX=${CROSS_COMPILE_CXX[$GH_CPU_ARCH]}

Expand Down Expand Up @@ -53,17 +53,21 @@ build_engine()
cd "$BUILDDIR" || die

if [ "$ARCH" = "amd64" ]; then # we need enabling 64-bit target only on Intel-compatible CPUs
AMD64="-8"
WAF_EXTRA_ARGS="-8"
fi

if [ -d "ffmpeg" ]; then
WAF_EXTRA_ARGS+=" --enable-ffmpeg"
fi

if [ "$GH_CROSSCOMPILING" != "true" ]; then
ENABLE_TESTS="--enable-tests"
WAF_EXTRA_ARGS+=" --enable-tests"
fi

if [ "$1" = "dedicated" ]; then
./waf configure $AMD64 $ENABLE_TESTS --enable-lto --enable-bundled-deps -d || die_configure
./waf configure $WAF_EXTRA_ARGS --enable-lto --enable-bundled-deps -d || die_configure
elif [ "$1" = "full" ]; then
./waf configure $AMD64 $ENABLE_TESTS --enable-lto --enable-bundled-deps -s SDL2_linux --enable-stb --enable-utils || die_configure
./waf configure $WAF_EXTRA_ARGS --enable-lto --enable-bundled-deps -s SDL2_linux --enable-stb --enable-utils || die_configure
else
die
fi
Expand All @@ -75,9 +79,13 @@ deploy_engine()
{
cd "$BUILDDIR" || die
./waf install --destdir="$APPDIR" || die
cp SDL2_linux/lib/libSDL2-2.0.so.0 "$APPDIR/"
cp -av SDL2_linux/lib/libSDL2-2.0.so.0 "$APPDIR/"
if [ "$GH_CPU_ARCH" = "i386" ]; then
cp 3rdparty/vgui_support/vgui-dev/lib/vgui.so "$APPDIR/"
cp -av 3rdparty/vgui_support/vgui-dev/lib/vgui.so "$APPDIR/"
fi

if [ -d "ffmpeg" ]; then
cp -av ffmpeg/lib/libav* ffmpeg/lib/libsw* "$APPDIR/"
fi
}

Expand Down
16 changes: 13 additions & 3 deletions scripts/gha/build_win32.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,30 @@ if [ "$ARCH" = "amd64" ]; then # we need enabling 64-bit target only on Intel-co
AMD64="-8"
fi

if [ -d "ffmpeg" ]; then
export PKGCONFIG="$PWD/pkgconf/bin/pkgconf.exe"
export PKG_CONFIG_PATH="$PWD/ffmpeg/lib/pkgconfig"
WAF_EXTRA_ARGS="--enable-ffmpeg"
fi

# NOTE: to build with other version use --msvc_version during configuration
# NOTE: sometimes you may need to add WinSDK to %PATH%
./waf.bat configure -s "SDL2_VC" -T release --enable-utils --enable-tests --enable-lto $AMD64 || die_configure
./waf.bat configure -s "SDL2_VC" -T release --enable-utils --enable-tests --enable-lto $AMD64 $WAF_EXTRA_ARGS || die_configure
./waf.bat build || die
./waf.bat install --destdir=. || die

if [ "$ARCH" = "i386" ]; then
cp SDL2_VC/lib/x86/SDL2.dll . # Install SDL2
cp -v SDL2_VC/lib/x86/SDL2.dll . # Install SDL2
elif [ "$ARCH" = "amd64" ]; then
cp SDL2_VC/lib/x64/SDL2.dll .
cp -v SDL2_VC/lib/x64/SDL2.dll .
else
die
fi

if [ -d "ffmpeg" ]; then
cp -v ffmpeg/bin/av* ffmpeg/bin/sw* .
fi

WINSDK_LATEST=$(ls -1 "C:/Program Files (x86)/Windows Kits/10/bin" | grep -E '^10' | sort -rV | head -n1)
echo "Latest installed Windows SDK is $WINSDK_LATEST"

Expand Down
4 changes: 4 additions & 0 deletions scripts/gha/deps_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,9 @@ if [ -n "${APPIMAGETOOL[$GH_CPU_ARCH]}" ]; then
chmod +x appimagetool.AppImage
fi

FFMPEG_ARCHIVE=$(get_ffmpeg_archive)
wget https://github.com/FWGS/FFmpeg-Builds/releases/download/latest/$FFMPEG_ARCHIVE.tar.xz -qO- | tar -xJf -
mv $FFMPEG_ARCHIVE ffmpeg

wget "https://github.com/libsdl-org/SDL/releases/download/release-$SDL_VERSION/SDL2-$SDL_VERSION.tar.gz" -qO- | tar -xzf -
mv "SDL2-$SDL_VERSION" SDL2_src
17 changes: 16 additions & 1 deletion scripts/gha/deps_win32.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
#!/bin/bash

curl http://libsdl.org/release/SDL2-devel-$SDL_VERSION-VC.zip -o SDL2.zip
. scripts/lib.sh

curl -L http://libsdl.org/release/SDL2-devel-$SDL_VERSION-VC.zip -o SDL2.zip
unzip -q SDL2.zip
mv SDL2-$SDL_VERSION SDL2_VC

curl -L https://github.com/FWGS/potential-meme/releases/download/prebuilts/mingw-w64-x86_64-pkgconf-1.2.3.0-1-any.pkg.tar.zst -o pkgconf.tar.zst
7z x pkgconf.tar.zst
7z x pkgconf.tar
rm pkgconf.tar*
mv mingw64 pkgconf

FFMPEG_ARCHIVE=$(get_ffmpeg_archive)
curl -L https://github.com/FWGS/FFmpeg-Builds/releases/download/latest/$FFMPEG_ARCHIVE.zip -o ffmpeg.zip
if [ -f ffmpeg.zip ]; then
unzip -x ffmpeg.zip
mv $FFMPEG_ARCHIVE ffmpeg
fi
21 changes: 21 additions & 0 deletions scripts/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,27 @@ die_configure()
die
}

get_ffmpeg_archive()
{
if [ "$GH_CPU_OS" == "win32" ]; then
A=win
else
A="$GH_CPU_OS"
fi

if [ "$GH_CPU_ARCH" == "amd64" ]; then
B=64
elif [ "$GH_CPU_ARCH" == "i386" ]; then
B=32
else
B="$GH_CPU_ARCH"
fi

FLAVOR=lgpl-shared-minimal

echo "ffmpeg-n$FFMPEG_VERSION-latest-$A$B-$FLAVOR-$FFMPEG_VERSION"
}

if [ -n "$TRAVIS_BUILD_DIR" ]; then
BUILDDIR=$TRAVIS_BUILD_DIR
elif [ -n "$GITHUB_WORKSPACE" ]; then
Expand Down

0 comments on commit 8b4b047

Please sign in to comment.