CMake: build add flags for building QtAndroid.jar
Adds -source, -target, -Xlint:unchecked, -bootclasspath flags. Setting default javac build source and target versions to 8. Allow setting custom values for javac build versions via -DQT_ANDROID_JAVAC_SOURCE, and -DQT_ANDROID_JAVAC_TARGET. Task-number: QTBUG-86282 Change-Id: I98f4f193ac96016dc722d178594d7fd401202f68 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
581ac9a4ad
commit
b9c85d6b0e
@ -465,6 +465,7 @@ qt_copy_or_install(FILES
|
||||
cmake/QtTargetHelpers.cmake
|
||||
cmake/QtTestHelpers.cmake
|
||||
cmake/QtToolHelpers.cmake
|
||||
cmake/QtJavaHelpers.cmake
|
||||
DESTINATION "${__GlobalConfig_install_dir}"
|
||||
)
|
||||
|
||||
|
@ -477,6 +477,7 @@ include(QtTargetHelpers)
|
||||
include(QtTestHelpers)
|
||||
include(QtToolHelpers)
|
||||
include(QtHeadersClean)
|
||||
include(QtJavaHelpers)
|
||||
|
||||
# This sets up the scope finalizer mechanism.
|
||||
variable_watch(CMAKE_CURRENT_LIST_DIR qt_watch_current_list_dir)
|
||||
|
18
cmake/QtJavaHelpers.cmake
Normal file
18
cmake/QtJavaHelpers.cmake
Normal file
@ -0,0 +1,18 @@
|
||||
# This function can be used to compile java sources into a jar package.
|
||||
|
||||
function(qt_internal_add_jar target)
|
||||
|
||||
set(javac_target_version "${QT_ANDROID_JAVAC_TARGET}")
|
||||
if (NOT javac_target_version)
|
||||
set(javac_target_version "8")
|
||||
endif()
|
||||
|
||||
set(javac_source_version "${QT_ANDROID_JAVAC_SOURCE}")
|
||||
if (NOT javac_source_version)
|
||||
set(javac_source_version "8")
|
||||
endif()
|
||||
|
||||
set(CMAKE_JAVA_COMPILE_FLAGS -source "${javac_source_version}" -target "${javac_target_version}" -Xlint:unchecked -bootclasspath "${QT_ANDROID_JAR}")
|
||||
add_jar(${ARGV})
|
||||
|
||||
endfunction()
|
@ -556,6 +556,8 @@ endif()
|
||||
translate_string_input(platform QT_QMAKE_TARGET_MKSPEC)
|
||||
translate_string_input(xplatform QT_QMAKE_TARGET_MKSPEC)
|
||||
translate_string_input(qpa_default_platform QT_QPA_DEFAULT_PLATFORM)
|
||||
translate_string_input(android-javac-source QT_ANDROID_JAVAC_SOURCE)
|
||||
translate_string_input(android-javac-target QT_ANDROID_JAVAC_TARGET)
|
||||
|
||||
drop_input(make)
|
||||
drop_input(nomake)
|
||||
|
@ -96,6 +96,8 @@ The effort of this is tracked in QTBUG-85373 and QTBUG-85349.
|
||||
| -android-ndk-host | | |
|
||||
| -android-abis | | |
|
||||
| -android-style-assets | | |
|
||||
| -android-javac-source | -DQT_ANDROID_JAVAC_SOURCE=7 | Set the javac build source version. |
|
||||
| -android-javac-target | -DQT_ANDROID_JAVAC_TARGET=7 | Set the javac build target version. |
|
||||
| -skip <repo> | -DBUILD_<repo>=OFF | |
|
||||
| -make <part> | -DBUILD_TESTING=ON | A way to turn on tools explicitly is missing. |
|
||||
| | -DBUILD_EXAMPLES=ON | |
|
||||
|
@ -36,6 +36,8 @@ qt_commandline_option(android-ndk-host TYPE string)
|
||||
qt_commandline_option(android-ndk-platform TYPE string)
|
||||
qt_commandline_option(android-sdk TYPE string)
|
||||
qt_commandline_option(android-style-assets TYPE boolean)
|
||||
qt_commandline_option(android-javac-target TYPE string)
|
||||
qt_commandline_option(android-javac-source TYPE string)
|
||||
qt_commandline_option(appstore-compliant TYPE boolean)
|
||||
qt_commandline_option(avx TYPE boolean)
|
||||
qt_commandline_option(avx2 TYPE boolean)
|
||||
|
@ -18,7 +18,7 @@ set(java_sources
|
||||
src/org/qtproject/qt5/android//QtThread.java
|
||||
)
|
||||
|
||||
add_jar(QtAndroid
|
||||
qt_internal_add_jar(QtAndroid
|
||||
INCLUDE_JARS ${QT_ANDROID_JAR}
|
||||
SOURCES ${java_sources}
|
||||
OUTPUT_DIR "${QT_BUILD_DIR}/jar"
|
||||
|
@ -19,7 +19,7 @@ set(java_sources
|
||||
src/org/qtproject/qt5/android/QtServiceDelegate.java # special case
|
||||
)
|
||||
|
||||
add_jar(QtAndroid
|
||||
qt_internal_add_jar(QtAndroid
|
||||
INCLUDE_JARS ${QT_ANDROID_JAR}
|
||||
SOURCES ${java_sources}
|
||||
OUTPUT_DIR "${QT_BUILD_DIR}/jar"
|
||||
|
@ -4,7 +4,7 @@ set(java_sources
|
||||
src/org/qtproject/qt5/android/network/QtNetwork.java
|
||||
)
|
||||
|
||||
add_jar(QtAndroidNetwork
|
||||
qt_internal_add_jar(QtAndroidNetwork
|
||||
INCLUDE_JARS ${QT_ANDROID_JAR}
|
||||
SOURCES ${java_sources}
|
||||
OUTPUT_DIR "${QT_BUILD_DIR}/jar"
|
||||
|
@ -3532,7 +3532,7 @@ def write_jar(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
|
||||
cm_fh, scope, "", ["JAVASOURCES"], indent=indent, header=f"set(java_sources\n", footer=")\n"
|
||||
)
|
||||
|
||||
cm_fh.write(f"{spaces(indent)}add_jar({target}\n")
|
||||
cm_fh.write(f"{spaces(indent)}qt_internal_add_jar({target}\n")
|
||||
cm_fh.write(f"{spaces(indent+1)}INCLUDE_JARS {android_sdk_jar}\n")
|
||||
cm_fh.write(f"{spaces(indent+1)}SOURCES ${{java_sources}}\n")
|
||||
cm_fh.write(f'{spaces(indent+1)}OUTPUT_DIR "${{QT_BUILD_DIR}}/{install_dir}"\n')
|
||||
|
Loading…
Reference in New Issue
Block a user