mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-03 03:50:09 +03:00
Add libavif support for iOS (#9117)
Co-authored-by: Andrew Murray <radarhere@users.noreply.github.com>
This commit is contained in:
parent
2ab301dcc9
commit
148e1ac914
37
.github/workflows/wheels-dependencies.sh
vendored
37
.github/workflows/wheels-dependencies.sh
vendored
|
@ -186,30 +186,43 @@ function build_libavif {
|
||||||
|
|
||||||
python3 -m pip install meson ninja
|
python3 -m pip install meson ninja
|
||||||
|
|
||||||
if [[ "$PLAT" == "x86_64" ]] || [ -n "$SANITIZER" ]; then
|
if ([[ "$PLAT" == "x86_64" ]] && [[ -z "$IOS_SDK" ]]) || [ -n "$SANITIZER" ]; then
|
||||||
build_simple nasm 2.16.03 https://www.nasm.us/pub/nasm/releasebuilds/2.16.03
|
build_simple nasm 2.16.03 https://www.nasm.us/pub/nasm/releasebuilds/2.16.03
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local build_type=MinSizeRel
|
local build_type=MinSizeRel
|
||||||
|
local build_shared=ON
|
||||||
local lto=ON
|
local lto=ON
|
||||||
|
|
||||||
local libavif_cmake_flags
|
local libavif_cmake_flags
|
||||||
|
|
||||||
if [ -n "$IS_MACOS" ]; then
|
if [[ -n "$IS_MACOS" ]]; then
|
||||||
lto=OFF
|
lto=OFF
|
||||||
libavif_cmake_flags=(
|
libavif_cmake_flags=(
|
||||||
-DCMAKE_C_FLAGS_MINSIZEREL="-Oz -DNDEBUG -flto" \
|
-DCMAKE_C_FLAGS_MINSIZEREL="-Oz -DNDEBUG -flto" \
|
||||||
-DCMAKE_CXX_FLAGS_MINSIZEREL="-Oz -DNDEBUG -flto" \
|
-DCMAKE_CXX_FLAGS_MINSIZEREL="-Oz -DNDEBUG -flto" \
|
||||||
-DCMAKE_SHARED_LINKER_FLAGS_INIT="-Wl,-S,-x,-dead_strip_dylibs" \
|
-DCMAKE_SHARED_LINKER_FLAGS_INIT="-Wl,-S,-x,-dead_strip_dylibs" \
|
||||||
)
|
)
|
||||||
|
if [[ -n "$IOS_SDK" ]]; then
|
||||||
|
build_shared=OFF
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
if [[ "$MB_ML_VER" == 2014 ]] && [[ "$PLAT" == "x86_64" ]]; then
|
if [[ "$MB_ML_VER" == 2014 ]] && [[ "$PLAT" == "x86_64" ]]; then
|
||||||
build_type=Release
|
build_type=Release
|
||||||
fi
|
fi
|
||||||
libavif_cmake_flags=(-DCMAKE_SHARED_LINKER_FLAGS_INIT="-Wl,--strip-all,-z,relro,-z,now")
|
libavif_cmake_flags=(-DCMAKE_SHARED_LINKER_FLAGS_INIT="-Wl,--strip-all,-z,relro,-z,now")
|
||||||
fi
|
fi
|
||||||
|
if [[ -n "$IOS_SDK" ]] && [[ "$PLAT" == "x86_64" ]]; then
|
||||||
|
libavif_cmake_flags+=(-DAOM_TARGET_CPU=generic)
|
||||||
|
else
|
||||||
|
libavif_cmake_flags+=(
|
||||||
|
-DAVIF_CODEC_AOM_DECODE=OFF \
|
||||||
|
-DAVIF_CODEC_DAV1D=LOCAL
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
|
||||||
local out_dir=$(fetch_unpack https://github.com/AOMediaCodec/libavif/archive/refs/tags/v$LIBAVIF_VERSION.tar.gz libavif-$LIBAVIF_VERSION.tar.gz)
|
local out_dir=$(fetch_unpack https://github.com/AOMediaCodec/libavif/archive/refs/tags/v$LIBAVIF_VERSION.tar.gz libavif-$LIBAVIF_VERSION.tar.gz)
|
||||||
|
|
||||||
# CONFIG_AV1_HIGHBITDEPTH=0 is a flag for libaom (included as a subproject
|
# CONFIG_AV1_HIGHBITDEPTH=0 is a flag for libaom (included as a subproject
|
||||||
# of libavif) that disables support for encoding high bit depth images.
|
# of libavif) that disables support for encoding high bit depth images.
|
||||||
(cd $out_dir \
|
(cd $out_dir \
|
||||||
|
@ -217,20 +230,27 @@ function build_libavif {
|
||||||
-DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX \
|
-DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX \
|
||||||
-DCMAKE_INSTALL_LIBDIR=$BUILD_PREFIX/lib \
|
-DCMAKE_INSTALL_LIBDIR=$BUILD_PREFIX/lib \
|
||||||
-DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib \
|
-DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib \
|
||||||
-DBUILD_SHARED_LIBS=ON \
|
-DBUILD_SHARED_LIBS=$build_shared \
|
||||||
-DAVIF_LIBSHARPYUV=LOCAL \
|
-DAVIF_LIBSHARPYUV=LOCAL \
|
||||||
-DAVIF_LIBYUV=LOCAL \
|
-DAVIF_LIBYUV=LOCAL \
|
||||||
-DAVIF_CODEC_AOM=LOCAL \
|
-DAVIF_CODEC_AOM=LOCAL \
|
||||||
-DCONFIG_AV1_HIGHBITDEPTH=0 \
|
-DCONFIG_AV1_HIGHBITDEPTH=0 \
|
||||||
-DAVIF_CODEC_AOM_DECODE=OFF \
|
|
||||||
-DAVIF_CODEC_DAV1D=LOCAL \
|
|
||||||
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=$lto \
|
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=$lto \
|
||||||
-DCMAKE_C_VISIBILITY_PRESET=hidden \
|
-DCMAKE_C_VISIBILITY_PRESET=hidden \
|
||||||
-DCMAKE_CXX_VISIBILITY_PRESET=hidden \
|
-DCMAKE_CXX_VISIBILITY_PRESET=hidden \
|
||||||
-DCMAKE_BUILD_TYPE=$build_type \
|
-DCMAKE_BUILD_TYPE=$build_type \
|
||||||
"${libavif_cmake_flags[@]}" \
|
"${libavif_cmake_flags[@]}" \
|
||||||
. \
|
$HOST_CMAKE_FLAGS . )
|
||||||
&& make install)
|
|
||||||
|
if [[ -n "$IOS_SDK" ]]; then
|
||||||
|
# libavif's CMake configuration generates a meson cross file... but it
|
||||||
|
# doesn't work for iOS cross-compilation. Copy in Pillow-generated
|
||||||
|
# meson-cross config to replace the cmake-generated version.
|
||||||
|
cp $WORKDIR/meson-cross.txt $out_dir/crossfile-apple.meson
|
||||||
|
fi
|
||||||
|
|
||||||
|
(cd $out_dir && make install)
|
||||||
|
|
||||||
touch libavif-stamp
|
touch libavif-stamp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,10 +288,7 @@ function build {
|
||||||
build_tiff
|
build_tiff
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$IOS_SDK" ]]; then
|
|
||||||
# Short term workaround; don't build libavif on iOS
|
|
||||||
build_libavif
|
build_libavif
|
||||||
fi
|
|
||||||
build_libpng
|
build_libpng
|
||||||
build_lcms2
|
build_lcms2
|
||||||
build_openjpeg
|
build_openjpeg
|
||||||
|
|
|
@ -25,8 +25,7 @@ def test_wheel_modules() -> None:
|
||||||
|
|
||||||
elif sys.platform == "ios":
|
elif sys.platform == "ios":
|
||||||
# tkinter is not available on iOS
|
# tkinter is not available on iOS
|
||||||
# libavif is not available on iOS (for now)
|
expected_modules.remove("tkinter")
|
||||||
expected_modules -= {"tkinter", "avif"}
|
|
||||||
|
|
||||||
assert set(features.get_supported_modules()) == expected_modules
|
assert set(features.get_supported_modules()) == expected_modules
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user