Skip to content

Commit

Permalink
libavif: simplify install_libavif.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
fdintino committed Apr 12, 2021
1 parent 616f70b commit b851ca6
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .ci/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ python3 -m pip install -U pytest-cov
python3 -m pip install -U pytest-timeout
python3 -m pip install pyroma
python3 -m pip install test-image-results
python3 -m pip install meson

# TODO Remove condition when numpy supports 3.10
if ! [ "$GHA_PYTHON_VERSION" == "3.10-dev" ]; then python3 -m pip install numpy ; fi

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/macos-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

set -e

brew install libtiff libjpeg openjpeg libimagequant webp little-cms2 freetype openblas libraqm cmake nasm ninja meson
brew install \
libtiff libjpeg openjpeg libimagequant webp little-cms2 freetype openblas \
libraqm dav1d aom rav1e

PYTHONOPTIMIZE=0 python3 -m pip install cffi
python3 -m pip install coverage
Expand Down
58 changes: 45 additions & 13 deletions depends/install_libavif.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ else
MAKE_INSTALL=(sudo make install)
fi

PKGCONFIG=${PKGCONFIG:-pkg-config}

export CFLAGS="-fPIC -O3 $CFLAGS"
export CXXFLAGS="-fPIC -O3 $CXXFLAGS"

Expand All @@ -19,24 +21,54 @@ curl -sLo - \
| tar Czxf . -
pushd libavif-$LIBAVIF_VERSION

cd ext
bash libyuv.cmd
bash aom.cmd
# dav1d needs to be compiled with -Denable_avx512=false to accomodate
# older nasm on some systems
perl -pi -e 's/^meson /meson -Denable_avx512=false /g' dav1d.cmd
bash dav1d.cmd
cd ..
HAS_DECODER=0
HAS_ENCODER=0

if $PKGCONFIG --exists dav1d; then
LIBAVIF_CMAKE_FLAGS+=(-DAVIF_CODEC_DAV1D=ON)
HAS_DECODER=1
fi

if $PKGCONFIG --exists rav1e; then
LIBAVIF_CMAKE_FLAGS+=(-DAVIF_CODEC_RAV1E=ON)
HAS_ENCODER=1
fi

if $PKGCONFIG --exists SvtAv1Enc; then
LIBAVIF_CMAKE_FLAGS+=(-DAVIF_CODEC_SVT=ON)
HAS_ENCODER=1
fi

if $PKGCONFIG --exists libgav1; then
LIBAVIF_CMAKE_FLAGS+=(-DAVIF_CODEC_LIBGAV1=ON)
HAS_DECODER=1
fi

if $PKGCONFIG --exists aom; then
LIBAVIF_CMAKE_FLAGS+=(-DAVIF_CODEC_AOM=ON)
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)
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
cd build
cmake .. \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DAVIF_CODEC_AOM=ON \
-DAVIF_LOCAL_AOM=ON \
-DAVIF_CODEC_DAV1D=ON \
-DAVIF_LOCAL_DAV1D=ON \
-DAVIF_LOCAL_LIBYUV=ON
-DCMAKE_BUILD_TYPE=Release \
"${LIBAVIF_CMAKE_FLAGS[@]}"
make && "${MAKE_INSTALL[@]}"
cd ..

Expand Down
3 changes: 1 addition & 2 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ Then see ``depends/install_raqm_cmake.sh`` to install libraqm.

To install libavif on macOS use Homebrew to install its build dependencies::

brew install nasm ninja meson cmake
brew install aom dav1d rav1e

Then see ``depends/install_libavif.sh`` to install libavif.

Expand Down Expand Up @@ -411,7 +411,6 @@ See ``depends/install_raqm.sh`` to install libraqm.
Build prerequisites for libavif on Ubuntu are installed with::

sudo apt-get install cmake ninja-build nasm
sudo python3 -m pip install meson

Then see ``depends/install_libavif.sh`` to build and install libavif.

Expand Down

0 comments on commit b851ca6

Please sign in to comment.