summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 867e89e7421837811420ded2bea2774bc7e28587 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Maintainer: Gonzalo Exequiel Pedone <hipersayan DOT x AT gmail DOT com>
# Contributor: Antonio Rojas <arojas@archlinux.org>
# Contributor: Adam Fontenot <fontenot@ucla.edu>

_android_arch=x86-64

pkgname=android-${_android_arch}-libheif-bootstrap
pkgver=1.19.2
pkgrel=1
arch=('any')
pkgdesc="An HEIF and AVIF file format decoder and encoder (Android ${_android_arch})"
url='https://github.com/strukturag/libheif'
license=('GPL3')
groups=('android-libheif-bootstrap')
makedepends=('android-cmake'
             "android-${_android_arch}-dav1d"
             "android-${_android_arch}-gdk-pixbuf2"
             "android-${_android_arch}-libjpeg"
             "android-${_android_arch}-libpng"
             "android-${_android_arch}-rav1e"
             "android-${_android_arch}-svt-av1"
             'doxygen')
depends=("android-${_android_arch}-aom"
         "android-${_android_arch}-libde265"
         "android-${_android_arch}-libwebp"
         "android-${_android_arch}-x265")
optdepends=("android-${_android_arch}-libjpeg: for heif-convert and heif-enc"
            "android-${_android_arch}-libpng: for heif-convert and heif-enc"
            "android-${_android_arch}-dav1d: dav1d encoder"
            "android-${_android_arch}-ffmpeg: hardware decode"
            "android-${_android_arch}-rav1e: rav1e encoder"
            "android-${_android_arch}-svt-av1: svt-av1 encoder")
provides=("android-${_android_arch}-libheif")
conflicts=("android-${_android_arch}-libheif")
options=(!strip !buildflags staticlibs !emptydirs)
source=("https://github.com/strukturag/libheif/releases/download/v${pkgver}/libheif-${pkgver}.tar.gz")
md5sums=('1dba03bbb0d34bc5f80908bdfb1cfe93')

