SUMMARY="Code-completion engine for Vim"
DESCRIPTION="YouCompleteMe is a fast, as-you-type, fuzzy-search code \
completion engine for Vim. It has several completion engines:
* an identifier-based engine that works with every programming language,
* a Clang-based engine that provides native semantic code completion for \
C/C++/Objective-C/Objective-C++ (from now on referred to as \"the C-family \
languages\"),
* a Jedi-based completion engine for Python 2 and 3 (using the JediHTTP wrapper),
* an OmniSharp-based completion engine for C#,
* a combination of Gocode and Godef semantic engines for Go,
* a TSServer-based completion engine for TypeScript,
* a Tern-based completion engine for JavaScript,
* a racer-based completion engine for Rust,
* a jdt.ls-based experimental completion engine for Java.
* and an omnifunc-based completer that uses data from Vim's omnicomplete \
system to provide semantic completions for many other languages (Ruby, PHP \
etc.)."
HOMEPAGE="http://ycm-core.github.io/YouCompleteMe/"
COPYRIGHT="2015-2019 YouCompleteMe contributors"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://github.com/ycm-core/YouCompleteMe/archive/fa92f40d0209469a037196fdc3d949ae29d0c30a.zip"
SOURCE_DIR="YouCompleteMe-fa92f40d0209469a037196fdc3d949ae29d0c30a"
CHECKSUM_SHA256="498982a0129fe8f506d2700e6427695b5b73f7e18ad0ba372d56d4bb673352b0"
PATCHES="youcompleteme-20180809.patchset"
SOURCE_URI_2="https://github.com/ycm-core/ycmd/archive/be84d443f2afd4eff72b3eb420656de6155eca20.zip"
SOURCE_DIR_2="ycmd-be84d443f2afd4eff72b3eb420656de6155eca20"
CHECKSUM_SHA256_2="38e096934868eb8e834fabb57ccf89c39ecb00acd95fee03aa885fc9be15b99e"

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

PROVIDES="
	youcompleteme$secondaryArchSuffix = $portVersion
	"

# Yes, this needs both python (for vim embedded parts) and python3 (for the
# ycmd server) packages.
REQUIRES="
	haiku$secondaryArchSuffix
	cmd:vim >= 8.1
	bottle_python3
	certifi_python
	certifi_python3
	frozendict_python
	frozendict_python3
	future_python
	future_python3
	futures_python
	requests_futures_python
	requests_python
	requests_python3
	waitress_python3
	lib:libclang$secondaryArchSuffix >= 7
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libboost_filesystem$secondaryArchSuffix
	devel:libboost_regex$secondaryArchSuffix
	devel:libboost_system$secondaryArchSuffix
	devel:libclang$secondaryArchSuffix >= 7
	devel:libpython3.6m$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ninja
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	mkdir -p ycm_build
	mkdir -p $developLibDir
	cd ycm_build

	rm -rf ../third_party/ycmd
	ln -s ../../../sources-2/ycmd-* ../third_party/ycmd

	cmake -GNinja $cmakeDirArgs ../third_party/ycmd/cpp -DUSE_SYSTEM_BOOST=ON \
		-DUSE_SYSTEM_LIBCLANG=ON \
		-DPYTHON_INCLUDE_DIR=/system/develop/headers/python3.6m \
		-DUSE_PYTHON2=OFF
	ninja $jobArgs ycm_core
}

INSTALL()
{
	mkdir -p $dataDir/vim/vim81
	cp -r autoload doc python plugin $dataDir/vim/vim81

	mkdir -p $dataDir/vim/vim81/third_party/ycmd
	cp -r third_party/ycmd/ycm_core.so $dataDir/vim/vim81/third_party/ycmd
	cp -r third_party/ycmd/ycmd $dataDir/vim/vim81/third_party/ycmd/ycmd
	cp third_party/ycmd/CORE_VERSION $dataDir/vim/vim81/third_party/ycmd/
}
