# Description:  A cat(1) clone with wings
# URL: https://github.com/sharkdp/bat
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: rust
# Optional: libgit2

name=bat
version=0.26.1
release=1
source=(https://github.com/sharkdp/bat/archive/v$version/$name-$version.tar.gz)

build() {
  prt-get isinst libgit2 && PKGMK_BAT+=' git'

  prt-get isinst sccache && export RUSTC_WRAPPER=/usr/bin/sccache
  [[ ! -e $PKGMK_SOURCE_DIR/rust ]] && mkdir $PKGMK_SOURCE_DIR/rust

  export CFLAGS+=' -ffat-lto-objects -w'
  cargo build --release --manifest-path $name-$version/Cargo.toml \
    --features "bugreport build-assets minimal-application $PKGMK_BAT"

  prt-get isinst bash-completion && install -Dm644 \
    $name-$version/target/release/build/bat-*/out/assets/completions/bat.bash \
    $PKG/usr/share/bash-completion/completions/bat
  prt-get isinst zsh && install -Dm644 \
    $name-$version/target/release/build/bat-*/out/assets/completions/bat.zsh \
    $PKG/usr/share/zsh/site-functions/_bat

  install -Dm644 $name-$version/target/release/build/bat-*/out/assets/manual/bat.1 \
    $PKG/usr/share/man/man1/bat.1
  install -Dt $PKG/usr/bin $name-$version/target/release/$name
}
