summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 3a49b5c971552a6099f955e237100d36b5438a98 (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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Maintainer: Karl-Felix Glatzer <karl[dot]glatzer[at]gmx[dot]de>
# Contributor: Maxime Gauduin <alucryd@archlinux>org>
# Contributor: quietvoid <tcChlisop0@gmail.com>

pkgname=mingw-w64-libdovi
pkgver=3.3.0
pkgrel=1
pkgdesc='Library to read and write Dolby Vision metadata (mingw-w64)'
arch=('i686' 'x86_64')
url=https://github.com/quietvoid/dovi_tool/tree/main/dolby_vision
license=(MIT)
depends=(
  mingw-w64-crt
)
options=(!strip !buildflags staticlibs)
makedepends=(
  cargo-c
  git
  mingw-w64-rust
)
_tag=108f7892fa9c5c5b24caec29f2289cf805e52119
source=(git+https://github.com/quietvoid/dovi_tool.git#tag=${_tag})
b2sums=(SKIP)
_architectures="i686-w64-mingw32 x86_64-w64-mingw32"

prepare() {
  if [[ -d "${RUST_PATH}" ]] ; then
    export PATH="${RUST_PATH}:${PATH}"
  else
    export PATH="/opt/rust/bin:${PATH}"
  fi
  if [[ ! -d "${CARGO_HOME}" ]] ; then
    export CARGO_HOME="/opt/rust/cargo"
  fi

  cargo fetch \
    --manifest-path dovi_tool/dolby_vision/Cargo.toml
}

#pkgver() {
#  cd dovi_tool
#  git describe --tags | sed 's/^libdovi-//'
#}

build() {
  if [[ -d "${RUST_PATH}" ]] ; then
    export PATH="${RUST_PATH}:${PATH}"
  else
    export PATH="/opt/rust/bin:${PATH}"
  fi
  if [[ ! -d "${CARGO_HOME}" ]] ; then
    export CARGO_HOME="/opt/rust/cargo"
  fi

  for _arch in ${_architectures}; do
    if [[ ${_arch} = i686-w64-mingw32 ]] ; then
      export RUST_TARGET=i686-pc-windows-gnu
    fi
    if [[ ${_arch} = x86_64-w64-mingw32 ]] ; then
      export RUST_TARGET=x86_64-pc-windows-gnu
    fi

    export DLLTOOL="${_arch}-dlltool"

    cargo cbuild \
      --verbose \
      --verbose \
      --target ${RUST_TARGET} \
      --release \
      --frozen \
      --prefix=/usr/${_arch} \
      --manifest-path dovi_tool/dolby_vision/Cargo.toml
   done
}

check() {
  if [[ -d "${RUST_PATH}" ]] ; then
    export PATH="${RUST_PATH}:${PATH}"
  else
    export PATH="/opt/rust/bin:${PATH}"
  fi
  if [[ ! -d "${CARGO_HOME}" ]] ; then
    export CARGO_HOME="/opt/rust/cargo"
  fi

  for _arch in ${_architectures}; do
    if [[ ${_arch} = i686-w64-mingw32 ]] ; then
      export RUST_TARGET=i686-pc-windows-gnu
    fi
    if [[ ${_arch} = x86_64-w64-mingw32 ]] ; then
      export RUST_TARGET=x86_64-pc-windows-gnu
    fi

    cargo test \
      --target ${RUST_TARGET} \
      --release \
      --frozen \
      --all-features \
      --manifest-path dovi_tool/dolby_vision/Cargo.toml
   done
}

package() {
  cd dovi_tool/dolby_vision

  if [[ -d "${RUST_PATH}" ]] ; then
    export PATH="${RUST_PATH}:${PATH}"
  else
    export PATH="/opt/rust/bin:${PATH}"
  fi
  if [[ ! -d "${CARGO_HOME}" ]] ; then
    export CARGO_HOME="/opt/rust/cargo"
  fi

  for _arch in ${_architectures}; do
    if [[ ${_arch} = i686-w64-mingw32 ]] ; then
      export RUST_TARGET=i686-pc-windows-gnu
    fi
    if [[ ${_arch} = x86_64-w64-mingw32 ]] ; then
      export RUST_TARGET=x86_64-pc-windows-gnu
    fi

    cargo cinstall \
      --target ${RUST_TARGET} \
      --release \
      --frozen \
      --prefix /usr/${_arch} \
      --destdir "${pkgdir}"

    # somehow dlltool invocation of cargo cbuild produces a broken implib
    rm "${pkgdir}"/usr/${_arch}/lib/dovi.dll.a
    ${_arch}-dlltool -d "${pkgdir}"/usr/${_arch}/lib/dovi.def -D dovi.dll -l "${pkgdir}"/usr/${_arch}/lib/dovi.dll.a

    ${_arch}-strip --strip-unneeded "${pkgdir}"/usr/${_arch}/bin/*.dll
    ${_arch}-strip -g "${pkgdir}"/usr/${_arch}/lib/*.a

    install -Dm 644 LICENSE -t "${pkgdir}"/usr/${_arch}/share/licenses/libdovi/
  done
}

# vim: ts=2 sw=2 et: