summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 62cbe1ffb8dc1b23aac62e52d6241ddb434c1989 (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
# Maintainer: Patrick Northon <northon_patrick3@yahoo.ca>

_pkgname=libheif
pkgname=mingw-w64-${_pkgname}
pkgver=1.19.5
pkgrel=1
pkgdesc='HEIF file format decoder and encoder (mingw-w64)'
url='https://github.com/strukturag/libheif'
license=('LGPL')
depends=(
	'mingw-w64-crt'
	'mingw-w64-libpng'
	'mingw-w64-aom'
	'mingw-w64-x265'
	'mingw-w64-libde265'
	'mingw-w64-rav1e'
	'mingw-w64-dav1d'
	'mingw-w64-zlib'
	'mingw-w64-libwebp'
	'mingw-w64-svt-av1' # Only for x86_64
	'mingw-w64-openjpeg2'
	'mingw-w64-ffmpeg'
	'mingw-w64-kvazaar'
)
makedepends=('mingw-w64-cmake' 'ninja')
arch=('any')
options=(!strip !buildflags staticlibs)
optdepends=()
sha256sums=('5cd9a3e28493310358e1c1299cd596cc4c7ae5fb985eceb758fa6141424e58bb')
source=("$_pkgname-$pkgver.tar.gz::https://github.com/strukturag/${_pkgname}/archive/v${pkgver}.tar.gz")

_srcdir="${_pkgname}-${pkgver}"
_architectures='i686-w64-mingw32 x86_64-w64-mingw32'
_flags=(
	-Wno-dev
	-DCMAKE_BUILD_TYPE=Release
	-DCMAKE_CXX_FLAGS_RELEASE='-DNDEBUG -Wno-error=stringop-overflow'
	-DWITH_RAV1E=ON
	-DWITH_RAV1E_PLUGIN=OFF
	-DWITH_SvtEnc=ON # Only supported on 64 bits platforms
	-DWITH_SvtEnc_PLUGIN=OFF
	-DWITH_EXAMPLES=OFF
	-DWITH_REDUCED_VISIBILITY=OFF
	-DWITH_DAV1D=ON
	-DWITH_DAV1D_PLUGIN=OFF
	-DWITH_FFMPEG_DECODER=ON
	-DWITH_FFMPEG_DECODER_PLUGIN=OFF
	-DWITH_OpenJPEG_DECODER=ON
	-DWITH_OpenJPEG_DECODER_PLUGIN=OFF
	-DWITH_KVAZAAR=ON
	-DWITH_KVAZAAR_PLUGIN=OFF )

prepare() {
	cd "${_srcdir}"

	(cat << EOF
include(LibFindMacros)
libfind_pkg_check_modules(RAV1E rav1e)
message(STATUS \${RAV1E_LDFLAGS})
EOF
	) > 'cmake/modules/FindRAV1E.cmake'

  sed -i 's/${${varName}_INCLUDE_DIR}/${${varName}_INCLUDE_DIRS}/' 'libheif/plugins/CMakeLists.txt'
  sed -i 's|./${TEST_NAME}|${TEST_NAME}|g' 'tests/CMakeLists.txt'
  sed -i \
		-e 's/__declspec(dllexport)/__attribute__((__dllexport__))/' \
		-e 's/__declspec(dllimport)/__attribute__((__dllimport__))/' \
		'libheif/api/libheif/heif.h'
}

build() {
	for _arch in ${_architectures}; do
		${_arch}-cmake -G Ninja -S "${_srcdir}" -B "build-${_arch}-static" "${_flags[@]}" \
			-DBUILD_SHARED_LIBS=OFF \
			-DBUILD_TESTING=OFF \
			-DCMAKE_INSTALL_PREFIX="/usr/${_arch}/static"
		cmake --build "build-${_arch}-static"

		${_arch}-cmake -G Ninja -S "${_srcdir}" -B "build-${_arch}" "${_flags[@]}" \
			-DBUILD_TESTING=OFF
		cmake --build "build-${_arch}"
	done
}

check() {
	for _arch in ${_architectures}; do
		${_arch}-cmake -S "${_srcdir}" -B "build-${_arch}" "${_flags[@]}" -DBUILD_TESTING=ON
		cmake --build "build-${_arch}"
		cmake --build "build-${_arch}" --target test
	done
}

package() {
	for _arch in ${_architectures}; do
		DESTDIR="${pkgdir}" cmake --install "build-${_arch}-static"
		${_arch}-strip -g "$pkgdir"/usr/${_arch}/static/lib/*.a

		DESTDIR="${pkgdir}" cmake --install "build-${_arch}"
		${_arch}-strip --strip-unneeded "$pkgdir"/usr/${_arch}/bin/*.dll
		${_arch}-strip -g "$pkgdir"/usr/${_arch}/lib/*.a
	done
}