summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 6aa9cf99f12b781a3ad63645ab7f867f59e59121 (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
# Mantainer:
# Contributor: PumpkinCheshire <me@pumpkincheshire.top>
# Contributor: katt <magunasu.b97@gmail.com>
# Contributor: Mitch Bigelow <ipha00@gmail.com>
# Contributor: Utkan Güngördü <utkan@freeconsole.org>

_pkgname="waifu2x-ncnn-vulkan"
pkgname="$_pkgname-git"
pkgver=20220728.r0.g93ed2bc
pkgrel=1
pkgdesc="ncnn implementation of waifu2x converter"
url="https://github.com/nihui/waifu2x-ncnn-vulkan"
arch=('i686' 'x86_64' 'aarch64')
license=('MIT')

depends=(
  'libwebp'
  'ncnn'
)
makedepends=(
  'cmake'
  'git'
  'glslang'
  'ninja'
  'vulkan-headers'
)

provides=("$_pkgname")
conflicts=("$_pkgname")

_pkgsrc="$_pkgname"
source=(
  "$_pkgsrc"::"git+$url.git"
  "0001-glslang.patch"
)
sha256sums=(
  'SKIP'
  'd0a08ac4673d84c956e7114385678ebe024ab63e048f0214a01d5cb76666eeeb'
)

pkgver() {
  cd "$_pkgsrc"
  git describe --long --tags --abbrev=7 \
    | sed -E 's/^[^0-9]*//;s/([^-]*-g)/r\1/;s/-/./g'
}

prepare() {
  cd "$_pkgsrc"

  patch -Np1 -F100 -i "../0001-glslang.patch"

  # Fix default model path
  sed -i 's|path_t model = PATHSTR("models-cunet")|path_t model = PATHSTR("/usr/share/waifu2x-ncnn-vulkan/models-cunet")|' src/main.cpp
}

build() {
  local _cmake_options=(
    -B build
    -S "$_pkgsrc/src"
    -G Ninja
    -DCMAKE_BUILD_TYPE=None
    -DCMAKE_INSTALL_PREFIX='/usr'
    -DUSE_SYSTEM_NCNN=ON
    -DUSE_SYSTEM_WEBP=ON
    -Wno-dev
  )

  cmake "${_cmake_options[@]}"
  cmake --build build
}

package() {
  install -Dm755 build/waifu2x-ncnn-vulkan -t "$pkgdir/usr/bin/"
  install -Dm644 "$_pkgsrc/LICENSE" -t "$pkgdir/usr/share/licenses/$pkgname/"

  cd "$_pkgsrc/models"
  for f in models-*/*; do
    install -Dm644 "$f" "$pkgdir/usr/share/$_pkgname/$f"
  done
}