SUMMARY="A search tool that combines the usability of ag with the speed of grep"
DESCRIPTION="\
ripgrep (rg) recursively searches your current directory for a regex pattern.
By default, ripgrep will respect your .gitignore and automatically skip hidden
files/directories and binary files."
HOMEPAGE="https://github.com/BurntSushi/ripgrep"
COPYRIGHT="2015 Andrew Gallant"
LICENSE="MIT
	Unlicense"
REVISION="1"
SOURCE_URI="$HOMEPAGE/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="0fb17aaf285b3eee8ddab17b833af1e190d73de317ff9648751ab0660d763ed2"
SOURCE_FILENAME="ripgrep-$portVersion.tar.gz"

SOURCE_URI_2="https://static.crates.io/crates/aho-corasick/aho-corasick-0.7.18.crate"
CHECKSUM_SHA256_2="1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"

SOURCE_URI_3="https://static.crates.io/crates/atty/atty-0.2.14.crate"
CHECKSUM_SHA256_3="d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"

SOURCE_URI_4="https://static.crates.io/crates/base64/base64-0.13.0.crate"
CHECKSUM_SHA256_4="904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"

SOURCE_URI_5="https://static.crates.io/crates/bitflags/bitflags-1.2.1.crate"
CHECKSUM_SHA256_5="cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"

SOURCE_URI_6="https://static.crates.io/crates/bstr/bstr-0.2.16.crate"
CHECKSUM_SHA256_6="90682c8d613ad3373e66de8c6411e0ae2ab2571e879d2efbf73558cc66f21279"

SOURCE_URI_7="https://static.crates.io/crates/bytecount/bytecount-0.6.2.crate"
CHECKSUM_SHA256_7="72feb31ffc86498dacdbd0fcebb56138e7177a8cc5cea4516031d15ae85a742e"

SOURCE_URI_8="https://static.crates.io/crates/cc/cc-1.0.68.crate"
CHECKSUM_SHA256_8="4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787"

SOURCE_URI_9="https://static.crates.io/crates/cfg-if/cfg-if-0.1.10.crate"
CHECKSUM_SHA256_9="4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"

SOURCE_URI_10="https://static.crates.io/crates/cfg-if/cfg-if-1.0.0.crate"
CHECKSUM_SHA256_10="baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"

SOURCE_URI_11="https://static.crates.io/crates/clap/clap-2.33.3.crate"
CHECKSUM_SHA256_11="37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"

SOURCE_URI_12="https://static.crates.io/crates/crossbeam-channel/crossbeam-channel-0.5.1.crate"
CHECKSUM_SHA256_12="06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4"

SOURCE_URI_13="https://static.crates.io/crates/crossbeam-utils/crossbeam-utils-0.8.5.crate"
CHECKSUM_SHA256_13="d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db"

SOURCE_URI_14="https://static.crates.io/crates/encoding_rs/encoding_rs-0.8.28.crate"
CHECKSUM_SHA256_14="80df024fbc5ac80f87dfef0d9f5209a252f2a497f7f42944cff24d8253cac065"

SOURCE_URI_15="https://static.crates.io/crates/encoding_rs_io/encoding_rs_io-0.1.7.crate"
CHECKSUM_SHA256_15="1cc3c5651fb62ab8aa3103998dade57efdd028544bd300516baa31840c252a83"

SOURCE_URI_16="https://static.crates.io/crates/fnv/fnv-1.0.7.crate"
CHECKSUM_SHA256_16="3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"

SOURCE_URI_17="https://static.crates.io/crates/fs_extra/fs_extra-1.2.0.crate"
CHECKSUM_SHA256_17="2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394"

SOURCE_URI_18="https://static.crates.io/crates/glob/glob-0.3.0.crate"
CHECKSUM_SHA256_18="9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"

SOURCE_URI_19="https://static.crates.io/crates/hermit-abi/hermit-abi-0.1.18.crate"
CHECKSUM_SHA256_19="322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c"

SOURCE_URI_20="https://static.crates.io/crates/itoa/itoa-0.4.7.crate"
CHECKSUM_SHA256_20="dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"

SOURCE_URI_21="https://static.crates.io/crates/jemalloc-sys/jemalloc-sys-0.3.2.crate"
CHECKSUM_SHA256_21="0d3b9f3f5c9b31aa0f5ed3260385ac205db665baa41d49bb8338008ae94ede45"

