Skip to content

Commit

Permalink
WIP: target platform
Browse files Browse the repository at this point in the history
  • Loading branch information
askmeaboutlo0m committed Sep 1, 2024
1 parent b623143 commit 8bb8ac0
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 252 deletions.
6 changes: 5 additions & 1 deletion .github/scripts/build-qt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,11 @@ if(EMSCRIPTEN)
set(BASE_RELEASE_FLAGS -feature-optimize_full)
else()
set(BASE_DEBUG_INFO_FLAGS -separate-debug-info)
# Qt6 has various issues with link-time optimization. On Linux, rcc fails to
# build with a weird error about not finding qt_version_tag.
# https://bugreports.qt.io/browse/QTBUG-72846 regressed in Qt6 due to
# https://gitlab.kitware.com/cmake/cmake/-/issues/23864
if(NOT APPLE OR QT_VERSION VERSION_LESS 6)
if(QT_VERSION VERSION_LESS 6)
list(APPEND BASE_FLAGS -ltcg)
endif()
endif()
Expand Down Expand Up @@ -275,6 +277,8 @@ if(BASE)
patches/webgl_is_hard.diff
patches/fusioncontrast-qt6.diff
patches/macostabs-qt6.diff
patches/qtbug-127468.diff
patches/qt6androidmacros_build_tools_revision.diff
)
endif()

Expand Down
41 changes: 22 additions & 19 deletions .github/scripts/cmake/BuildDependency.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ foreach(path IN LISTS CMAKE_PREFIX_PATH)
list(APPEND NEW_CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}/${path}")
endif()
endforeach()
if(NOT NEW_CMAKE_PREFIX_PATH)
set(NEW_CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}")
endif()
set(CMAKE_PREFIX_PATH ${NEW_CMAKE_PREFIX_PATH})
unset(NEW_CMAKE_PREFIX_PATH)

Expand Down Expand Up @@ -315,27 +318,27 @@ function(_build_cmake build_type target_bits source_dir)
"-DCMAKE_OBJCXX_FLAGS_INIT=-fno-omit-frame-pointer -fsanitize=address"
)
endif()
endif()

if(CMAKE_TOOLCHAIN_FILE)
list(APPEND default_flags
"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
"-DANDROID_ABI=${ANDROID_ABI}"
"-DANDROID_PLATFORM=${ANDROID_PLATFORM}"
"-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=on"
)
elseif(CMAKE_ANDROID_NDK)
list(APPEND default_flags
"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_ANDROID_NDK}/build/cmake/android.toolchain.cmake"
"-DCMAKE_ANDROID_NDK=${CMAKE_ANDROID_NDK}"
"-DCMAKE_ANDROID_ARCH_ABI=${CMAKE_ANDROID_ARCH_ABI}"
"-DANDROID_PLATFORM=${ANDROID_PLATFORM}"
"-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=on"
)
endif()
if(CMAKE_TOOLCHAIN_FILE)
list(APPEND default_flags
"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
"-DANDROID_ABI=${ANDROID_ABI}"
"-DANDROID_PLATFORM=${ANDROID_PLATFORM}"
"-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=on"
)
elseif(CMAKE_ANDROID_NDK)
list(APPEND default_flags
"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_ANDROID_NDK}/build/cmake/android.toolchain.cmake"
"-DCMAKE_ANDROID_NDK=${CMAKE_ANDROID_NDK}"
"-DCMAKE_ANDROID_ARCH_ABI=${CMAKE_ANDROID_ARCH_ABI}"
"-DANDROID_PLATFORM=${ANDROID_PLATFORM}"
"-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=on"
)
endif()

if(ANDROID_SDK_ROOT)
list(APPEND default_flags "-DANDROID_SDK=${ANDROID_SDK_ROOT}")
if(ANDROID_SDK_ROOT)
list(APPEND default_flags "-DANDROID_SDK=${ANDROID_SDK_ROOT}")
endif()
endif()

if(CMAKE_ARG_NO_DEFAULT_FLAGS OR CMAKE_ARG_NO_DEFAULT_BUILD_TYPE)
Expand Down
30 changes: 30 additions & 0 deletions .github/scripts/patches/qt6androidmacros_build_tools_revision.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Description: Qt6 tries to allow setting the build tools revision via
QT_ANDROID_SDK_BUILD_TOOLS_REVISION, but fails to actually return it from this
function that's supposed to determine the version to use. This leads to it
generating an invalid gradle.properties file with a blank entry for the build
tools version. This patch fixes that function to actually return the version
properly.

