Skip to content

Commit

Permalink
add linux targets
Browse files Browse the repository at this point in the history
  • Loading branch information
kvnp committed Jul 6, 2024
1 parent 4f51628 commit 86f9459
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 3 deletions.
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
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-x64/native
- uses: actions/download-artifact@v4
with:
name: linux-arm
path: osu.Framework.NativeLibs/runtimes/linux-x64/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-x64/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

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" ]; then
FFMPEG_FLAGS+=(
--disable-asm
)
fi

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

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

0 comments on commit 86f9459

Please sign in to comment.