SOURCE_URI_22="https://static.crates.io/crates/jemallocator/jemallocator-0.3.2.crate"
CHECKSUM_SHA256_22="43ae63fcfc45e99ab3d1b29a46782ad679e98436c3169d15a167a1108a724b69"

SOURCE_URI_23="https://static.crates.io/crates/jobserver/jobserver-0.1.22.crate"
CHECKSUM_SHA256_23="972f5ae5d1cb9c6ae417789196c803205313edde988685da5e3aae0827b9e7fd"

SOURCE_URI_24="https://static.crates.io/crates/lazy_static/lazy_static-1.4.0.crate"
CHECKSUM_SHA256_24="e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"

SOURCE_URI_25="https://static.crates.io/crates/libc/libc-0.2.97.crate"
CHECKSUM_SHA256_25="12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6"

SOURCE_URI_26="https://static.crates.io/crates/libm/libm-0.1.4.crate"
CHECKSUM_SHA256_26="7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a"

SOURCE_URI_27="https://static.crates.io/crates/log/log-0.4.14.crate"
CHECKSUM_SHA256_27="51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"

SOURCE_URI_28="https://static.crates.io/crates/memchr/memchr-2.4.0.crate"
CHECKSUM_SHA256_28="b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc"

SOURCE_URI_29="https://static.crates.io/crates/memmap2/memmap2-0.3.0.crate"
CHECKSUM_SHA256_29="20ff203f7bdc401350b1dbaa0355135777d25f41c0bbc601851bbd6cf61e8ff5"

SOURCE_URI_30="https://static.crates.io/crates/num_cpus/num_cpus-1.13.0.crate"
CHECKSUM_SHA256_30="05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"

SOURCE_URI_31="https://static.crates.io/crates/once_cell/once_cell-1.7.2.crate"
CHECKSUM_SHA256_31="af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3"

SOURCE_URI_32="https://static.crates.io/crates/packed_simd_2/packed_simd_2-0.3.5.crate"
CHECKSUM_SHA256_32="0e64858a2d3733fdd61adfdd6da89aa202f7ff0e741d2fc7ed1e452ba9dc99d7"

SOURCE_URI_33="https://static.crates.io/crates/pcre2/pcre2-0.2.3.crate"
CHECKSUM_SHA256_33="85b30f2f69903b439dd9dc9e824119b82a55bf113b29af8d70948a03c1b11ab1"

SOURCE_URI_34="https://static.crates.io/crates/pcre2-sys/pcre2-sys-0.2.5.crate"
CHECKSUM_SHA256_34="dec30e5e9ec37eb8fbf1dea5989bc957fd3df56fbee5061aa7b7a99dbb37b722"

SOURCE_URI_35="https://static.crates.io/crates/pkg-config/pkg-config-0.3.19.crate"
CHECKSUM_SHA256_35="3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"

SOURCE_URI_36="https://static.crates.io/crates/proc-macro2/proc-macro2-1.0.27.crate"
CHECKSUM_SHA256_36="f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038"

SOURCE_URI_37="https://static.crates.io/crates/quote/quote-1.0.9.crate"
CHECKSUM_SHA256_37="c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"

SOURCE_URI_38="https://static.crates.io/crates/regex/regex-1.5.4.crate"
CHECKSUM_SHA256_38="d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"

SOURCE_URI_39="https://static.crates.io/crates/regex-automata/regex-automata-0.1.10.crate"
CHECKSUM_SHA256_39="6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"

SOURCE_URI_40="https://static.crates.io/crates/regex-syntax/regex-syntax-0.6.25.crate"
CHECKSUM_SHA256_40="f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"

SOURCE_URI_41="https://static.crates.io/crates/ryu/ryu-1.0.5.crate"
CHECKSUM_SHA256_41="71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"

SOURCE_URI_42="https://static.crates.io/crates/same-file/same-file-1.0.6.crate"
CHECKSUM_SHA256_42="93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"

SOURCE_URI_43="https://static.crates.io/crates/serde/serde-1.0.126.crate"
CHECKSUM_SHA256_43="ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03"

SOURCE_URI_44="https://static.crates.io/crates/serde_derive/serde_derive-1.0.126.crate"
CHECKSUM_SHA256_44="963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43"