--- a/src/corelib/Qt6AndroidMacros.cmake
+++ b/src/corelib/Qt6AndroidMacros.cmake
@@ -5,7 +5,9 @@

# Locate newest Android sdk build tools revision
function(_qt_internal_android_get_sdk_build_tools_revision out_var)
- if (NOT QT_ANDROID_SDK_BUILD_TOOLS_REVISION)
+ if (QT_ANDROID_SDK_BUILD_TOOLS_REVISION)
+ set(${out_var} "${QT_ANDROID_SDK_BUILD_TOOLS_REVISION}")
+ else()
file(GLOB android_build_tools
LIST_DIRECTORIES true
RELATIVE "${ANDROID_SDK_ROOT}/build-tools"
@@ -17,8 +19,8 @@
list(SORT android_build_tools)
list(REVERSE android_build_tools)
list(GET android_build_tools 0 android_build_tools_latest)
+ set(${out_var} "${android_build_tools_latest}" PARENT_SCOPE)
endif()
- set(${out_var} "${android_build_tools_latest}" PARENT_SCOPE)
endfunction()

# The function appends to the 'out_var' a 'json_property' that contains the 'tool' path. If 'tool'
53 changes: 53 additions & 0 deletions .github/scripts/patches/qtbug-127468.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
From 27321bb7fae0f82cf069cea74438278d4706feb7 Mon Sep 17 00:00:00 2001
From: Ville Voutilainen <[email protected]>
Date: Sun, 18 Aug 2024 01:59:29 +0300
Subject: [PATCH] Fix an evaluated use of std::declval in qjnitypes.h

While other compilers don't seem to have trouble with this, the latest
NDK (27) compiler does. That compiler diagnoses the empty-pack case, even though in that case there is no actual use of declval, as the pack-expanded expression contains no use of declval.
For other compilers, that may work for functions that have no arguments, but will not work for any function that does have arguments; in that case, the attempt to use declval will always be ill-formed, and there will be an attempt to use declval.

The fix is straightforward; we have a Ret(*)(Args...), its return type
is simply Ret. So use a simple trait instead of the result of a call.

Task-number: QTBUG-127468
Change-Id: I0dc9e1201914ab94acc2940870be7c6d8cb16c12
Reviewed-by: Thiago Macieira <[email protected]>
(cherry picked from commit 236c6ec6f4c777d0534539f1c293cfc74006a6eb)
Reviewed-by: Qt Cherry-pick Bot <[email protected]>
(cherry picked from commit 1079d210d19cc05275228a17c318e5bdbcdeff6c)
---

diff --git a/src/corelib/kernel/qjnitypes.h b/src/corelib/kernel/qjnitypes.h
index 4317f75..5e07547 100644
--- a/src/corelib/kernel/qjnitypes.h
+++ b/src/corelib/kernel/qjnitypes.h
@@ -123,12 +123,14 @@
return makeTupleFromArgsHelper<Args...>(args);
}

-// Get the return type of a function point
-template <typename Ret, typename ...Args>
-auto nativeFunctionReturnType(Ret(*function)(Args...))
+template <typename>
+struct NativeFunctionReturnType {};
+
+template<typename Ret, typename... Args>
+struct NativeFunctionReturnType<Ret(Args...)>
{
- return function(std::declval<Args>()...);
-}
+ using type = Ret;
+};

} // namespace Detail
} // namespace QtJniMethods
@@ -139,7 +141,7 @@
// the actual function with. This then takes care of implicit conversions,
// e.g. a jobject becomes a QJniObject.
#define Q_DECLARE_JNI_NATIVE_METHOD_HELPER(Method) \
-static decltype(QtJniMethods::Detail::nativeFunctionReturnType(Method)) \
+static QtJniMethods::Detail::NativeFunctionReturnType<decltype(Method)>::type \
va_##Method(JNIEnv *env, jclass thiz, ...) \
{ \
va_list args; \
Loading

0 comments on commit 8bb8ac0

Please sign in to comment.