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 all 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
51 changes: 51 additions & 0 deletions .github/workflows/build-ffmpeg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,44 @@ jobs:
name: linux-x64
path: linux-x64

build-linux-cross:
name: Build Linux
# Use 20.04 to target glibc 2.31 like the other native libs
runs-on: ubuntu-20.04
strategy:
matrix:
include:
- { arch: x86, container: "i386/ubuntu:20.04" }
- { arch: arm64, container: "arm64v8/ubuntu:20.04" }
- { arch: arm, container: "arm32v7/ubuntu:20.04" }
steps:
- name: Checkout
uses: actions/checkout@v4

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

- name: Build
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
if [ "$(dpkg --print-architecture)" = "i386" ]; then
apt-get install -y nasm
fi
Comment on lines +222 to +224
Copy link
Contributor

Choose a reason for hiding this comment

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

--disable-asm on x86 Linux should mean that this is not needed


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

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

build-android:
name: Build Android
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -228,6 +266,7 @@ jobs:
- build-win
- build-win-arm64
- build-linux
- build-linux-cross
- build-android
steps:
- name: Checkout
Expand All @@ -241,10 +280,22 @@ jobs:
with:
name: iOS-xcframework
path: osu.Framework.iOS/runtimes/ios/native
- uses: actions/download-artifact@v4
with:
name: linux-arm64
path: osu.Framework.NativeLibs/runtimes/linux-arm64/native
- uses: actions/download-artifact@v4
with:
name: linux-arm
path: osu.Framework.NativeLibs/runtimes/linux-arm/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: linux-x86
path: osu.Framework.NativeLibs/runtimes/linux-x86/native
- uses: actions/download-artifact@v4
with:
name: win-arm64
Expand Down
19 changes: 16 additions & 3 deletions osu.Framework.NativeLibs/scripts/ffmpeg/build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,31 @@ SCRIPT_PATH=$(pwd)
popd > /dev/null
source "$SCRIPT_PATH/common.sh"

if [ "$(dpkg --print-architecture)" = "amd64" ]; then
arch="x64"
elif [ "$(dpkg --print-architecture)" = "i386" ]; then
arch="x86"
elif [ "$(dpkg --print-architecture)" = "arm64" ]; then
arch="arm64"
elif [ "$(dpkg --print-architecture)" = "armhf" ]; then
arch="arm"
else
echo "Unsupported architecture: $(dpkg --print-architecture)"
exit 1
fi
Comment on lines +9 to +20
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't use dpkg for this. uname is available almost everywhere while dpkg is Debian-specific.


FFMPEG_FLAGS+=(
--target-os=linux
)

pushd . > /dev/null
prep_ffmpeg linux-x64
prep_ffmpeg linux-$arch
build_ffmpeg
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
6 changes: 6 additions & 0 deletions osu.Framework.NativeLibs/scripts/ffmpeg/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ function prep_ffmpeg() {

function build_ffmpeg() {
echo "-> Configuring..."
if [ "$arch" = "x86" ] && [ "$(uname -s)" = "Linux" ]; then
FFMPEG_FLAGS+=(
--disable-asm
)
fi
Comment on lines +59 to +63
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be moved to build-linux.sh (the other platforms also do arch-specific changes inside their own build scripts, see for example build-win.sh lines 23 - 38)


./configure "${FFMPEG_FLAGS[@]}"

echo "-> Building using $CORES threads..."
Expand Down