forked from python-pillow/Pillow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
16 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,59 @@ | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
|
||
LIBAVIF_VERSION=${LIBAVIF_VERSION:-12e066686892df1c8201cfb0d8d6c68ad248c872} | ||
version=1.1.1 | ||
|
||
LIBAVIF_CMAKE_FLAGS=() | ||
./download-and-extract.sh libavif-$version https://github.com/AOMediaCodec/libavif/archive/refs/tags/v$version.tar.gz | ||
|
||
pushd libavif-$version | ||
|
||
if uname -s | grep -q Darwin; then | ||
PREFIX=/usr/local | ||
PREFIX=$(brew --prefix) | ||
else | ||
PREFIX=/usr | ||
fi | ||
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
|
||
PKGCONFIG=${PKGCONFIG:-pkg-config} | ||
|
||
mkdir -p libavif-$LIBAVIF_VERSION | ||
curl -sLo - \ | ||
https://github.com/AOMediaCodec/libavif/archive/$LIBAVIF_VERSION.tar.gz \ | ||
| tar --strip-components=1 -C libavif-$LIBAVIF_VERSION -zxf - | ||
pushd libavif-$LIBAVIF_VERSION | ||
|
||
LIBAVIF_CMAKE_FLAGS=() | ||
HAS_DECODER=0 | ||
HAS_ENCODER=0 | ||
|
||
if $PKGCONFIG --exists dav1d; then | ||
LIBAVIF_CMAKE_FLAGS+=(-DAVIF_CODEC_DAV1D=ON) | ||
LIBAVIF_CMAKE_FLAGS+=(-DAVIF_CODEC_DAV1D=SYSTEM) | ||
HAS_DECODER=1 | ||
fi | ||
|
||
if $PKGCONFIG --exists rav1e; then | ||
LIBAVIF_CMAKE_FLAGS+=(-DAVIF_CODEC_RAV1E=ON) | ||
LIBAVIF_CMAKE_FLAGS+=(-DAVIF_CODEC_RAV1E=SYSTEM) | ||
HAS_ENCODER=1 | ||
fi | ||
|
||
if $PKGCONFIG --exists SvtAv1Enc; then | ||
LIBAVIF_CMAKE_FLAGS+=(-DAVIF_CODEC_SVT=ON) | ||
LIBAVIF_CMAKE_FLAGS+=(-DAVIF_CODEC_SVT=SYSTEM) | ||
HAS_ENCODER=1 | ||
fi | ||
|
||
if $PKGCONFIG --exists libgav1; then | ||
LIBAVIF_CMAKE_FLAGS+=(-DAVIF_CODEC_LIBGAV1=ON) | ||
LIBAVIF_CMAKE_FLAGS+=(-DAVIF_CODEC_LIBGAV1=SYSTEM) | ||
HAS_DECODER=1 | ||
fi | ||
|
||
if $PKGCONFIG --exists aom; then | ||
LIBAVIF_CMAKE_FLAGS+=(-DAVIF_CODEC_AOM=ON) | ||
LIBAVIF_CMAKE_FLAGS+=(-DAVIF_CODEC_AOM=SYSTEM) | ||
HAS_ENCODER=1 | ||
HAS_DECODER=1 | ||
fi | ||
|
||
if [ "$HAS_ENCODER" != 1 ] || [ "$HAS_DECODER" != 1 ]; then | ||
pushd ext > /dev/null | ||
bash aom.cmd | ||
popd > /dev/null | ||
LIBAVIF_CMAKE_FLAGS+=(-DAVIF_CODEC_AOM=ON -DAVIF_LOCAL_AOM=ON) | ||
LIBAVIF_CMAKE_FLAGS+=(-DAVIF_CODEC_AOM=LOCAL) | ||
fi | ||
|
||
if uname -s | grep -q Darwin; then | ||
# Prevent cmake from using @rpath in install id, so that delocate can | ||
# find and bundle the libavif dylib | ||
LIBAVIF_CMAKE_FLAGS+=("-DCMAKE_INSTALL_NAME_DIR=$PREFIX/lib" -DCMAKE_MACOSX_RPATH=OFF) | ||
fi | ||
|
||
mkdir build | ||
pushd build | ||
cmake .. \ | ||
cmake -S . -B build \ | ||
-DCMAKE_INSTALL_PREFIX=$PREFIX \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DBUILD_SHARED_LIBS=OFF \ | ||
-DCMAKE_INSTALL_NAME_DIR=$PREFIX/lib \ | ||
-DCMAKE_MACOSX_RPATH=OFF \ | ||
"${LIBAVIF_CMAKE_FLAGS[@]}" | ||
make | ||
make install || sudo make install | ||
popd | ||
|
||
popd |