summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 56d0542434cf4a68c782c7bf2b8473d08c91af04 (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
# Maintainer: Christoph Haag <christoph.haag@collabora.com>

_pkgname=onnxruntime
pkgname=onnxruntime-git
pkgver=1.17.0.r10276.db3c076081
pkgrel=1
pkgdesc="cross-platform inference and training machine-learning accelerator."
arch=('x86_64')
url="https://onnxruntime.ai/"
license=('MIT')
depends=('gcc-libs' 'python' 'protobuf')
makedepends=('git' 'cmake' 'ninja' 'clang')
checkdepends=()
optdepends=()
provides=('onnxruntime')
conflicts=('onnxruntime')
replaces=()
options=()
source=("git+https://github.com/microsoft/onnxruntime.git#branch=main")
md5sums=('SKIP')

prepare() {
	cd "$_pkgname"
	git submodule update --init --recursive
	(pacman -Qq nsync && sed -i 's/nsync::nsync_cpp/nsync_cpp/g' cmake/{**,.}/*.cmake cmake/CMakeLists.txt) || true
}

pkgver() {
  cd "$_pkgname"
  echo $(cat ./VERSION_NUMBER).r$(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

build() {
	cd "$_pkgname"
	# ./build.sh --config RelWithDebInfo --build_shared_lib --parallel
	# export PKG_CONFIG_PATH=/usr/lib/pkgconfig
	# rm -rf $srcdir/$_pkgname-build


	export CC=clang
	export CXX=clang++

	cmake -S "$srcdir"/$_pkgname/cmake \
		-B "$srcdir"/$_pkgname-build \
		-G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr/ \
		-DCMAKE_PREFIX_PATH=/usr/ \
		-DCMAKE_BUILD_TYPE=Release \
		-Donnxruntime_BUILD_SHARED_LIB=ON \
		-DONNX_USE_PROTOBUF_SHARED_LIBS=ON \
		-DPYTHON_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
		-DPYTHON_LIBRARY=$(python -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))") \
		-DPYTHON_EXECUTABLE:FILEPATH=$(which python) \
		-DCMAKE_IGNORE_PATH=/usr/lib/cmake/flatbuffers/\;/lib/cmake/flatbuffers/ \

	sed -i 's/-Werror //g' "$srcdir"/$_pkgname-build/_deps/flatbuffers-src/CMakeLists.txt

	# Fix build with gcc. See also
	# * https://github.com/pytorch/pytorch/issues/77939
	# * https://github.com/opencv/opencv/pull/22512
	sed -i 's/\"-mavx512f\"/\"-mavx512f -Wno-error\"/g' "$srcdir"/$_pkgname/cmake/onnxruntime_mlas.cmake

	ninja -C "$srcdir"/$_pkgname-build
}

check() {
	cd "$_pkgname"
	#make -k check
}

package() {
	cd "$srcdir"/$_pkgname
	DESTDIR="$pkgdir/" ninja -C "$srcdir"/$_pkgname-build install
}