# Template file for 'cudatext-gtk'
pkgname=cudatext-gtk
version=1.115.0
revision=1
# Dependency package versions.
# Note to updaters: Please update these to latest releases when $version was released and test accordingly.
_version_bgrabitmap=11.2.3
_version_EncConv=2020.06.15
_version_ATBinHex_Lazarus=2020.09.05
_version_ATFlatControls=2020.09.20
_version_ATSynEdit=2020.10.12
_version_ATSynEdit_Cmp=2020.10.11
_version_EControl=2020.10.04
_version_ATSynEdit_Ex=2020.10.04
_version_Python_for_Lazarus=2020.07.31
_version_Emmet_Pascal=2020.09.05
archs="x86_64 i686"
wrksrc="CudaText-${version}"
build_style=meta
hostmakedepends="lazarus make binutils gdb subversion zip unzip unrar"
makedepends="gtk+-devel libX11-devel gdk-pixbuf-devel cairo-devel pango-devel"
depends="python3"
short_desc="Cross-platform, multi-caret, infinitely customizable text editor"
maintainer="reback00 <reback00@protonmail.com>"
license="MPL-2.0"
homepage="http://uvviewsoft.com/cudatext"
distfiles="https://github.com/Alexey-T/CudaText/archive/${version}.tar.gz
 https://github.com/bgrabitmap/bgrabitmap/archive/v${_version_bgrabitmap}.tar.gz>bgrabitmap.tar.gz
 https://github.com/Alexey-T/EncConv/archive/${_version_EncConv}.tar.gz>EncConv.tar.gz
 https://github.com/Alexey-T/ATBinHex-Lazarus/archive/${_version_ATBinHex_Lazarus}.tar.gz>ATBinHex-Lazarus.tar.gz
 https://github.com/Alexey-T/ATFlatControls/archive/${_version_ATFlatControls}.tar.gz>ATFlatControls.tar.gz
 https://github.com/Alexey-T/ATSynEdit/archive/${_version_ATSynEdit}.tar.gz>ATSynEdit.tar.gz
 https://github.com/Alexey-T/ATSynEdit_Cmp/archive/${_version_ATSynEdit_Cmp}.tar.gz>ATSynEdit_Cmp.tar.gz
 https://github.com/Alexey-T/EControl/archive/${_version_EControl}.tar.gz>EControl.tar.gz
 https://github.com/Alexey-T/ATSynEdit_Ex/archive/${_version_ATSynEdit_Ex}.tar.gz>ATSynEdit_Ex.tar.gz
 https://github.com/Alexey-T/Python-for-Lazarus/archive/${_version_Python_for_Lazarus}.tar.gz>Python-for-Lazarus.tar.gz
 https://github.com/Alexey-T/Emmet-Pascal/archive/${_version_Emmet_Pascal}.tar.gz>Emmet-Pascal.tar.gz"
checksum="ffd79784ae27e52f112fcfa73f542ffea15a03e2c331855720cc7e3f5ccfff44
 a87c462202f2bd4bb6b7c2a24be7960c0b539675cea7773dca7c8808ed29fe79
 203f0c1c7e648d05c176cd022c3fe953361e7135ba158a6999be057f34e54403
 f41189a54ce50012c2c39a79b24f4706317a6c894972437c6c6b85095af2bc77
 2b5c3a8fc25623e0c3474c6d953b45fbca324b7dca992f24807ff43c51cd105e
 93d567a8ea9d1a4da94bedd62466a096c608c7091895489045dec26a2003798c
 a717ab19bfff842ffd9cef194dcc145b597ebfbe2acd267daebb4ce68fed71ea
 12035dee5c0bb8c8e546a8a5a17469852509e7e4df7d4d85439b53bdb8e5e41e
 24f6b9202ac21eaaf7c55ca373a400d61829ca866efb6984254b5e771a9c46f3
 53ad6b7b4b231bc93b4b36c0a351b139bc67a11e508878f22600bd9a4db98309
 cba0d68fee260a5f7aff51933014fe53ea3eb71f6d8349ff660b8b2a04028eaf"
nopie=yes
python_version=3

# Dependency packages to install. Order of some of these packages are important.
_packages="${XBPS_BUILDDIR}/Python-for-Lazarus-${_version_Python_for_Lazarus}/python4lazarus/python4lazarus_package.lpk
${XBPS_BUILDDIR}/bgrabitmap-${_version_bgrabitmap}/bgrabitmap/bgrabitmappack.lpk
${XBPS_BUILDDIR}/EncConv-${_version_EncConv}/encconv/encconv_package.lpk
${XBPS_BUILDDIR}/ATBinHex-Lazarus-${_version_ATBinHex_Lazarus}/atbinhex/atbinhex_package.lpk
${XBPS_BUILDDIR}/ATFlatControls-${_version_ATFlatControls}/atflatcontrols/atflatcontrols_package.lpk
${XBPS_BUILDDIR}/ATSynEdit-${_version_ATSynEdit}/atsynedit/atsynedit_package.lpk
${XBPS_BUILDDIR}/EControl-${_version_EControl}/econtrol/econtrol_package.lpk
${XBPS_BUILDDIR}/ATSynEdit_Ex-${_version_ATSynEdit_Ex}/atsynedit_ex/atsynedit_ex_package.lpk
${XBPS_BUILDDIR}/ATSynEdit_Cmp-${_version_ATSynEdit_Cmp}/atsynedit_cmp/atsynedit_cmp_package.lpk
${XBPS_BUILDDIR}/Emmet-Pascal-${_version_Emmet_Pascal}/emmet/emmet_package.lpk"

_lazbuild_options="-q --lazarusdir=/usr/lib/lazarus"

pre_build() {
	echo "$_packages" | while read package ; do
		# Compile package
		lazbuild $_lazbuild_options "$package"
		# Add package
		lazbuild $_lazbuild_options --add-package="$package"
	done

	# Build Lazarus IDE with the packages added
	lazbuild $_lazbuild_options --build-ide=
}

do_build() {
	lazbuild $_lazbuild_options app/cudatext.lpi
}

do_install() {
	vbin app/cudatext

	vinstall setup/debfiles/cudatext.desktop 644 usr/share/applications
	vinstall setup/debfiles/cudatext-512.png 644 usr/share/pixmaps

	vmkdir usr/share/cudatext
	vcopy app/data usr/share/cudatext
	vcopy app/py usr/share/cudatext
	vcopy app/settings_default usr/share/cudatext
}
