### this file is sourced not run

PKGVER=2024.07.15

PKGBUILD=1
PKGARCH=x86_64

# source: step PKGBUILD/fccf

### This is not a fully reproducible build.
# The CMake module ExternalProject downloads three dependencies from GitHub:
# https://github.com/p-ranav/argparse.git master
# https://github.com/fmtlib/fmt.git master
# https://github.com/nlohmann/json/releases/download/v3.10.5/json.tar.xz
# It uses git clone for the two masters and CMake's own internal downloader
# for the third project.
# I found a hack to work around the git clone (hack included but disabled
# in pkg_build()). But I can't find a way around the third download.
# Therefore, I let CMake download all three dependencies, and declare this
# a non-reproducible build :(

VERSION=0.6.0+11 # hash7 is 11th commit on 2024-04-12 after release 0.6.0
hash=644f8875fa5dc760ae7b7c4c447a33c7e1ba6e57
hash7=${hash#???????}; hash7=${hash%"$hash7"}
TARBALL=fccf-$PKGVER-${hash7}.tar.gz SRC_URL=https://github.com/p-ranav/fccf/archive/${hash}.tar.gz
MD5SUM=b4087dd242e7615bb5ad8f407e04e52f
BUNDLE=

SLACKREQ='llvm-clang' # git and lfs-cacert build time
SLACKDESC="fccf: fccf $PKGVER $VERSION $hash7 (source code search tool)
fccf:
fccf: fccf is a command-line tool that quickly searches through C/C++ source code
fccf: in a directory based on a search string and prints relevant code snippets
fccf: that match the query.
fccf:
fccf:
fccf: https://github.com/p-ranav/fccf
fccf:
fccf:
fccf:
"
SLACKSUG=''

### default pkg_download
### default pkg_prepare
### default pkg_package
### build
pkg_build() {
	cd /tmp/fccf-* &&

if false; then
	### Reproducible build hack to convince CMake module "ExternalProject",
	# that it's downloading dependencies from GitHub.  Instead we pre-packaged
	# the dependencies.  Here's is the local git fake for the task:
	mkdir build &&
	echo '
	printf "%s\n" "pwd: $(pwd)" "fake git $*" >&2
	case "$*" in
	--version)
		echo "git version 2.41.0"
	;;
	# argparse-src and fmt-src: pre-cloned with git and saved to ../pkg/git_deps
	# but not included in this recipe because they take up 18MB compressed
	*clone*argparse-src)
		cp -a /tmp/pkg/git_deps/argparse-src ./
	;;
	*clone*fmt-src)
		cp -a /tmp/pkg/git_deps/fmt-src ./
	;;
	*rev-parse*HEAD^0)
		cat .git/refs/heads/master
	;;
	esac
	' > /usr/bin/git &&
	chmod +x /usr/bin/git # &&
fi &&

	# CMake wants to download dependencies
	echo 'nameserver 9.9.9.9' > /etc/resolv.conf &&
	cmake -S . -B build \
		-D CMAKE_INSTALL_PREFIX=/usr \
		-D CMAKE_BUILD_TYPE=Release &&
	cmake --build build &&
	cmake --install build &&
	rm -f /etc/resolv.conf /usr/bin/git &&
	pkg_build_slackdesc
}

# vim:ft=sh:

