makedepends=(rustc)

description="Simple, fast and user-friendly alternative to find"
url="https://github.com/sharkdp/fd"

packager="Great-OS Team"
maintainer="Great-OS Team"

name=fd
version=10.3.0
release=2

PKGMK_KEEP_SOURCES="no"

source=($url/archive/v${version}.tar.gz)

prepare() {
  cd fd-$version

  cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}

build() {
  cd fd-$version
  export CFLAGS+=" -ffat-lto-objects"
  cargo build --release --locked --offline
}

package() {
  cd fd-$version
  install -Dm755 target/release/fd $PKG/usr/bin/fd

  make completions
  install -Dm644 autocomplete/fd.bash $PKG/usr/share/bash-completion/completions/fd
  install -Dm644 autocomplete/fd.fish $PKG/usr/share/fish/vendor_completions.d/fd.fish
  install -Dm644 autocomplete/_fd $PKG/usr/share/zsh/site-functions/_fd

  install -Dm644 doc/fd.1 $PKG/usr/share/man/man1/fd.1
  install -Dm644 LICENSE-MIT $PKG/usr/share/licenses/fd/LICENSE-MIT
}