SOURCE_URI_45="https://static.crates.io/crates/serde_json/serde_json-1.0.64.crate"
CHECKSUM_SHA256_45="799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79"

SOURCE_URI_46="https://static.crates.io/crates/strsim/strsim-0.8.0.crate"
CHECKSUM_SHA256_46="8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"

SOURCE_URI_47="https://static.crates.io/crates/syn/syn-1.0.73.crate"
CHECKSUM_SHA256_47="f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7"

SOURCE_URI_48="https://static.crates.io/crates/termcolor/termcolor-1.1.2.crate"
CHECKSUM_SHA256_48="2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"

SOURCE_URI_49="https://static.crates.io/crates/textwrap/textwrap-0.11.0.crate"
CHECKSUM_SHA256_49="d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"

SOURCE_URI_50="https://static.crates.io/crates/thread_local/thread_local-1.1.3.crate"
CHECKSUM_SHA256_50="8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd"

SOURCE_URI_51="https://static.crates.io/crates/unicode-width/unicode-width-0.1.8.crate"
CHECKSUM_SHA256_51="9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"

SOURCE_URI_52="https://static.crates.io/crates/unicode-xid/unicode-xid-0.2.2.crate"
CHECKSUM_SHA256_52="8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"

SOURCE_URI_53="https://static.crates.io/crates/walkdir/walkdir-2.3.2.crate"
CHECKSUM_SHA256_53="808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"

SOURCE_URI_54="https://static.crates.io/crates/winapi/winapi-0.3.9.crate"
CHECKSUM_SHA256_54="5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"

SOURCE_URI_55="https://static.crates.io/crates/winapi-i686-pc-windows-gnu/winapi-i686-pc-windows-gnu-0.4.0.crate"
CHECKSUM_SHA256_55="ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"

SOURCE_URI_56="https://static.crates.io/crates/winapi-util/winapi-util-0.1.5.crate"
CHECKSUM_SHA256_56="70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"

SOURCE_URI_57="https://static.crates.io/crates/winapi-x86_64-pc-windows-gnu/winapi-x86_64-pc-windows-gnu-0.4.0.crate"
CHECKSUM_SHA256_57="712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

ARCHITECTURES="all !x86_gcc2"
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
SECONDARY_ARCHITECTURES="x86"
commandBinDir=$prefix/bin
fi

PROVIDES="
	ripgrep$secondaryArchSuffix = $portVersion
	cmd:rg
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	lib:libxslt$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:a2x
	cmd:gcc$secondaryArchSuffix
	cmd:rustc$secondaryArchSuffix >= 1.39.0
	"

defineDebugInfoPackage ripgrep$secondaryArchSuffix \
	"$commandBinDir"/rg

BUILD()
{
	export CARGO_HOME=$sourceDir/../cargo
	vendor=$CARGO_HOME/haiku
	mkdir -p "$vendor"
	for i in $(seq 2 57); do
		eval "srcDir=\$sourceDir$i"
		eval "sha256sum=\$CHECKSUM_SHA256_$i"
		set -- "$srcDir"/*
		ln -sf "$1" "$vendor"
		cat <<-EOF >"$vendor/${1##*/}/.cargo-checksum.json"
		{
		  "package": "$sha256sum",
		  "files": {}
		}
		EOF
	done

	cat <<-EOF >"$CARGO_HOME"/config
	[source.haiku]
	directory = "$vendor"

	[source.crates-io]
	replace-with = "haiku"
	EOF

	cargo build --release --frozen --features pcre2
}

INSTALL()
{
	install -m 755 -d "$commandBinDir" "$docDir" "$manDir"/man1 \
		"$dataDir"/bash-completions/completions \
		"$dataDir"/zsh/site-functions

	install -m 755 target/release/rg "$commandBinDir"
	install -m 644 README.md "$docDir"
	install -m 644 target/release/build/ripgrep-*/out/rg.1 "$manDir"/man1

	install -m 644 target/release/build/ripgrep-*/out/rg.bash \
		"$dataDir"/bash-completions/completions/rg
	install -m 644 complete/_rg "$dataDir"/zsh/site-functions
}

TEST()
{
	export CARGO_HOME=$sourceDir/../cargo
	cargo test --release --frozen --features pcre2
}
