diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index e1b734fc6..8f6b0eb36 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -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 diff --git a/scripts/gha/build_linux.sh b/scripts/gha/build_linux.sh index 3c14f0656..dc3d15fdd 100755 --- a/scripts/gha/build_linux.sh +++ b/scripts/gha/build_linux.sh @@ -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]} @@ -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 @@ -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 } diff --git a/scripts/gha/build_win32.sh b/scripts/gha/build_win32.sh index 3873dbd15..e0778815c 100755 --- a/scripts/gha/build_win32.sh +++ b/scripts/gha/build_win32.sh @@ -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" diff --git a/scripts/gha/deps_linux.sh b/scripts/gha/deps_linux.sh index e933dae6b..59efc0805 100755 --- a/scripts/gha/deps_linux.sh +++ b/scripts/gha/deps_linux.sh @@ -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 diff --git a/scripts/gha/deps_win32.sh b/scripts/gha/deps_win32.sh index f73c47ea9..29a9cccd4 100755 --- a/scripts/gha/deps_win32.sh +++ b/scripts/gha/deps_win32.sh @@ -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 diff --git a/scripts/lib.sh b/scripts/lib.sh index bc281338c..cfe5ee142 100644 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -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