# Template file for 'forgejo-cli'
pkgname=forgejo-cli
version=0.6.0
revision=1
build_style=cargo
build_helper="rust qemu"
hostmakedepends="pkg-config libgit2-1.9-devel libssh2-devel"
makedepends="libgit2-1.9-devel libssh2-devel openssl-devel"
short_desc="CLI application for interacting with Forgejo"
maintainer="rayfadh <rayfadh@duck.com>"
license="Apache-2.0 OR MIT"
homepage="https://codeberg.org/forgejo-contrib/forgejo-cli"
changelog="https://codeberg.org/forgejo-contrib/forgejo-cli/releases"
distfiles="https://codeberg.org/forgejo-contrib/forgejo-cli/archive/v${version}.tar.gz"
checksum=8b91194cb1886f253261a4567ee6f83aa34b05a9637644793f88b40b7110322a


_setup_env() {
# workaround the cc-rs mixing CFLAGS for host and target.
# https://github.com/rust-lang/cc-rs/issues/1469
export CFLAGS_${RUST_BUILD//-/_}="${CFLAGS_host}" \
	CXXFLAGS_${RUST_BUILD//-/_}="${CXXFLAGS_host}" \
	LDFLAGS_${RUST_BUILD//-/_}="${LDFLAGS_host}" \
	CFLAGS_${RUST_TARGET//-/_}="${CFLAGS}" \
	CXXFLAGS_${RUST_TARGET//-/_}="${CXXFLAGS}" \
	LDFLAGS_${RUST_TARGET//-/_}="${LDFLAGS}" \
	CFLAGS="" CXXFLAGS="" LDFLAGS=""
}

pre_build() {
	_setup_env
}

pre_install() {
	_setup_env
}

post_install() {
	vlicense LICENSE-APACHE
	vlicense LICENSE-MIT

	for _shell in bash fish zsh; do
		vtargetrun ${DESTDIR}/usr/bin/fj completion ${_shell} > fj.${_shell}
		vcompletion fj.${_shell} ${_shell} fj
	done
}
