Skip to content

Commit

Permalink
Merge pull request #414 from jellyfin/macos-ci-enhancement
Browse files Browse the repository at this point in the history
ci: improve macOS build
  • Loading branch information
gnattu authored Jul 12, 2024
2 parents beafe65 + 6d69187 commit d80bee1
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 52 deletions.
2 changes: 1 addition & 1 deletion builder/buildmac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ FF_HOST_CFLAGS="$(xargs <<< "$FF_HOST_CFLAGS")"
FF_HOST_LDFLAGS="$(xargs <<< "$FF_HOST_LDFLAGS")"
FFBUILD_TARGET_FLAGS="$(xargs <<< "$FFBUILD_TARGET_FLAGS")"

mkdir build
mkdir -p build
for macbase in images/macos/*.sh; do
cd "$BUILDER_ROOT"/build
source "$BUILDER_ROOT"/"$macbase"
Expand Down
6 changes: 0 additions & 6 deletions builder/images/macos/00-dep.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#!/bin/bash

ffbuild_macbase() {
if [[ $TARGET == mac64 ]]; then
# For unknown reason ffmpeg insist to link to against libx11 and is hard to debug
# It does not link against libx11 on arm64, which is strange
# Remove everything using libx11 on github's x86 macOS host as a workaround
brew uninstall ant cairo gradle harfbuzz kotlin libxext libxft libxrender maven openjdk r sbt selenium-server libx11
fi
brew install wget subversion mercurial autoconf automake cmake meson ninja pkg-config coreutils gcc make python-setuptools pcre2 libtool gnu-sed gnu-tar nasm quilt
mkdir /opt/ffbuild/bin
cp "$BUILDER_ROOT"/images/base/git-mini-clone.sh /opt/ffbuild/bin/git-mini-clone
Expand Down
18 changes: 0 additions & 18 deletions builder/images/macos/02-pcre2.sh

This file was deleted.

20 changes: 0 additions & 20 deletions builder/images/macos/03-glib2.sh

This file was deleted.

2 changes: 2 additions & 0 deletions builder/scripts.d/25-fftw3f.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ SCRIPT_COMMIT="cab901fe465324cb46bd4953e18ddc610ade29b9"
ffbuild_enabled() {
# Dependency of GPL-Only librubberband
[[ $VARIANT == lgpl* ]] && return -1
# Prefer macOS native vDSP
[[ $TARGET == mac* ]] && return -1
return 0
}

Expand Down
6 changes: 6 additions & 0 deletions builder/scripts.d/45-harfbuzz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ ffbuild_dockerbuild() {
--host="$FFBUILD_TOOLCHAIN"
)
elif [[ $TARGET == mac* ]]; then
myconf+=(
--with-glib=no
--with-cairo=no
--with-chafa=no
--with-icu=no
)
# freetype's pkg-config usage cannot find static libbrotli
export FREETYPE_LIBS="$(pkg-config --libs --static freetype2)"
else
Expand Down
9 changes: 7 additions & 2 deletions builder/scripts.d/50-chromaprint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@ ffbuild_dockerbuild() {
mkdir build && cd build

if [[ $TARGET == mac* ]]; then
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" -DBUILD_SHARED_LIBS=OFF -DBUILD_TOOLS=OFF -DBUILD_TESTS=OFF -DFFT_LIB=fftw3f ..
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" -DBUILD_SHARED_LIBS=OFF -DBUILD_TOOLS=OFF -DBUILD_TESTS=OFF -DFFT_LIB=vdsp ..
else
cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" -DBUILD_SHARED_LIBS=OFF -DBUILD_TOOLS=OFF -DBUILD_TESTS=OFF -DFFT_LIB=fftw3f ..
fi

make -j$(nproc)
make install

echo "Libs.private: -lfftw3f -lstdc++" >> "$FFBUILD_PREFIX"/lib/pkgconfig/libchromaprint.pc
if [[ $TARGET != mac* ]]; then
echo "Libs.private: -lfftw3f -lstdc++" >> "$FFBUILD_PREFIX"/lib/pkgconfig/libchromaprint.pc
else
echo "Libs.private: -framework Accelerate -lstdc++" >> "$FFBUILD_PREFIX"/lib/pkgconfig/libchromaprint.pc
fi

echo "Cflags.private: -DCHROMAPRINT_NODLL" >> "$FFBUILD_PREFIX"/lib/pkgconfig/libchromaprint.pc
}

Expand Down
14 changes: 9 additions & 5 deletions builder/variants/defaults-mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ XCODE_MAJOR_VER="$(xcodebuild -version | grep 'Xcode' | awk '{print $2}' | cut -

FF_CFLAGS+="-I"$FFBUILD_PREFIX"/include"
FF_LDFLAGS+="-L"$FFBUILD_PREFIX"/lib"
FF_CONFIGURE+=" --disable-libjack --disable-indev=jack --enable-neon --enable-runtime-cpudetect --enable-audiotoolbox --enable-videotoolbox"
FF_CONFIGURE+=" --disable-libjack --disable-indev=jack --disable-libxcb --disable-xlib --enable-neon --enable-runtime-cpudetect --enable-audiotoolbox --enable-videotoolbox"
FFBUILD_TARGET_FLAGS="--disable-shared --enable-static --pkg-config-flags=\"--static\" --enable-pthreads --cc=clang"
FF_HOST_CFLAGS="-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I"$FFBUILD_PREFIX"/include"
FF_HOST_LDFLAGS=""
if [ $XCODE_MAJOR_VER -ge 15 ]; then
FF_HOST_LDFLAGS+="-Wl,-ld_classic "
export LDFLAGS="-Wl,-ld_classic"
fi

# As of Xcode 15.4, this workaround is no longer needed.
# If you enconters duplicated symbol linker error try uncomment the following
# if [ $XCODE_MAJOR_VER -ge 15 ]; then
# FF_HOST_LDFLAGS+="-Wl,-ld_classic "
# export LDFLAGS="-Wl,-ld_classic"
# fi

FF_HOST_LDFLAGS+="-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -L"$FFBUILD_PREFIX"/lib"
export PKG_CONFIG_LIBDIR="/usr/lib/pkgconfig:/opt/homebrew/Library/Homebrew/os/mac/pkgconfig/$MACOS_MAJOR_VER:/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/$MACOS_MAJOR_VER"
export CMAKE_PREFIX_PATH=""$FFBUILD_PREFIX""
Expand Down

0 comments on commit d80bee1

Please sign in to comment.