Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: target platform
Browse files Browse the repository at this point in the history
askmeaboutlo0m committed Sep 1, 2024

Verified

This commit was signed with the committer’s verified signature.
1 parent b623143 commit 50565b6
Showing 7 changed files with 109 additions and 252 deletions.
5 changes: 4 additions & 1 deletion .github/scripts/build-qt.cmake
Original file line number Diff line number Diff line change
@@ -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()
@@ -275,6 +277,7 @@ if(BASE)
patches/webgl_is_hard.diff
patches/fusioncontrast-qt6.diff
patches/macostabs-qt6.diff
patches/qtbug-127468.diff
)
endif()

41 changes: 22 additions & 19 deletions .github/scripts/cmake/BuildDependency.cmake
Original file line number Diff line number Diff line change
@@ -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)

@@ -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)
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; \
248 changes: 21 additions & 227 deletions .github/workflows/main.yml

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -140,6 +140,11 @@ if(CLIENT OR SERVER)
# Finding Qt needs to come first, otherwise automoc gets confused about
# being unable to generate a MOC for the cmake-config directory below.
find_package(${QT_PACKAGE_NAME} REQUIRED COMPONENTS Core Network)
# This alters how some Android properties are handled in ways that don't
# matter to us, so we just set this policy so that we don't get a warning.
if(ANDROID AND QT_VERSION VERSION_GREATER_EQUAL 6.6.0)
qt_policy(SET QTP0002 NEW)
endif()
endif()

# This must be included *after* drawdance is added to make sure that we do not
4 changes: 2 additions & 2 deletions cmake/Qt5AndroidDeploymentTarget.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#[[ This module sets the variables required to generate a Qt5 Android build. #]]

# The defaults in Qt5 are outdated, so make them match the current NDK
set(ANDROID_MIN_SDK_VERSION ${NDK_MIN_PLATFORM_LEVEL})
set(ANDROID_TARGET_SDK_VERSION ${NDK_MAX_PLATFORM_LEVEL})
set(ANDROID_MIN_SDK_VERSION ${NDK_MIN_PLATFORM_LEVEL} CACHE STRING "Android minimum SDK version" FORCE)
set(ANDROID_TARGET_SDK_VERSION ${NDK_MAX_PLATFORM_LEVEL} CACHE STRING "Android target SDK version" FORCE)

# If ANDROID_SDK is not defined Qt will default it to being one level up from
# NDK, but actually it is two levels up by default due to versioning and this
5 changes: 2 additions & 3 deletions src/desktop/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -720,9 +720,8 @@ elseif(ANDROID)
)
set(ANDROID_QT_NAMESPACE org.qtproject.qt)
file(READ AndroidManifest.xml.qt6 ANDROID_EXTRA_METADATA)
qt_android_generate_deployment_settings(drawpile)
qt_android_add_apk_target(drawpile)
add_custom_command(TARGET drawpile_make_apk POST_BUILD
cmake_language(DEFER CALL add_custom_command
TARGET drawpile_make_apk POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"android-build/drawpile.apk"
"${output_apk}"

0 comments on commit 50565b6

Please sign in to comment.