# Description: Sccache is a ccache-like tool
# URL: https://github.com/mozilla/sccache
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: rust

name=sccache
version=0.16.0
release=1
source=(https://github.com/mozilla/sccache/archive/v$version/$name-v$version.tar.gz)

build() {
  prt-get isinst sccache && export RUSTC_WRAPPER='/usr/bin/sccache'
  mkdir "$PKGMK_SOURCE_DIR/rust" || true
  export CARGO_HOME="$PKGMK_SOURCE_DIR/rust"

  export CFLAGS+=' -ffat-lto-objects'
  export LDFLAGS+=' -lzstd'

  #if [ $(uname -m) == "x86_64" ]; then
  #  PKGMK_SCCACHE+=',dist-server'
  #fi

  cargo build --manifest-path $name-$version/Cargo.toml --release \
    --features native-zlib,all$PKGMK_SCCACHE
  cargo install --path $name-$version --root $PKG/usr --no-track \
    --frozen --offline --features native-zlib,all$PKGMK_SCCACHE
}
