SUMMARY="A high performance CSV command line toolkit"
DESCRIPTION="xsv is a command line program for indexing, slicing, analyzing, \
splitting and joining CSV files. Commands should be simple, fast and composable:

1. Simple tasks should be easy.
2. Performance trade offs should be exposed in the CLI interface.
3. Composition should not come at the expense of performance."
HOMEPAGE="https://github.com/BurntSushi/xsv"
COPYRIGHT="2015 Andrew Gallant"
LICENSE="Unlicense
	MIT"
REVISION="1"
SOURCE_URI="$HOMEPAGE/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="2b75309b764c9f2f3fdc1dd31eeea5a74498f7da21ae757b3ffd6fd537ec5345"
SOURCE_FILENAME="xsv-$portVersion.tar.gz"

SOURCE_URI_2="https://static.crates.io/crates/aho-corasick/aho-corasick-0.6.4.crate"
CHECKSUM_SHA256_2="d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4"

SOURCE_URI_3="https://static.crates.io/crates/bitflags/bitflags-1.0.3.crate"
CHECKSUM_SHA256_3="d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789"

SOURCE_URI_4="https://static.crates.io/crates/byteorder/byteorder-1.2.2.crate"
CHECKSUM_SHA256_4="73b5bdfe7ee3ad0b99c9801d58807a9dbc9e09196365b0203853b99889ab3c87"

SOURCE_URI_5="https://static.crates.io/crates/cfg-if/cfg-if-0.1.3.crate"
CHECKSUM_SHA256_5="405216fd8fe65f718daa7102ea808a946b6ce40c742998fbfd3463645552de18"

SOURCE_URI_6="https://static.crates.io/crates/chan/chan-0.1.21.crate"
CHECKSUM_SHA256_6="9af7c487bb99c929ba2715b1a3a7bf45f5062bf5b6eae5d32b292a96c5865172"

SOURCE_URI_7="https://static.crates.io/crates/csv/csv-1.0.0.crate"
CHECKSUM_SHA256_7="71903184af9960c555e7f3b32ff17390d20ecaaf17d4f18c4a0993f2df8a49e3"

SOURCE_URI_8="https://static.crates.io/crates/csv-core/csv-core-0.1.4.crate"
CHECKSUM_SHA256_8="4dd8e6d86f7ba48b4276ef1317edc8cc36167546d8972feb4a2b5fec0b374105"

SOURCE_URI_9="https://static.crates.io/crates/csv-index/csv-index-0.1.5.crate"
CHECKSUM_SHA256_9="7b27beef016f9d0d43fd1f6097a469d1ccccd2191888f5dfeb4e7be7dbc8bfc6"

SOURCE_URI_10="https://static.crates.io/crates/docopt/docopt-1.0.0.crate"
CHECKSUM_SHA256_10="e67fb750c36fc6fffbd3575cf8f2b46790fc0b05096ae3c03a36cf71b55e1e2b"

SOURCE_URI_11="https://static.crates.io/crates/filetime/filetime-0.1.15.crate"
CHECKSUM_SHA256_11="714653f3e34871534de23771ac7b26e999651a0a228f47beb324dfdf1dd4b10f"

SOURCE_URI_12="https://static.crates.io/crates/fuchsia-zircon/fuchsia-zircon-0.3.3.crate"
CHECKSUM_SHA256_12="2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"

SOURCE_URI_13="https://static.crates.io/crates/fuchsia-zircon-sys/fuchsia-zircon-sys-0.3.3.crate"
CHECKSUM_SHA256_13="3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"

SOURCE_URI_14="https://static.crates.io/crates/lazy_static/lazy_static-1.0.0.crate"
CHECKSUM_SHA256_14="c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d"

SOURCE_URI_15="https://static.crates.io/crates/libc/libc-0.2.40.crate"
CHECKSUM_SHA256_15="6fd41f331ac7c5b8ac259b8bf82c75c0fb2e469bbf37d2becbba9a6a2221965b"

SOURCE_URI_16="https://static.crates.io/crates/log/log-0.4.1.crate"
CHECKSUM_SHA256_16="89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2"

SOURCE_URI_17="https://static.crates.io/crates/memchr/memchr-2.0.1.crate"
CHECKSUM_SHA256_17="796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d"

SOURCE_URI_18="https://static.crates.io/crates/num-traits/num-traits-0.2.4.crate"
CHECKSUM_SHA256_18="775393e285254d2f5004596d69bb8bc1149754570dcc08cf30cabeba67955e28"

SOURCE_URI_19="https://static.crates.io/crates/num_cpus/num_cpus-1.8.0.crate"
CHECKSUM_SHA256_19="c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30"

SOURCE_URI_20="https://static.crates.io/crates/proc-macro2/proc-macro2-0.3.8.crate"
CHECKSUM_SHA256_20="1b06e2f335f48d24442b35a19df506a835fb3547bc3c06ef27340da9acf5cae7"

SOURCE_URI_21="https://static.crates.io/crates/quickcheck/quickcheck-0.6.2.crate"
CHECKSUM_SHA256_21="c01babc5ffd48a2a83744b3024814bb46dfd4f2a4705ccb44b1b60e644fdcab7"

