SUMMARY="A complete IDE for C/C++ development from the makers of Qt"
DESCRIPTION="Qt Creator provides a cross-platform, complete integrated \
development environment (IDE) for application developers to create \
applications for multiple desktop, embedded, and mobile device platforms, \
such as Android and iOS."
HOMEPAGE="https://www.qt.io/ide/"
COPYRIGHT="2021 The Qt Company Ltd"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://download.qt.io/official_releases/qtcreator/${portVersion%.*}/$portVersion/qt-creator-opensource-src-$portVersion.tar.xz"
CHECKSUM_SHA256="94ccca750150c731956ad368f69714ed5fd4c3b4cd35e5340df37920bded6f3b"
SOURCE_DIR="qt-creator-opensource-src-$portVersion"
PATCHES="qt_creator-$portVersion.patchset"
ADDITIONAL_FILES="qt_creator.rdef.in"

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

PROVIDES="
	qt_creator$secondaryArchSuffix = $portVersion
	app:QtCreator$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libclang$secondaryArchSuffix
	lib:libclang_cpp$secondaryArchSuffix
	lib:libexecinfo$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libLLVM_9$secondaryArchSuffix
	lib:libQt6Concurrent$secondaryArchSuffix
	lib:libQt6Core$secondaryArchSuffix
	lib:libQt6Core5Compat$secondaryArchSuffix
	lib:libQt6Designer$secondaryArchSuffix
	lib:libQt6DesignerComponents$secondaryArchSuffix
	lib:libQt6Gui$secondaryArchSuffix
	lib:libQt6Help$secondaryArchSuffix
	lib:libQt6Network$secondaryArchSuffix
	lib:libQt6PrintSupport$secondaryArchSuffix
	lib:libQt6Qml$secondaryArchSuffix
	lib:libQt6Quick$secondaryArchSuffix
	lib:libQt6QuickWidgets$secondaryArchSuffix
	lib:libQt6Sql$secondaryArchSuffix
	lib:libQt6Svg$secondaryArchSuffix
	lib:libQt6Widgets$secondaryArchSuffix
	lib:libQt6Xml$secondaryArchSuffix
	lib:libsqlite3$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	qt6_tools${secondaryArchSuffix}_devel
	devel:libclang$secondaryArchSuffix >= 9
	devel:libclang_cpp$secondaryArchSuffix >= 9
	devel:libexecinfo$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libLLVM_9$secondaryArchSuffix
	devel:libQt6Concurrent$secondaryArchSuffix
	devel:libQt6Core$secondaryArchSuffix
	devel:libQt6Core5Compat$secondaryArchSuffix
	devel:libQt6Designer$secondaryArchSuffix
	devel:libQt6DesignerComponents$secondaryArchSuffix
	devel:libQt6Gui$secondaryArchSuffix
	devel:libQt6Help$secondaryArchSuffix
	devel:libQt6Network$secondaryArchSuffix
	devel:libQt6PrintSupport$secondaryArchSuffix
	devel:libQt6Qml$secondaryArchSuffix
	devel:libQt6Quick$secondaryArchSuffix
	devel:libQt6QuickWidgets$secondaryArchSuffix
	devel:libQt6Sql$secondaryArchSuffix
	devel:libQt6Svg$secondaryArchSuffix
	devel:libQt6Widgets$secondaryArchSuffix
	devel:libQt6Xml$secondaryArchSuffix
	devel:libsqlite3$secondaryArchSuffix

	"
BUILD_PREREQUIRES="
	cmd:g++$secondaryArchSuffix
	cmd:make
	cmd:qdoc6$secondaryArchSuffix
	cmd:qmake6$secondaryArchSuffix
	cmd:perl
	cmd:pkg_config$secondaryArchSuffix
	cmd:python2
	cmd:which
	"

BUILD()
{
	qmake6
	make $jobArgs
}

INSTALL()
{
	make install INSTALL_ROOT=$appsDir/QtCreator

	# Qt port doesn't support createPlatformOpenGLContext yet
	rm -rf $appsDir/QtCreator/lib/qtcreator/plugins/libQmlDesigner.so
	rm -rf $appsDir/QtCreator/lib/qtcreator/plugins/libQmlProfiler.so
	# Create symlink to libclang
	ln -s /system/$relativeDevelopLibDir/libclang.so.9 $appsDir/QtCreator/lib/qtcreator/
	ln -s /system/$relativeDevelopLibDir/libclang.so.9 $appsDir/QtCreator/libexec/qtcreator/

	local APP_SIGNATURE="application/x-vnd.qt6-qtcreator"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/qt_creator.rdef.in > qt_creator.rdef

	addResourcesToBinaries qt_creator.rdef $appsDir/QtCreator/bin/qtcreator

	mv $appsDir/QtCreator/bin/qtcreator "$appsDir/QtCreator/bin/Qt Creator"

	mkdir -p $dataDir/deskbar/menu/Applications/Qt
	addAppDeskbarSymlink "$appsDir/QtCreator/bin/Qt Creator" "Qt/Qt Creator"
}
