SUMMARY="A fast JSON parser/generator for C++ with both SAX/DOM style API"
DESCRIPTION="RapidJSON is a JSON parser and generator for C++. It was \
inspired by RapidXml.

RapidJSON is small but complete. It supports both SAX and DOM style API. The \
SAX parser is only a half thousand lines of code.

RapidJSON is fast. Its performance can be comparable to strlen(). It also \
optionally supports SSE2/SSE4.2 for acceleration.

RapidJSON is self-contained and header-only. It does not depend on external \
libraries such as BOOST. It even does not depend on STL.

RapidJSON is memory-friendly. Each JSON value occupies exactly 16 bytes for \
most 32/64-bit machines (excluding text string). By default it uses a fast \
memory allocator, and the parser allocates memory compactly during parsing.

RapidJSON is Unicode-friendly. It supports UTF-8, UTF-16, UTF-32 (LE & BE), \
and their detection, validation and transcoding internally. For example, you \
can read a UTF-8 file and let RapidJSON transcode the JSON strings into \
UTF-16 in the DOM. It also supports surrogates and \"\u0000\" \
(null character)."
HOMEPAGE="https://github.com/Tencent/rapidjson"
COPYRIGHT="2015 THL A29 Limited, a Tencent company, and Milo Yip"
LICENSE="MIT"
REVISION="2"
SOURCE_URI="https://github.com/Tencent/rapidjson/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="bf7ced29704a1e696fbccf2a2b4ea068e7774fa37f6d7dd4039d0787f8bed98e"
SOURCE_FILENAME="rapidjson-$portVersion.tar.gz"
PATCHES="rapidjson-$portVersion.patchset"

ARCHITECTURES="all ?x86_gcc2 ?x86"
SECONDARY_ARCHITECTURES="x86"

libVersion="$portVersion"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	rapidjson$secondaryArchSuffix = $portVersion
	devel:librapidjson$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	mkdir -p haiku_build
	cd haiku_build

	cmake .. \
		-DBUILD_SHARED_LIBS=ON \
		-DRAPIDJSON_BUILD_DOC=ON \
		-DRAPIDJSON_BUILD_EXAMPLES=OFF \
		-DRAPIDJSON_BUILD_TESTS=ON \
		-DRAPIDJSON_BUILD_THIRDPARTY_GTEST=OFF \
		-DINCLUDE_INSTALL_DIR=$includeDir \
		-DLIB_INSTALL_DIR=$libDir \
		-DDOC_INSTALL_DIR=$docDir \
		$cmakeDirArgs

	make $jobArgs
}

INSTALL()
{
	cd haiku_build
	make install

	fixPkgconfig
}

TEST()
{
	cd haiku_build
	make test
}
