Files
FFmpeg/.github/workflows/build.yml
T
Michael Fabian 'Xaymar' Dirks c7f4b1690a ci: Don't bother with static or 32-bit
Static builds are mostly pointless as the compilers used differ quite a lot. We also shouldn't bother with 32-bit anymore, as it has been replaced by 64-bit on Windows.
2021-05-23 21:57:06 +02:00

271 lines
10 KiB
YAML

name: Build
on:
workflow_dispatch:
inputs:
ref:
description: 'Branch, Tag or Commit to build'
required: false
default: 'master'
apply_patches:
description: 'Apply custom patches (Boolean)'
required: false
default: false
env:
X264_VERSION: "0.161.3049"
FFNVCODEC_VERSION: "n11.0.10.0"
AMF_VERSION: "v1.4.18"
ZLIB_NG_VERSION: "2.0.3"
jobs:
cc:
runs-on: ubuntu-20.04
strategy:
matrix:
license_version: [ 3, 2 ]
license: [ "GPL", "LGPL" ]
type: [ "shared" ]
bits: [ 64 ]
name: "Windows (${{ matrix.bits }}bit, ${{ matrix.type }}, ${{ matrix.license }}v${{ matrix.license_version}})"
steps:
- name: "automation: Check out"
uses: actions/checkout@v2
with:
submodules: "recursive"
fetch-depth: 0
- name: "automation: Copy patches to safe directory"
if: ${{ github.event.inputs.apply_patches == 'true' }}
shell: bash
run: |
if [[ -d ./patches ]]; then
cp -a ./patches /tmp/
fi
- name: "automation: Gather Information"
id: data
shell: bash
run: |
# Bitness
if [ "${{ matrix.bits }}" == "32" ]; then
echo "::set-output name=arch::i686"
echo "::set-output name=target_os::mingw32"
echo "::set-output name=cross_prefix::i686-w64-mingw32"
else
echo "::set-output name=arch::x86_64"
echo "::set-output name=target_os::mingw64"
echo "::set-output name=cross_prefix::x86_64-w64-mingw32"
fi
# License (GPL vs LGPL, v2 vs v3)
if [ "${{ matrix.license }}" == "GPL" ]; then
echo "::set-output name=flags_license::--enable-gpl"
fi
if [ "${{ matrix.license_version }}" == "3" ]; then
echo "::set-output name=flags_license_version::--enable-version3"
fi
# Build Type
if [ "${{ matrix.type }}" == "static" ]; then
echo "::set-output name=flags_type::--enable-static --disable-shared"
else
echo "::set-output name=flags_type::--disable-static --enable-shared"
fi
- name: "ffmpeg: Check out ${{ github.event.inputs.ref }}"
uses: actions/checkout@v2
with:
ref: "${{ github.event.inputs.ref }}"
submodules: "recursive"
fetch-depth: 0
- name: "automation: Detect version (and apply patches if necessary)"
id: version
shell: bash
run: |
# Detect Major.Minor.Patch version
VERSION=( $(cat RELEASE | sed -E 's/\./ /gi') )
VERSION_MAJOR=${VERSION[0]}
VERSION_MINOR=${VERSION[1]}
if (( ${#VERSION[@]} == 3 )); then
VERSION_PATCH=${VERSION[2]}
else
VERSION_PATCH=0
fi
COMMIT="$(git rev-parse --short=8 HEAD)"
echo "FFmpeg v${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${COMMIT}"
# Apply available patches
if [[ "${{ github.event.inputs.apply_patches}}" == "true" ]]; then
echo "Applying custom patches:"
declare -a PATCHES
if [[ "${{ github.event.inputs.ref }}" == "master" ]]; then
PATCHES[${#PATCHES[@]}]="master"
else
PATCHES[${#PATCHES[@]}]="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
PATCHES[${#PATCHES[@]}]="${VERSION_MAJOR}.${VERSION_MINOR}"
PATCHES[${#PATCHES[@]}]="${VERSION_MAJOR}"
fi
for p in ${PATCHES[@]}; do
if [[ -d "/tmp/patches/${p}" ]]; then
echo " Found patches for ${p}:"
for f in /tmp/patches/${p}/*.patch; do
echo " ${f}..."
[ -e "$f" ] || continue
git apply "$f"
done
else
echo " No patches for ${p}."
fi
done
VERSION_PATCH="${VERSION_PATCH}.patched"
fi
# Set Outputs
echo "::set-output name=major::${VERSION_MAJOR}"
echo "::set-output name=minor::${VERSION_MINOR}"
echo "::set-output name=patch::${VERSION_PATCH}"
echo "::set-output name=commit::${COMMIT}"
# Create distrib directory
mkdir distrib
mkdir distrib/bin
mkdir distrib/lib
mkdir distrib/include
mkdir distrib/share
- name: "dependency: cmake, make, pkg-config, mingw, nasm"
shell: bash
run: |
sudo apt-get update
sudo apt-get install \
build-essential git \
cmake make ninja-build \
pkg-config \
mingw-w64 mingw-w64-tools gcc-mingw-w64 g++-mingw-w64 \
nasm
# zlib-ng
- name: "dependency: zlib (zlib-ng v${{ env.ZLIB_NG_VERSION }}, Zlib license, shared)"
id: zlib
shell: bash
run: |
git clone --depth 1 --branch ${ZLIB_NG_VERSION} "https://github.com/zlib-ng/zlib-ng" /tmp/zlib-ng
pushd "/tmp/zlib-ng" > /dev/null
cmake -H. -Bbuild/build \
-DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain-mingw-${{ steps.data.outputs.arch }}.cmake \
-DCMAKE_BUILD_TYPE=RELEASE -DZLIB_COMPAT=ON -DZLIB_ENABLE_TESTS=OFF -DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX=./build/distrib/
cmake --build build/build --target install
pushd "./build/distrib" > /dev/null
# Fix ZLIB_COMPAT=ON still adding a suffix.
cp ./lib/libzlib.dll.a ./lib/libz.dll.a
# Generate MSVC compatible .lib file
gendef - ./bin/libzlib1.dll > ./lib/libzlib.def
${{ steps.data.outputs.cross_prefix }}-dlltool -d ./lib/libzlib.def -l ./lib/libzlib.lib
cp ./lib/libzlib.lib ./lib/libz.lib
popd > /dev/null
popd > /dev/null
sudo cp -a /tmp/zlib-ng/build/distrib/. /usr/${{ steps.data.outputs.cross_prefix }}
cp -a /tmp/zlib-ng/build/distrib/bin/*.dll ./distrib/bin/
# libx264 (FFmpeg 0.5 and up, arbitrarily limited to 1.0 because I'm lazy)
- name: "dependency: x264 v${{ env.X264_VERSION }} (GPLv2, shared)"
if: ${{ (steps.version.outputs.major >= 1) && startsWith(matrix.license, 'GPL') }}
id: x264
shell: bash
run: |
curl -L -o "/tmp/x264.zip" "https://github.com/Xaymar/x264/releases/download/${X264_VERSION}/x264-${{ matrix.bits }}-shared-GPLv2.zip"
7z x -o/tmp/x264/ "/tmp/x264.zip"
sudo cp -a /tmp/x264/. /usr/${{ steps.data.outputs.cross_prefix }}/
cp -a /tmp/x264/bin/*.dll ./distrib/bin/
echo "::set-output name=flags::--enable-libx264"
# NVIDIA Codec Headers (FFmpeg 3.0 and up)
- name: "dependency: NVIDIA Codec Headers v${{ env.FFNVCODEC_VERSION }} (MIT, shared)"
if: ${{ steps.version.outputs.major >= 3 }}
id: ffnvcodec
shell: bash
run: |
git clone --depth 1 --branch ${FFNVCODEC_VERSION} "https://git.videolan.org/git/ffmpeg/nv-codec-headers.git" /tmp/nv-codec-headers
pushd "/tmp/nv-codec-headers" > /dev/null
make PREFIX=/usr/${{ steps.data.outputs.cross_prefix }}
sudo make PREFIX=/usr/${{ steps.data.outputs.cross_prefix }} install
popd > /dev/null
if (( "${{ steps.version.outputs.major }}" >= 4 )); then
echo "::set-output name=flags::--enable-ffnvcodec --enable-nvdec --enable-cuvid --enable-nvenc"
elif (( "${{ steps.version.outputs.major }}" >= 3 )); then
if (( "${{ steps.version.outputs.minor }}" >= 2 )); then
# 3.2+ has cuda, cuvid, nvenc
echo "::set-output name=flags::--enable-cuvid --enable-nvenc"
elif (( "${{ steps.version.outputs.minor }}" >= 1 )); then
# 3.1 has cuda, nvenc
echo "::set-output name=flags::--enable-nvenc"
elif (( "${{ steps.version.outputs.minor }}" >= 0 )); then
# 3.0 has nvenc
echo "::set-output name=flags::--enable-nvenc"
fi
fi
# AMD AMF (FFmpeg 4.0 and up)
- name: "dependency: AMD AMF (v${{ env.AMF_VERSION }}, MIT, shared)"
if: ${{ steps.version.outputs.major >= 4 }}
id: amf
shell: bash
run: |
git clone --depth 1 --branch ${AMF_VERSION} "https://github.com/GPUOpen-LibrariesAndSDKs/AMF.git" /tmp/amd-amf
pushd "/tmp/amd-amf"
sudo cp -R amf/public/include/ /usr/${{ steps.data.outputs.cross_prefix }}/include/AMF
popd
if (( "${{ steps.version.outputs.major }}" >= 4 )); then
echo "::set-output name=flags::--enable-amf"
fi
# Configure FFmpeg
- name: "ffmpeg: Configure"
shell: bash
run: |
export PKG_CONFIG_PATH=/usr/${{ steps.data.outputs.cross_prefix }}/lib/pkgconfig:${PKG_CONFIG_PATH}
./configure \
--arch=${{ steps.data.outputs.arch }} \
--target-os=${{ steps.data.outputs.target_os }} \
--cross-prefix=${{ steps.data.outputs.cross_prefix }}- \
--prefix="${{ github.workspace }}/distrib" \
--bindir="${{ github.workspace }}/distrib/bin" \
--libdir="${{ github.workspace }}/distrib/lib" \
--shlibdir="${{ github.workspace }}/distrib/bin" \
--pkg-config=pkg-config \
--extra-cflags=-O3 --extra-cflags=-mmmx --extra-cflags=-msse --extra-cflags=-msse2 --extra-cflags=-msse3 --extra-cflags=-mssse3 \
--extra-cflags=-msse4.1 --extra-cflags=-msse4.2 --extra-cflags=-mavx --extra-cflags=-maes --extra-cflags=-mpclmul \
--pkg-config=pkg-config \
${{ steps.data.outputs.flags_license }} ${{ steps.data.outputs.flags_license_version }} \
${{ steps.data.outputs.flags_type }} \
${{ steps.x264.outputs.flags }} \
${{ steps.ffnvcodec.outputs.flags }} \
${{ steps.amf.outputs.flags }}
- name: "ffmpeg: Compile"
shell: bash
run: |
make -j 4
- name: "ffmpeg: Install"
shell: bash
run: |
make install
# Move .lib files which are in the wrong place.
mv ./distrib/bin/*.lib ./distrib/lib/
- name: "automation: Upload Artifacts"
uses: actions/upload-artifact@v1
with:
name: ffmpeg-${{ matrix.bits }}-${{ matrix.type }}-${{ matrix.license }}v${{ matrix.license_version }}-${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }}-${{ steps.version.outputs.commit }}
path: distrib