Skip to content

feat(build): make this a fullblown cmake project #19

feat(build): make this a fullblown cmake project

feat(build): make this a fullblown cmake project #19

Workflow file for this run

---
name: CI
on:
pull_request:
branches: [master]
types: [opened, synchronize, reopened]
push:
branches: [master]
workflow_dispatch:
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
env:
MACOSX_DEPLOYMENT_TARGET: 13.0
jobs:
build:
name: Build (${{ matrix.name }})
# https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
# https://trac.ffmpeg.org/wiki/CompilationGuide/macOS
# https://trac.ffmpeg.org/wiki/CompilationGuide/MinGW
strategy:
fail-fast: false # false to test all, true to fail entire job if any fail
matrix:
include:
- name: Linux-x86_64 # ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}
os_type: linux
os: ubuntu-22.04
arch: x86_64
shell: bash
cmake_generator: Unix Makefiles
ffmpeg_extras: >-
--enable-amf
--enable-cuda
--enable-cuda_llvm
--enable-encoder=h264_amf,hevc_amf,av1_amf
--enable-encoder=h264_nvenc,hevc_nvenc,av1_nvenc
--enable-encoder=h264_vaapi,hevc_vaapi,av1_vaapi
--enable-encoder=h264_v4l2m2m
--enable-ffnvcodec
--enable-nvenc
--enable-v4l2_m2m
--enable-vaapi
- name: Linux-aarch64
os_type: linux
os: ubuntu-22.04
arch: aarch64
shell: bash
cmake_generator: Unix Makefiles
host: aarch64-linux-gnu
ffmpeg_extras: >-
--enable-amf
--enable-cuda
--enable-cuda_llvm
--enable-encoder=h264_amf,hevc_amf,av1_amf
--enable-encoder=h264_nvenc,hevc_nvenc,av1_nvenc
--enable-encoder=h264_vaapi,hevc_vaapi,av1_vaapi
--enable-encoder=h264_v4l2m2m
--enable-ffnvcodec
--enable-nvenc
--enable-v4l2_m2m
--enable-vaapi
- name: Linux-ppc64le
os_type: linux
os: ubuntu-22.04
arch: powerpc64le
shell: bash
cmake_generator: Unix Makefiles
host: powerpc64le-linux-gnu
ffmpeg_extras: >-
--enable-amf
--enable-cuda
--enable-cuda_llvm
--enable-encoder=h264_amf,hevc_amf,av1_amf
--enable-encoder=h264_nvenc,hevc_nvenc,av1_nvenc
--enable-encoder=h264_vaapi,hevc_vaapi,av1_vaapi
--enable-encoder=h264_v4l2m2m
--enable-ffnvcodec
--enable-nvenc
--enable-v4l2_m2m
--enable-vaapi
- name: Darwin-x86_64
os_type: macos
os: macos-13
arch: x86_64
shell: bash
cmake_generator: Unix Makefiles # should be `Xcode` but that fails
ffmpeg_extras: >-
--enable-encoder=h264_videotoolbox,hevc_videotoolbox
--enable-videotoolbox
- name: Darwin-arm64
os_type: macos
os: macos-14
arch: aarch64
shell: bash
cmake_generator: Unix Makefiles # should be `Xcode` but that fails
ffmpeg_extras: >-
--enable-encoder=h264_videotoolbox,hevc_videotoolbox
--enable-videotoolbox
- name: Windows-AMD64
os_type: windows
os: windows-2022
arch: x86_64
shell: msys2 {0}
cmake_generator: MSYS Makefiles
ffmpeg_extras: >-
--enable-amf
--enable-cuda
--enable-d3d11va
--enable-encoder=h264_amf,hevc_amf,av1_amf
--enable-encoder=h264_mf,hevc_mf
--enable-encoder=h264_nvenc,hevc_nvenc,av1_nvenc
--enable-encoder=h264_qsv,hevc_qsv,av1_qsv
--enable-ffnvcodec
--enable-libvpl
--enable-nvenc
--enable-mediafoundation
runs-on: ${{ matrix.os }}
defaults:
run:
shell: ${{ matrix.shell }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Dependencies Unix
if: ${{ matrix.os_type != 'windows' }}
run: |
echo "::group::dependencies prep"
if [[ ${{ matrix.os }} == "ubuntu-18.04" ]]; then
dist="bionic"
elif [[ ${{ matrix.os }} == "ubuntu-20.04" ]]; then
dist="focal"
elif [[ ${{ matrix.os }} == "ubuntu-22.04" ]]; then
dist="jammy"
elif [[ ${{ matrix.os }} == "ubuntu-24.04" ]]; then
dist="noble"
fi
package_arch="amd64"
if [[ ${{ matrix.arch }} == "aarch64" ]]; then
package_arch="arm64"
elif [[ ${{ matrix.arch }} == "powerpc64le" ]]; then
package_arch="ppc64el"
fi
mirror="http://ports.ubuntu.com/ubuntu-ports"
extra_sources=$(cat <<- VAREOF
deb [arch=$package_arch] $mirror $dist main restricted
deb [arch=$package_arch] $mirror $dist-updates main restricted
deb [arch=$package_arch] $mirror $dist universe
deb [arch=$package_arch] $mirror $dist-updates universe
deb [arch=$package_arch] $mirror $dist multiverse
deb [arch=$package_arch] $mirror $dist-updates multiverse
deb [arch=$package_arch] $mirror $dist-backports main restricted universe multiverse
deb [arch=$package_arch] $mirror $dist-security main restricted
deb [arch=$package_arch] $mirror $dist-security universe
deb [arch=$package_arch] $mirror $dist-security multiverse
VAREOF
)
echo "::endgroup::"
if [[ ${{ matrix.os_type }} == "linux" ]]; then
echo "::group::linux dependencies"
if [[ ${{ matrix.os }} == "ubuntu-20.04" ]]; then
# activate mesa backport PPA to ensure ffmpeg builds with vaSyncBuffer()
# (via libva 2.9.0 or later)
sudo add-apt-repository ppa:kisak/turtle -y
fi
if [[ $package_arch != "amd64" ]]; then
# fix original sources
sudo sed -i -e "s#deb http#deb [arch=amd64] http#g" /etc/apt/sources.list
sudo dpkg --add-architecture $package_arch
echo "$extra_sources" | sudo tee -a /etc/apt/sources.list
echo "----"
sudo cat /etc/apt/sources.list
fi
sudo apt-get update -q && sudo apt-get -y install \
autoconf \
automake \
build-essential \
cmake \
git-core \
libass-dev \
libfreetype6-dev \
libgnutls28-dev \
libmp3lame-dev \
libnuma-dev \
libopus-dev \
libsdl2-dev \
libtool \
libvorbis-dev \
libxcb1-dev \
libxcb-shm0-dev \
libxcb-xfixes0-dev \
meson \
nasm \
ninja-build \
pkg-config \
texinfo \
wget \
yasm \
zlib1g-dev
if [[ ${{ matrix.arch }} == "powerpc64le" ]]; then
sudo apt-get -y install \
libva-dev:$package_arch \
libva2:$package_arch \
libva-drm2:$package_arch \
libdrm2:$package_arch \
libva-glx2:$package_arch \
libgl1:$package_arch \
libglx0:$package_arch \
libglx-mesa0:$package_arch \
libglapi-mesa:$package_arch \
libgl1-mesa-dri:$package_arch \
libdrm-amdgpu1:$package_arch \
libdrm-nouveau2:$package_arch \
libdrm-radeon1:$package_arch \
libwayland-client0:$package_arch \
libwayland-cursor0:$package_arch \
libwayland-dev:$package_arch \
libwayland-egl1:$package_arch \
libwayland-server0:$package_arch \
libva-wayland2:$package_arch \
libva-x11-2:$package_arch
else
sudo apt-get -y install \
libva-dev:$package_arch \
libva-glx2:$package_arch \
libgl1:$package_arch \
libglx0:$package_arch
fi
if [[ ${{ matrix.arch }} != "x86_64" ]]; then
sudo apt-get -y install \
binutils-${{ matrix.host }} \
g++-${{ matrix.host }} \
gcc-${{ matrix.host }}
fi
echo "::endgroup::"
elif [[ ${{ matrix.os_type }} == "macos" ]]; then
echo "::group::macos dependencies"
brew install \
automake \
fdk-aac \
git \
lame \
libass \
libtool \
libvorbis \
libvpx \
nasm \
opus \
pkg-config \
sdl \
shtool \
texi2html \
theora \
wget \
yasm \
xvid
echo "::endgroup::"
fi
- name: Setup Dependencies Windows
# if a dependency needs to be pinned, see https://github.com/LizardByte/build-deps/pull/186
if: ${{ matrix.os_type == 'windows' }}
uses: msys2/setup-msys2@v2
with:
msystem: ucrt64
update: true
install: >-
diffutils
git
make
pkg-config
mingw-w64-ucrt-x86_64-binutils
mingw-w64-ucrt-x86_64-cmake
mingw-w64-ucrt-x86_64-gcc
mingw-w64-ucrt-x86_64-onevpl
mingw-w64-ucrt-x86_64-nasm
- name: Initialize Submodules
# libx265 has issues when using the recursive method of the first checkout action
# this is after `msys2/setup-msys2@v2` because `msys2` (default) shell is not available until then.
run: |
git submodule update --init --recursive
- name: Create Directories
id: root
run: |
echo "root_path=$PWD" >> $GITHUB_OUTPUT
mkdir -p ./bin ./ffmpeg_build ./ffmpeg_sources
- name: Setup cross compilation
id: cross
if: ${{ matrix.arch != 'x86_64' }}
run: |
TOOLCHAIN_DIR=${{ steps.root.outputs.root_path }}/cmake/toolchains/${{ matrix.arch }}-${{ matrix.os_type }}
echo "CMAKE_TOOLCHAIN_FILE=$TOOLCHAIN_DIR/crosscompile.cmake" >> $GITHUB_OUTPUT
if [[ ${{ matrix.os_type }} == 'linux' ]]; then
echo "CCPREFIX=/usr/bin/${{ matrix.host }}-" >> $GITHUB_OUTPUT
fi
- name: ffmpeg
env:
root_path: ${{ steps.root.outputs.root_path }}
working-directory: ffmpeg_sources/ffmpeg
run: |
echo "::group::configure options"
./configure --help || true # this command has a non zero exit status, but we should continue anyway
echo "::endgroup::"
echo "::group::configure extra flags for cross compilation"
extra_configure=""
if [[ ${{ matrix.os_type }} == "linux" && ${{ matrix.arch }} != "x86_64" ]]; then
CCPREFIX=${{ steps.cross.outputs.CCPREFIX }}
extra_configure=$(cat <<- VAREOF
--arch=${{ matrix.arch }}
--cross-prefix=${CCPREFIX}
--enable-cross-compile
--target-os=${{ matrix.os_type }}
VAREOF
)
fi
echo "$extra_configure"
echo "::endgroup::"
echo "::group::configure"
set +e # do not fail
PATH="$root_path/bin:$PATH" \
PKG_CONFIG_PATH="$root_path/ffmpeg_build/lib/pkgconfig:/usr/lib/${{ matrix.host }}/pkgconfig" \
./configure \
$extra_configure \
--prefix="$root_path/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-cflags="-I$root_path/ffmpeg_build/include" \
--extra-ldflags="-L$root_path/ffmpeg_build/lib" \
--extra-libs="-lpthread -lm" \
--bindir="$root_path/bin" \
--disable-all \
--disable-autodetect \
--disable-iconv \
--enable-avcodec \
--enable-encoder=libsvtav1 \
--enable-encoder=libx264,libx265 \
--enable-gpl \
--enable-libsvtav1 \
--enable-libx264 \
--enable-libx265 \
--enable-static \
--enable-swscale \
--pkg-config=pkg-config \
${{ matrix.ffmpeg_extras }} \
|| config_error=true
set -e # reset fail on error
echo "::endgroup::"
echo "::group::config error log"
cat ./ffbuild/config.log
if [ $config_error ]
then
exit -1
fi
echo "::endgroup::"
echo "::group::make"
PATH="$root_path/bin:$PATH" make -j$(nproc || sysctl -n hw.logicalcpu)
echo "::endgroup::"
echo "::group::make install"
make install
echo "::endgroup::"
echo "::group::copy license"
cp ./COPYING.GPLv2 $root_path/ffmpeg_build/LICENSE
echo "::endgroup::"
- name: cbs
env:
root_path: ${{ steps.root.outputs.root_path }}
run: |
mkdir -p build
cd build
echo "::group::configure extra flags for cross compilation"
if [[ ${{ matrix.os_type }} == "macos" ]]; then
if [[ ${{ matrix.arch }} == "x86_64" ]]; then
export CC="gcc"
export CXX="g++"
else
export CFLAGS="${{ steps.cross.outputs.CFLAGS }}"
export CXXFLAGS="${{ steps.cross.outputs.CXXFLAGS }}"
export LDFLAGS="${{ steps.cross.outputs.LDFLAGS }}"
fi
fi
echo "::endgroup::"
echo "::group::configure"
PATH="$root_path/bin:$PATH" cmake -G "${{ matrix.cmake_generator }}" \
-DCMAKE_TOOLCHAIN_FILE=${{ steps.cross.outputs.CMAKE_TOOLCHAIN_FILE }} \
-DCMAKE_INSTALL_PREFIX="$root_path/ffmpeg_build" \
-DBUILD_FFMPEG_CBS=ON \
..
echo "::endgroup::"
echo "::group::make"
PATH="$root_path/bin:$PATH" make -j$(nproc || sysctl -n hw.logicalcpu)
echo "::endgroup::"
echo "::group::make install"
make install
echo "::endgroup::"
- name: Cleanup
run: |
rm -f -r ./ffmpeg_build/share
rm -f -r ./ffmpeg_build/lib/pkgconfig
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: ./ffmpeg_build/
update_dist:
# only the commit is conditional, so the rest of the job can be verified on PRs
name: Update dist
needs: ffmpeg

Check failure on line 440 in .github/workflows/ci.yml

View workflow run for this annotation

GitHub Actions / CI

Invalid workflow file

The workflow is not valid. .github/workflows/ci.yml (Line: 440, Col: 12): Job 'update_dist' depends on unknown job 'ffmpeg'.
runs-on: ubuntu-latest
steps:
- name: Checkout dist
uses: actions/checkout@v4
with:
ref: dist
path: dist
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token
fetch-depth: 0 # otherwise, will fail to push refs to dest repo
- name: Cleanup
run: |
rm -f -r dist/ffmpeg/*/share
rm -f -r dist/ffmpeg/*/lib/pkgconfig
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist/ffmpeg
- name: Debug
run: |
ls -R dist/ffmpeg
- name: Commit dist
if: >-
startsWith(github.repository, 'LizardByte/') &&
github.ref == 'refs/heads/master' &&
(github.event_name == 'push' || github.event_name == 'workflow_dispatch')
uses: actions-js/[email protected]
with:
github_token: ${{ secrets.GH_BOT_TOKEN }}
author_email: ${{ secrets.GH_BOT_EMAIL }}
author_name: ${{ secrets.GH_BOT_NAME }}
directory: dist
branch: dist
force: false
message: "Commit ${{ github.sha }}"