build() {
    cd "${srcdir}/libheif-${pkgver}"
    source android-env ${_android_arch}

    openjpeg_dir=$(ls "${ANDROID_PREFIX_LIB}/cmake" | grep openjpeg- | head -n 1)

    android-${_android_arch}-cmake \
        -S . \
        -B build-shared \
        -DBUILD_SHARED_LIBS=ON \
        -DBUILD_TESTING=OFF \
        -DWITH_EXAMPLES=OFF \
        -DWITH_DAV1D=ON \
        -DWITH_RAV1E=ON \
        -DWITH_FFMPEG_DECODER=OFF \
        -DWITH_FFMPEG_DECODER_PLUGIN=OFF \
        -DWITH_SvtEnc=ON \
        -DWITH_JPEG_DECODER=ON \
        -DWITH_JPEG_ENCODER=ON \
        -DWITH_OpenJPEG_DECODER=ON \
        -DWITH_OpenJPEG_ENCODER=ON \
        -DLIBDE265_INCLUDE_DIR="${ANDROID_PREFIX_INCLUDE}" \
        -DLIBDE265_LIBRARY="${ANDROID_PREFIX_LIB}/libde265.so" \
        -DX265_INCLUDE_DIR="${ANDROID_PREFIX_INCLUDE}" \
        -DX265_LIBRARY="${ANDROID_PREFIX_LIB}/libx265.so" \
        -DDAV1D_INCLUDE_DIR="${ANDROID_PREFIX_INCLUDE}" \
        -DDAV1D_LIBRARY="${ANDROID_PREFIX_LIB}/libdav1d.so" \
        -DAOM_INCLUDE_DIR="${ANDROID_PREFIX_INCLUDE}" \
        -DAOM_LIBRARY="${ANDROID_PREFIX_LIB}/libaom.so" \
        -DSvtEnc_INCLUDE_DIR="${ANDROID_PREFIX_INCLUDE}" \
        -DSvtEnc_LIBRARY="${ANDROID_PREFIX_LIB}/libSvtAv1Enc.so" \
        -DRAV1E_INCLUDE_DIR="${ANDROID_PREFIX_INCLUDE}/rav1e" \
        -DRAV1E_LIBRARY="${ANDROID_PREFIX_LIB}/librav1e.so" \
        -DLIBSHARPYUV_INCLUDE_DIR="${ANDROID_PREFIX_INCLUDE}/webp" \
        -DLIBSHARPYUV_LIBRARY="${ANDROID_PREFIX_LIB}/libsharpyuv.so" \
        -DJPEG_INCLUDE_DIR="${ANDROID_PREFIX_INCLUDE}" \
        -DJPEG_LIBRARY_RELEASE="${ANDROID_PREFIX_LIB}/libjpeg.so" \
        -DOpenJPEG_DIR="${ANDROID_PREFIX_LIB}/cmake/$openjpeg_dir"
    sed -i "s|  -lgdk_pixbuf-2.0 |  -L${ANDROID_PREFIX_LIB} -lgdk_pixbuf-2.0 |g" build-shared/gdk-pixbuf/CMakeFiles/pixbufloader-heif.dir/link.txt
    make -C build-shared $MAKEFLAGS

    android-${_android_arch}-cmake \
        -S . \
        -B build-static \
        -DBUILD_SHARED_LIBS=OFF \
        -DBUILD_TESTING=OFF \
        -DWITH_EXAMPLES=OFF \
        -DWITH_DAV1D=ON \
        -DWITH_RAV1E=ON \
        -DWITH_FFMPEG_DECODER=OFF \
        -DWITH_FFMPEG_DECODER_PLUGIN=OFF \
        -DWITH_SvtEnc=ON \
        -DWITH_JPEG_DECODER=ON \
        -DWITH_JPEG_ENCODER=ON \
        -DWITH_OpenJPEG_DECODER=ON \
        -DWITH_OpenJPEG_ENCODER=ON \
        -DWITH_X265=OFF \
        -DLIBDE265_INCLUDE_DIR="${ANDROID_PREFIX_INCLUDE}" \
        -DLIBDE265_LIBRARY="${ANDROID_PREFIX_LIB}/libde265.a" \
        -DDAV1D_INCLUDE_DIR="${ANDROID_PREFIX_INCLUDE}" \
        -DDAV1D_LIBRARY="${ANDROID_PREFIX_LIB}/libdav1d.a" \
        -DAOM_INCLUDE_DIR="${ANDROID_PREFIX_INCLUDE}" \
        -DAOM_LIBRARY="${ANDROID_PREFIX_LIB}/libaom.a" \
        -DSvtEnc_INCLUDE_DIR="${ANDROID_PREFIX_INCLUDE}" \
        -DSvtEnc_LIBRARY="${ANDROID_PREFIX_LIB}/libSvtAv1Enc.a" \
        -DRAV1E_INCLUDE_DIR="${ANDROID_PREFIX_INCLUDE}/rav1e" \
        -DRAV1E_LIBRARY="${ANDROID_PREFIX_LIB}/librav1e.a" \
        -DLIBSHARPYUV_INCLUDE_DIR="${ANDROID_PREFIX_INCLUDE}/webp" \
        -DLIBSHARPYUV_LIBRARY="${ANDROID_PREFIX_LIB}/libsharpyuv.a" \
        -DJPEG_INCLUDE_DIR="${ANDROID_PREFIX_INCLUDE}" \
        -DJPEG_LIBRARY_RELEASE="${ANDROID_PREFIX_LIB}/libjpeg.a" \
        -DOpenJPEG_DIR="${ANDROID_PREFIX_LIB}/cmake/$openjpeg_dir"
    sed -i "s|  -lgdk_pixbuf-2.0 |  -L${ANDROID_PREFIX_LIB} -lgdk_pixbuf-2.0 |g" build-static/gdk-pixbuf/CMakeFiles/pixbufloader-heif.dir/link.txt
    make -C build-static $MAKEFLAGS
}

package() {
    cd "${srcdir}/libheif-${pkgver}"
    source android-env ${_android_arch}

    make -C build-shared DESTDIR="${pkgdir}" install
    make -C build-static DESTDIR="${pkgdir}" install
    find "${pkgdir}/${ANDROID_PREFIX_LIB}" -type f -name '*.so' -exec ${ANDROID_STRIP} -g --strip-unneeded {} \;
    ${ANDROID_STRIP} -g "${pkgdir}/${ANDROID_PREFIX_LIB}"/*.a
}