From f09b33cdc37b999aad1dfb2054e3152571513d43 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Mon, 1 Jul 2019 08:39:40 +0200
Subject: [PATCH] codelite: update to 13.0.

- Initial musl support (see https://github.com/eranif/codelite/pull/2299)
- Added some new build options
- Tested on voidlinux/x86_64-musl
---
 srcpkgs/codelite/patches/92ed90e07.patch | 48 ++++++++++++++++++++
 srcpkgs/codelite/patches/musl.patch      | 56 ++++++++++++++++++++++++
 srcpkgs/codelite/template                | 23 +++++++---
 3 files changed, 120 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/codelite/patches/92ed90e07.patch
 create mode 100644 srcpkgs/codelite/patches/musl.patch

diff --git a/srcpkgs/codelite/patches/92ed90e07.patch b/srcpkgs/codelite/patches/92ed90e07.patch
new file mode 100644
index 00000000000..89fba88f14d
--- /dev/null
+++ b/srcpkgs/codelite/patches/92ed90e07.patch
@@ -0,0 +1,48 @@
+From 92ed90e07774dfc8556bee02c66120eed4938a40 Mon Sep 17 00:00:00 2001
+From: dghart <dghart david@4Pane.co.uk>
+Date: Wed, 19 Jun 2019 11:23:38 +0100
+Subject: [PATCH] Compilation fix for wx3.0 gtk+3 builds
+
+---
+ codelite_terminal/TextView.cpp | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git a/codelite_terminal/TextView.cpp b/codelite_terminal/TextView.cpp
+index 83d2e260c..5966f9972 100644
+--- codelite_terminal/TextView.cpp
++++ codelite_terminal/TextView.cpp
+@@ -12,7 +12,11 @@ TextView::TextView(wxWindow* parent, wxWindowID winid)
+     m_ctrl->SetCaretStyle(wxSTC_CARETSTYLE_BLOCK);
+     m_ctrl->SetYCaretPolicy(wxSTC_CARET_STRICT | wxSTC_CARET_SLOP, 4);
+     m_ctrl->SetLexer(wxSTC_LEX_CONTAINER);
++#if wxCHECK_VERSION(3, 1, 1)
+     m_ctrl->StartStyling(0);
++#else
++    m_ctrl->StartStyling(0, 0x1f);
++#endif
+     m_ctrl->SetWrapMode(wxSTC_WRAP_CHAR);
+ #else
+     m_ctrl = new TextCtrl_t(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize,
+@@ -61,7 +65,11 @@ void TextView::SetDefaultStyle(const wxTextAttr& attr)
+ {
+ #if USE_STC
+     m_defaultAttr = attr;
++#if wxCHECK_VERSION(3, 1, 1)
+     m_ctrl->StartStyling(m_ctrl->GetLastPosition());
++#else
++    m_ctrl->StartStyling(m_ctrl->GetLastPosition(), 0x1f);
++#endif
+ #else
+     m_ctrl->SetDefaultStyle(attr);
+ #endif
+@@ -210,6 +218,10 @@ void TextView::Clear()
+ #if USE_STC
+     m_ctrl->ClearAll();
+     m_ctrl->ClearDocumentStyle();
++#if wxCHECK_VERSION(3, 1, 1)
+     m_ctrl->StartStyling(0);
++#else
++    m_ctrl->StartStyling(0, 0x1f);
++#endif
+ #endif
+ }
diff --git a/srcpkgs/codelite/patches/musl.patch b/srcpkgs/codelite/patches/musl.patch
new file mode 100644
index 00000000000..8a345ed9753
--- /dev/null
+++ b/srcpkgs/codelite/patches/musl.patch
@@ -0,0 +1,56 @@
+--- codelitegcc/main.cpp.orig	2019-06-29 08:37:38.818622077 +0200
++++ codelitegcc/main.cpp	2019-06-29 08:38:04.090937646 +0200
+@@ -33,6 +33,7 @@ extern int ExecuteProcessWIN(const std::
+ #include <sys/file.h>
+ #include <sys/stat.h>
+ #include <sys/stat.h>
++#include <fcntl.h>
+ 
+ void WriteContent( const std::string& logfile, const std::string& filename, const std::string& flags )
+ {
+--- sdk/codelite_indexer/libctags/read.c.orig	2019-06-29 08:54:26.592208449 +0200
++++ sdk/codelite_indexer/libctags/read.c	2019-06-29 08:56:18.688608501 +0200
+@@ -605,6 +605,9 @@ extern int readChars (char *buffer, size
+ #if defined(__WXMSW__) || defined(__APPLE__) || defined(__FreeBSD__)
+ 	if(location < 0)
+ 		return 0;
++#elif defined(__linux__) && !defined(__GLIBC__) /* musl */
++	if(location.__lldata < 0)
++		return 0;
+ #else
+ 	if(location.__pos < 0)
+ 		return 0;
+@@ -619,6 +622,8 @@ extern int readChars (char *buffer, size
+ 
+ #if defined(__WXMSW__) || defined(__APPLE__) || defined(__FreeBSD__)
+ 	sizeToRead = endPos - location;
++#elif defined(__linux__) && !defined(__GLIBC__) /* musl */
++	sizeToRead = endPos.__lldata - location.__lldata;
+ #else
+ 	sizeToRead = endPos.__pos - location.__pos;
+ #endif
+--- sdk/codelite_indexer/network/named_pipe.cpp.orig	2019-06-29 09:06:20.260132366 +0200
++++ sdk/codelite_indexer/network/named_pipe.cpp	2019-06-29 09:06:38.468360112 +0200
+@@ -27,9 +27,9 @@
+ 
+ #ifndef __WXMSW__
+ #  include <sys/types.h>
+-#  include <sys/unistd.h>
+ #  include <sys/socket.h>
+ #  include <sys/time.h>
++#  include <unistd.h>
+ #endif
+ 
+ #ifdef __WXMSW__
+--- sdk/codelite_indexer/network/named_pipe_server.cpp.orig	2019-06-29 09:07:26.077955618 +0200
++++ sdk/codelite_indexer/network/named_pipe_server.cpp	2019-06-29 09:07:35.484073269 +0200
+@@ -26,8 +26,8 @@
+ #include "named_pipe_server.h"
+ #ifndef __WXMSW__
+ # include <sys/types.h>
+-# include <sys/unistd.h>
+ # include <sys/socket.h>
++# include <unistd.h>
+ #endif
+ clNamedPipeServer::clNamedPipeServer(const char* pipePath)
+ 		: clNamedPipe(pipePath)
diff --git a/srcpkgs/codelite/template b/srcpkgs/codelite/template
index 87458f193c4..14577dfadd2 100644
--- a/srcpkgs/codelite/template
+++ b/srcpkgs/codelite/template
@@ -1,20 +1,29 @@
 # Template file for 'codelite'
 pkgname=codelite
-version=12.0
-revision=9
+version=13.0
+revision=1
 build_style=cmake
-configure_args="-DENABLE_CLANG=1 -DENABLE_LLDB=1 -DWITH_MYSQL=1"
+configure_args="-DWITH_PCH=0
+ $(vopt_if sftp -DENABLE_SFTP=1)
+ $(vopt_if lldb -DENABLE_LLDB=1)"
 hostmakedepends="pkg-config clang"
-makedepends="wxWidgets-gtk3-devel libmariadbclient-devel sqlite-devel
- libssh-devel gtk+3-devel"
+makedepends="gtk+3-devel wxWidgets-gtk3-devel sqlite-devel
+ $(vopt_if lldb lldb-devel) $(vopt_if hunspell hunspell-devel)
+ $(vopt_if mysql libmariadbclient-devel) $(vopt_if sftp libssh-devel)"
 short_desc="Open-source, cross platform IDE for the C/C++ programming languages"
 maintainer="Andrea Brancaleoni <abc@pompel.me>"
 license="GPL-2.0-or-later"
 homepage="http://www.codelite.org"
 distfiles="https://github.com/eranif/${pkgname}/archive/${version}.tar.gz"
-checksum=e8912e3e0aea8890b5c65631ad94d58ddc587812c7ac6ec398e37aaa4b7005b4
+checksum=f2653fa42d6214999718236998cb223e6de00a498c0cfde795e901be693fb9ac
 
-archs="i686 x86_64 ppc64le"
+archs="aarch64* i686* x86_64* ppc64le*"
+build_options="hunspell lldb mysql sftp"
+build_options_default="hunspell lldb sftp"
+desc_option_hunspell="Enable SpellCheck plugin"
+desc_option_lldb="Enable support for LLDB"
+desc_option_mysql="Enable mysql/mariadb support"
+desc_option_sftp="Enable Workspace Mirroring plugin"
 
 pre_configure() {
 	sed -i -e 's,wx-config,&-gtk3,g' \
