Skip to content

Commit

Permalink
feat: add native code dependencies for AVIF.
Browse files Browse the repository at this point in the history
  • Loading branch information
skidder committed Dec 12, 2024
1 parent 1d0cb7e commit 596b6a9
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 0 deletions.
48 changes: 48 additions & 0 deletions deps/build-deps-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ rm -rf giflib
rm -rf opencv
rm -rf bzip2
rm -rf ffmpeg
rm -rf libyuv
rm -rf aom
rm -rf libavif

if [ ! -d "$SRCDIR" ]; then
git clone https://github.com/discord/lilliput-dep-source "$SRCDIR"
Expand Down Expand Up @@ -117,6 +120,51 @@ $BASEDIR/ffmpeg/configure --prefix=$PREFIX --disable-doc --disable-programs --di
make
make install

echo '\n--------------------'
echo 'Building libyuv'
echo '--------------------\n'
mkdir -p $BASEDIR/libyuv
tar -xzf $SRCDIR/libyuv.tar.gz -C $BASEDIR/libyuv --strip-components 1
cd $BASEDIR/libyuv
make V=1 -f linux.mk
cp libyuv.a "$PREFIX/lib"
cp -r include/* "$PREFIX/include/"

echo '\n--------------------'
echo 'Building libaom'
echo '--------------------\n'
mkdir -p $BASEDIR/aom
tar -xzf $SRCDIR/aom.tar.gz -C $BASEDIR/aom --strip-components 1
mkdir -p $BUILDDIR/aom
cd $BUILDDIR/aom
cmake $BASEDIR/aom -DENABLE_SHARED=0 -DENABLE_STATIC=1 -DENABLE_TESTS=0 -DENABLE_TOOLS=0 -DENABLE_DOCS=0 -DCMAKE_INSTALL_PREFIX=$PREFIX
make
make install

echo '\n--------------------'
echo 'Building libavif'
echo '--------------------\n'
mkdir -p $BASEDIR/libavif
tar -xzf $SRCDIR/libavif.tar.gz -C $BASEDIR/libavif --strip-components 1
mkdir -p $BUILDDIR/libavif
cd $BUILDDIR/libavif
cmake $BASEDIR/libavif \
-DAVIF_CODEC_AOM=SYSTEM \
-DAVIF_BUILD_APPS=OFF \
-DLIBYUV_LIBRARY=$PREFIX/lib/libyuv.a \
-DLIBYUV_INCLUDE_DIR=$PREFIX/include \
-DAOM_LIBRARY=$PREFIX/lib/libaom.a \
-DAOM_INCLUDE_DIR=$PREFIX/include \
-DJPEG_INCLUDE_DIR=$PREFIX/include \
-DJPEG_LIBRARY=$PREFIX/lib/libjpeg.a \
-DPNG_PNG_INCLUDE_DIR=$PREFIX/include \
-DPNG_LIBRARY=$PREFIX/lib/libpng.a \
-DCMAKE_PREFIX_PATH=$PREFIX \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_INSTALL_PREFIX=$PREFIX
make
make install

rm -rf $BASEDIR/linux/$ARCH/bin
rm -f $BASEDIR/linux/$ARCH/**/*.cmake

Expand Down
86 changes: 86 additions & 0 deletions deps/build-deps-osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ rm -rf giflib
rm -rf opencv
rm -rf bzip2
rm -rf ffmpeg
rm -rf libyuv
rm -rf aom
rm -rf libavif

if [ ! -d "$SRCDIR" ]; then
git clone https://github.com/discord/lilliput-dep-source "$SRCDIR"
Expand Down Expand Up @@ -351,6 +354,89 @@ $BASEDIR/ffmpeg/configure --prefix=$PREFIX --disable-doc --disable-programs --di
make
make install

echo '\n--------------------'
echo 'Building libyuv'
echo '--------------------\n'
mkdir -p $BASEDIR/libyuv
tar -xzf $SRCDIR/libyuv.tar.gz -C $BASEDIR/libyuv --strip-components 1
cd $BASEDIR/libyuv
mkdir -p $BUILDDIR/libyuv
cd $BUILDDIR/libyuv

cmake $BASEDIR/libyuv \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-DCMAKE_C_FLAGS="-arch arm64 -fPIC -O3 -march=armv8-a+crc+crypto -mtune=apple-m1" \
-DCMAKE_CXX_FLAGS="-arch arm64 -fPIC -O3 -march=armv8-a+crc+crypto -mtune=apple-m1" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DBUILD_STATIC_LIBS=ON \
-DLIBYUV_BUILD_SHARED_LIBS=OFF \
-DLIBYUV_DISABLE_SHARED=ON \
-DLIBYUV_ENABLE_STATIC=ON

make
make install

# Remove any dylib if it was created
rm -f $PREFIX/lib/libyuv.dylib

echo '\n--------------------'
echo 'Building libaom'
echo '--------------------\n'
mkdir -p $BASEDIR/aom
tar -xzf $SRCDIR/aom.tar.gz -C $BASEDIR/aom --strip-components 1
mkdir -p $BUILDDIR/aom
cd $BUILDDIR/aom
cmake $BASEDIR/aom \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-DCMAKE_C_FLAGS="-O3 -march=armv8-a+crc+crypto -mtune=apple-m1" \
-DCMAKE_CXX_FLAGS="-O3 -march=armv8-a+crc+crypto -mtune=apple-m1" \
-DENABLE_SHARED=0 \
-DENABLE_STATIC=1 \
-DENABLE_TESTS=0 \
-DENABLE_TOOLS=0 \
-DENABLE_DOCS=0 \
-DENABLE_NEON=1 \
-DENABLE_VSX=0 \
-DCONFIG_MULTITHREAD=1 \
-DCONFIG_RUNTIME_CPU_DETECT=1 \
-DCMAKE_INSTALL_PREFIX=$PREFIX
make
make install

echo '\n--------------------'
echo 'Building libavif'
echo '--------------------\n'
mkdir -p $BASEDIR/libavif
tar -xzf $SRCDIR/libavif.tar.gz -C $BASEDIR/libavif --strip-components 1
mkdir -p $BUILDDIR/libavif
cd $BUILDDIR/libavif
cmake $BASEDIR/libavif \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-DCMAKE_C_FLAGS="-O3 -march=armv8-a+crc+crypto -mtune=apple-m1" \
-DCMAKE_CXX_FLAGS="-O3 -march=armv8-a+crc+crypto -mtune=apple-m1" \
-DAVIF_CODEC_AOM=SYSTEM \
-DAVIF_BUILD_APPS=OFF \
-DAVIF_ENABLE_NEON=ON \
-DLIBYUV_LIBRARY=$PREFIX/lib/libyuv.a \
-DLIBYUV_INCLUDE_DIR=$PREFIX/include \
-DAOM_LIBRARY=$PREFIX/lib/libaom.a \
-DAOM_INCLUDE_DIR=$PREFIX/include \
-DJPEG_INCLUDE_DIR=$PREFIX/include \
-DJPEG_LIBRARY=$PREFIX/lib/libjpeg.a \
-DPNG_PNG_INCLUDE_DIR=$PREFIX/include \
-DPNG_LIBRARY=$PREFIX/lib/libpng.a \
-DCMAKE_PREFIX_PATH=$PREFIX \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_INSTALL_PREFIX=$PREFIX
make
make install

rm -rf $BASEDIR/osx/$ARCH/bin
rm -f $BASEDIR/osx/$ARCH/**/*.cmake

Expand Down

0 comments on commit 596b6a9

Please sign in to comment.