From 85cc2acd6f39efe403df4b0cdb7101c1ce0fd064 Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Sun, 11 Feb 2024 04:00:10 +0300 Subject: [PATCH 1/3] Support Android logging. --- src/common/msgout.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/common/msgout.cpp b/src/common/msgout.cpp index 4eeefb0674..35c8dbd672 100644 --- a/src/common/msgout.cpp +++ b/src/common/msgout.cpp @@ -39,6 +39,10 @@ #include "wx/msw/private.h" #endif +#if defined(__ANDROID__) + #include +#endif + // =========================================================================== // implementation // =========================================================================== @@ -143,8 +147,13 @@ wxMessageOutputStderr::wxMessageOutputStderr(FILE *fp, const wxMBConv& conv) void wxMessageOutputStderr::Output(const wxString& str) { const wxCharBuffer& buf = PrepareForOutput(str); + +#if defined(__ANDROID__) + __android_log_write(ANDROID_LOG_INFO, "wxWidgets", buf.data()); +#else fwrite(buf, buf.length(), 1, m_fp); fflush(m_fp); +#endif } // ---------------------------------------------------------------------------- @@ -158,6 +167,10 @@ void wxMessageOutputDebug::Output(const wxString& str) out.Replace(wxT("\t"), wxT(" ")); out.Replace(wxT("\n"), wxT("\r\n")); ::OutputDebugString(out.t_str()); +#elif defined(__ANDROID__) + const wxCharBuffer& buf = PrepareForOutput(str); + + __android_log_write(ANDROID_LOG_DEBUG, "wxWidgets", buf.data()); #else // TODO: use native debug output function for the other ports too wxMessageOutputStderr::Output(str); From b4f435cbe86a626bfc623383ac5bb6c7f25a98db Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Sun, 11 Feb 2024 04:01:18 +0300 Subject: [PATCH 2/3] Fix linking errors related to android_wcsto* functions. --- include/wx/wxcrtbase.h | 6 +++--- src/common/wxcrt.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/wx/wxcrtbase.h b/include/wx/wxcrtbase.h index f3a204953b..00e539fe93 100644 --- a/include/wx/wxcrtbase.h +++ b/include/wx/wxcrtbase.h @@ -160,9 +160,9 @@ #ifdef __ANDROID__ // these functions are broken on android -extern double android_wcstod(const wchar_t *nptr, wchar_t **endptr); -extern long android_wcstol(const wchar_t *nptr, wchar_t **endptr, int base); -extern unsigned long android_wcstoul(const wchar_t *nptr, wchar_t **endptr, int base); +WXDLLIMPEXP_BASE double android_wcstod(const wchar_t *nptr, wchar_t **endptr); +WXDLLIMPEXP_BASE long android_wcstol(const wchar_t *nptr, wchar_t **endptr, int base); +WXDLLIMPEXP_BASE unsigned long android_wcstoul(const wchar_t *nptr, wchar_t **endptr, int base); #define wxCRT_StrtodW android_wcstod #define wxCRT_StrtolW android_wcstol diff --git a/src/common/wxcrt.cpp b/src/common/wxcrt.cpp index c0511899a6..0ac39ad494 100644 --- a/src/common/wxcrt.cpp +++ b/src/common/wxcrt.cpp @@ -1219,21 +1219,21 @@ int wxVsscanf(const wxCStrData& str, const wchar_t *format, va_list ap) } \ return d; -long android_wcstol(const wchar_t *nptr, wchar_t **endptr, int base) +WXDLLEXPORT long android_wcstol(const wchar_t *nptr, wchar_t **endptr, int base) { ANDROID_WCSTO_START long d = strtol(dst, &dstendp, base); ANDROID_WCSTO_END } -unsigned long android_wcstoul(const wchar_t *nptr, wchar_t **endptr, int base) +WXDLLEXPORT unsigned long android_wcstoul(const wchar_t *nptr, wchar_t **endptr, int base) { ANDROID_WCSTO_START unsigned long d = strtoul(dst, &dstendp, base); ANDROID_WCSTO_END } -double android_wcstod(const wchar_t *nptr, wchar_t **endptr) +WXDLLEXPORT double android_wcstod(const wchar_t *nptr, wchar_t **endptr) { ANDROID_WCSTO_START double d = strtod(dst, &dstendp); From 60c3ec9298e7f15679f240bc47ef73026908b84b Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Sun, 11 Feb 2024 20:13:55 +0300 Subject: [PATCH 3/3] CMake: remove Android ABI shared library suffix for Qt. --- build/cmake/toolkit.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build/cmake/toolkit.cmake b/build/cmake/toolkit.cmake index 49a21c1fc8..f3ca9a1d1d 100644 --- a/build/cmake/toolkit.cmake +++ b/build/cmake/toolkit.cmake @@ -134,6 +134,13 @@ if(WXQT) list(APPEND wxTOOLKIT_DEFINITIONS ${Qt5${QT_COMPONENT}_COMPILE_DEFINITIONS}) endforeach() set(wxTOOLKIT_VERSION ${Qt5Core_VERSION}) + + if(ANDROID) + # A hack to remove _${ANDROID_ABI} that Qt5AndroidSupport.cmake added + # which breaks wx-config. + set(CMAKE_SHARED_LIBRARY_SUFFIX_C ${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(CMAKE_SHARED_LIBRARY_SUFFIX_CXX ${CMAKE_SHARED_LIBRARY_SUFFIX}) + endif() endif() if(APPLE)