SOURCE_URI_22="https://static.crates.io/crates/quote/quote-0.5.2.crate"
CHECKSUM_SHA256_22="9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8"

SOURCE_URI_23="https://static.crates.io/crates/rand/rand-0.3.22.crate"
CHECKSUM_SHA256_23="15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1"

SOURCE_URI_24="https://static.crates.io/crates/rand/rand-0.4.2.crate"
CHECKSUM_SHA256_24="eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5"

SOURCE_URI_25="https://static.crates.io/crates/redox_syscall/redox_syscall-0.1.37.crate"
CHECKSUM_SHA256_25="0d92eecebad22b767915e4d529f89f28ee96dbbf5a4810d2b844373f136417fd"

SOURCE_URI_26="https://static.crates.io/crates/regex/regex-1.0.0.crate"
CHECKSUM_SHA256_26="75ecf88252dce580404a22444fc7d626c01815debba56a7f4f536772a5ff19d3"

SOURCE_URI_27="https://static.crates.io/crates/regex-syntax/regex-syntax-0.6.0.crate"
CHECKSUM_SHA256_27="8f1ac0f60d675cc6cf13a20ec076568254472551051ad5dd050364d70671bf6b"

SOURCE_URI_28="https://static.crates.io/crates/serde/serde-1.0.54.crate"
CHECKSUM_SHA256_28="db9c1726bdebaed7ac8afb7028672e068e12cf1b0b97cddd742a3a7939159699"

SOURCE_URI_29="https://static.crates.io/crates/serde_derive/serde_derive-1.0.54.crate"
CHECKSUM_SHA256_29="5121751b76f5a2e6f51b4c0d07976f4f04e33ae7a981467c2845e7cd4b67a114"

SOURCE_URI_30="https://static.crates.io/crates/streaming-stats/streaming-stats-0.2.0.crate"
CHECKSUM_SHA256_30="4f233aa550ceeb22c47cff12e167f7bc89c03e265e7fcff64b8359bb6799e0f4"

SOURCE_URI_31="https://static.crates.io/crates/strsim/strsim-0.7.0.crate"
CHECKSUM_SHA256_31="bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"

SOURCE_URI_32="https://static.crates.io/crates/syn/syn-0.13.9.crate"
CHECKSUM_SHA256_32="505550dded6ff93eb63bd9d0ada380ffccd9f51c046a5e80a3078d53fcef0038"

SOURCE_URI_33="https://static.crates.io/crates/tabwriter/tabwriter-1.0.4.crate"
CHECKSUM_SHA256_33="56ab9ac71e2a71d113e4568ab0a89e2182f0fc214d2e4952c6e5655cb8eac4dd"

SOURCE_URI_34="https://static.crates.io/crates/thread_local/thread_local-0.3.5.crate"
CHECKSUM_SHA256_34="279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963"

SOURCE_URI_35="https://static.crates.io/crates/threadpool/threadpool-1.7.1.crate"
CHECKSUM_SHA256_35="e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865"

SOURCE_URI_36="https://static.crates.io/crates/ucd-util/ucd-util-0.1.1.crate"
CHECKSUM_SHA256_36="fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d"

SOURCE_URI_37="https://static.crates.io/crates/unicode-width/unicode-width-0.1.4.crate"
CHECKSUM_SHA256_37="bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f"

SOURCE_URI_38="https://static.crates.io/crates/unicode-xid/unicode-xid-0.1.0.crate"
CHECKSUM_SHA256_38="fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"

SOURCE_URI_39="https://static.crates.io/crates/unreachable/unreachable-1.0.0.crate"
CHECKSUM_SHA256_39="382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"

SOURCE_URI_40="https://static.crates.io/crates/utf8-ranges/utf8-ranges-1.0.0.crate"
CHECKSUM_SHA256_40="662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122"

SOURCE_URI_41="https://static.crates.io/crates/void/void-1.0.2.crate"
CHECKSUM_SHA256_41="6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"

SOURCE_URI_42="https://static.crates.io/crates/winapi/winapi-0.3.4.crate"
CHECKSUM_SHA256_42="04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3"

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

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

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

PROVIDES="
	xsv$secondaryArchSuffix = $portVersion
	cmd:xsv
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:cargo$secondaryArchSuffix
	cmd:gcc$secondaryArchSuffix
	"

defineDebugInfoPackage xsv$secondaryArchSuffix \
	$commandBinDir/xsv

BUILD()
{
	export CARGO_HOME=$sourceDir/../cargo
	CARGO_VENDOR=$CARGO_HOME/haiku
	mkdir -p $CARGO_VENDOR
	for i in {2..44}; do
		eval temp=\$sourceDir$i
		eval shasum=\$CHECKSUM_SHA256_$i
		pkg=$(basename $temp/*)
		cp -r $temp/$pkg $CARGO_VENDOR
		cat <<- EOF > $CARGO_VENDOR/$pkg/.cargo-checksum.json
		{
			"package": "$shasum",
			"files": {}
		}
		EOF
	done

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

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

	cargo build --release
}

INSTALL()
{
	install -D -m755 target/release/xsv $commandBinDir/xsv
	install -D -m644 -t $docDir README.md BENCHMARKS.md
}

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