|
| 1 | +# Maintainer: Maksim Bondarenkov <maksapple2306@gmail.com> |
| 2 | + |
| 3 | +_realname=difftastic |
| 4 | +pkgbase=mingw-w64-${_realname} |
| 5 | +pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}" |
| 6 | + "${MINGW_PACKAGE_PREFIX}-${_realname}-docs") |
| 7 | +pkgver=0.67.0 |
| 8 | +pkgrel=1 |
| 9 | +pkgdesc="A structural diff that understands syntax (mingw-w64)" |
| 10 | +arch=('any') |
| 11 | +mingw_arch=('ucrt64' 'clang64' 'clangarm64') |
| 12 | +url='https://difftastic.wilfred.me.uk' |
| 13 | +msys2_repository_url='https://github.com/Wilfred/difftastic' |
| 14 | +license=('spdx:MIT') |
| 15 | +depends=("${MINGW_PACKAGE_PREFIX}-cc-libs") |
| 16 | +makedepends=("${MINGW_PACKAGE_PREFIX}-rust" |
| 17 | + "${MINGW_PACKAGE_PREFIX}-make" |
| 18 | + "${MINGW_PACKAGE_PREFIX}-mdbook" |
| 19 | + 'git') |
| 20 | +source=("git+${msys2_repository_url}#tag=${pkgver}" |
| 21 | + "remove-makedepends-jq.patch" |
| 22 | + "dont-use-jemalloc.patch") |
| 23 | +sha256sums=('d7f053d430cf3e029e3cf8944ab02f11a9ef99b7cf2e8e7bf6cc85aebd7ff0fd' |
| 24 | + 'f72984fbbdce964f71cf7f69ed02fcdde5a0701b7cbd498bd88375476c4b918c' |
| 25 | + '4de77c64e0ee3bdbcaa1476798c5223b4ab89fa6e7a6abfa235bccfcb4c83031') |
| 26 | + |
| 27 | +prepare() { |
| 28 | + cd "${_realname}" |
| 29 | + |
| 30 | + # so tree-sitter grammars can be built |
| 31 | + if test true != "$(git config core.symlinks)"; then |
| 32 | + git config core.symlinks true && |
| 33 | + MSYS='winsymlinks:nativestrict' git restore --source=HEAD :/ |
| 34 | + fi |
| 35 | + |
| 36 | + patch -Np1 -i ../remove-makedepends-jq.patch |
| 37 | + patch -p1 -i ../dont-use-jemalloc.patch |
| 38 | + |
| 39 | + rm rust-toolchain.toml |
| 40 | + cargo fetch --locked --target "${RUST_CHOST}" |
| 41 | +} |
| 42 | + |
| 43 | +build() { |
| 44 | + cd "${_realname}" |
| 45 | + |
| 46 | + export RUSTFLAGS="${RUSTFLAGS/+crt-static/-crt-static}" |
| 47 | + cargo build --release --frozen |
| 48 | + |
| 49 | + # documentation |
| 50 | + cd manual |
| 51 | + sed -i "s/DFT_VERSION_HERE/${pkgver}/g" -i src/introduction.md |
| 52 | + mdbook build |
| 53 | +} |
| 54 | + |
| 55 | +check() { |
| 56 | + cd "${_realname}" |
| 57 | + |
| 58 | + cargo test --release --frozen |
| 59 | +} |
| 60 | + |
| 61 | +package_difftastic() { |
| 62 | + cd "${_realname}" |
| 63 | + |
| 64 | + cargo install \ |
| 65 | + --offline \ |
| 66 | + --no-track \ |
| 67 | + --frozen \ |
| 68 | + --path . \ |
| 69 | + --root "${pkgdir}${MINGW_PREFIX}" |
| 70 | + |
| 71 | + install -Dm644 difft.1 "${pkgdir}${MINGW_PREFIX}/share/man/man1/difft.1" |
| 72 | + install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE" |
| 73 | +} |
| 74 | + |
| 75 | +package_difftastic-docs() { |
| 76 | + pkgdesc+=' (Documentation)' |
| 77 | + depends=() |
| 78 | + |
| 79 | + mkdir -p "${pkgdir}${MINGW_PREFIX}/share/doc/${_realname}/manual" |
| 80 | + cp -vr "${_realname}"/manual/book "${pkgdir}${MINGW_PREFIX}/share/doc/${_realname}/manual" |
| 81 | +} |
| 82 | + |
| 83 | +# vim: set ft=bash : |
| 84 | + |
| 85 | +# generate wrappers |
| 86 | +for _name in "${pkgname[@]}"; do |
| 87 | + _short="package_${_name#${MINGW_PACKAGE_PREFIX}-}" |
| 88 | + _func="$(declare -f "${_short}")" |
| 89 | + eval "${_func/#${_short}/package_${_name}}" |
| 90 | +done |
0 commit comments