Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build ffmpeg for linux-arm, linux-arm64, linux-x86 #6288

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 43 additions & 54 deletions .github/workflows/build-ffmpeg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: workflow_dispatch
jobs:
build-macos:
name: Build macOS
runs-on: macos-12
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -55,22 +55,25 @@ jobs:
path: macOS-universal

build-win:
name: Build Windows
name: Build Windows (${{ matrix.arch }})
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
arch:
- x86
- x64
- x86
- arm64
container:
image: mstorsjo/llvm-mingw:latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install nasm mingw-w64
apt-get update -y -qq
apt-get install -y nasm mingw-w64

- name: Build
run: osu.Framework.NativeLibs/scripts/ffmpeg/build-win.sh
Expand All @@ -83,81 +86,67 @@ jobs:
name: win-${{ matrix.arch }}
path: win-${{ matrix.arch }}

# The win-arm64 build runs in a special MinGW container to cross-compile successfully.
build-win-arm64:
name: Build Windows (arm64)
runs-on: ubuntu-22.04
container:
image: mstorsjo/llvm-mingw:latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build
run: osu.Framework.NativeLibs/scripts/ffmpeg/build-win.sh
env:
arch: arm64

- name: Upload
uses: actions/upload-artifact@v4
with:
name: win-arm64
path: win-arm64

build-linux:
name: Build Linux (x64)
name: Build Linux (${{ matrix.arch }})
kvnp marked this conversation as resolved.
Show resolved Hide resolved
# Use 20.04 to target glibc 2.31 like the other native libs
runs-on: ubuntu-20.04
strategy:
matrix:
include:
- { arch: x64, container: "ubuntu:20.04" }
- { arch: x86, container: "i386/ubuntu:20.04" }
- { arch: arm64, container: "arm64v8/ubuntu:20.04" }
- { arch: arm, container: "arm32v7/ubuntu:20.04" }
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install nasm libva-dev libvdpau-dev

- name: Checkout
uses: actions/checkout@v4

- name: Setup QEMU
if: ${{ contains(matrix.arch, 'arm') }}
uses: docker/setup-qemu-action@v2

- name: Build
run: osu.Framework.NativeLibs/scripts/ffmpeg/build-linux.sh
uses: addnab/docker-run-action@v3
with:
image: ${{ matrix.container }}
options: -v ${{ github.workspace }}:/workspace -w /workspace -e DEBIAN_FRONTEND=noninteractive
run: |
apt-get update -y -qq
apt-get install -y build-essential curl nasm libva-dev libvdpau-dev
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libva-dev and libvdpau-dev can be removed from this list. They are from an older version of the build process but were accidentally kept in the dependency list.

nasm is only required for x86 and x86_64 builds.

osu.Framework.NativeLibs/scripts/ffmpeg/build-linux.sh

- name: Upload
uses: actions/upload-artifact@v4
with:
name: linux-x64
path: linux-x64
name: linux-${{ matrix.arch }}
path: linux-${{ matrix.arch }}

make-pr:
name: Create pull request
runs-on: ubuntu-22.04
needs:
- combine-macos
- build-win
- build-win-arm64
- build-linux
strategy:
matrix:
include:
- { name: macOS-universal, path: osu.Framework.NativeLibs/runtimes/osx/native }
- { name: linux-arm64, path: osu.Framework.NativeLibs/runtimes/linux-arm64/native}
- { name: linux-arm, path: osu.Framework.NativeLibs/runtimes/linux-arm/native}
- { name: linux-x64, path: osu.Framework.NativeLibs/runtimes/linux-x64/native}
- { name: linux-x86, path: osu.Framework.NativeLibs/runtimes/linux-x86/native}
- { name: win-arm64, path: osu.Framework.NativeLibs/runtimes/win-arm64/native}
- { name: win-x64, path: osu.Framework.NativeLibs/runtimes/win-x64/native}
- { name: win-x86, path: osu.Framework.NativeLibs/runtimes/win-x86/native}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of this. This will create 8 separate "Update FFmpeg binaries" PRs every time this workflow is run.

steps:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: macOS-universal
path: osu.Framework.NativeLibs/runtimes/osx/native
- uses: actions/download-artifact@v4
with:
name: linux-x64
path: osu.Framework.NativeLibs/runtimes/linux-x64/native
- uses: actions/download-artifact@v4
with:
name: win-arm64
path: osu.Framework.NativeLibs/runtimes/win-arm64/native
- uses: actions/download-artifact@v4
with:
name: win-x64
path: osu.Framework.NativeLibs/runtimes/win-x64/native
- uses: actions/download-artifact@v4
with:
name: win-x86
path: osu.Framework.NativeLibs/runtimes/win-x86/native
name: ${{ matrix.name }}
path: ${{ matrix.path }}

- uses: peter-evans/create-pull-request@v6
with:
Expand Down
20 changes: 17 additions & 3 deletions osu.Framework.NativeLibs/scripts/ffmpeg/build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,21 @@ FFMPEG_FLAGS+=(
)

pushd . > /dev/null
prep_ffmpeg linux-x64

if [ $(uname -m) == "x86_64" ]; then
ARCH="x64"
elif [ $(uname -m) == "i686" ]; then
ARCH="x86"
elif [ $(uname -m) == "aarch64" ]; then
ARCH="arm64"
elif [ $(uname -m) == "armv7l" ]; then
ARCH="arm"
else
echo "Unsupported architecture: $(uname -m)"
exit 1
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this to the top (like the arch-related stuff in the other build scripts)


prep_ffmpeg linux-$ARCH
# Apply patch from upstream to fix errors with new binutils versions:
# Ticket: https://fftrac-bg.ffmpeg.org/ticket/10405
# This patch should be removed when FFmpeg is updated to >=6.1
Expand All @@ -28,7 +42,7 @@ popd > /dev/null

# gcc creates multiple symlinks per .so file for versioning.
# We delete the symlinks and rename the real files to include the major library version
rm linux-x64/*.so
for f in linux-x64/*.so.*.*.*; do
rm linux-$ARCH/*.so
for f in linux-$ARCH/*.so.*.*.*; do
mv -vf "$f" "${f%.*.*}"
done