From 675805e9eb0dc68a6e96622353073fd54161bdaf Mon Sep 17 00:00:00 2001 From: Assam Boudjelthia Date: Fri, 11 Sep 2020 11:07:44 +0300 Subject: [PATCH] Android: allow setting javac build version from the configure script The configure options -android-javac-source and -android-javac-target can be used to set the version numbers. Fixes: QTBUG-86282 Pick-to: 5.15 Change-Id: I36b0665de2c31e16bf6d138859b5503455eb8e66 Reviewed-by: Alexandru Croitor Reviewed-by: Andy Shaw --- config_help.txt | 2 ++ configure.json | 2 ++ configure.pri | 7 ++++++- mkspecs/features/java.prf | 11 ++++++++++- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/config_help.txt b/config_help.txt index 2cb34865bf..7b918a7511 100644 --- a/config_help.txt +++ b/config_help.txt @@ -210,6 +210,8 @@ Build environment: [$ANDROID_NDK_HOST] -android-abis ....... Comma separated Android abis, default is: armeabi-v7a,arm64-v8a,x86,x86_64 + -android-javac-target Set the javac build target version [7] + -android-javac-source Set the javac build source version [7] -android-style-assets Automatically extract style assets from the device at run time. This option makes the Android style behave correctly, but also makes the Android platform plugin diff --git a/configure.json b/configure.json index 6f62600090..4b339cf2ae 100644 --- a/configure.json +++ b/configure.json @@ -55,6 +55,8 @@ "android-ndk-host": "string", "android-ndk-platform": "string", "android-sdk": "string", + "android-javac-target": "string", + "android-javac-source": "string", "android-style-assets": "boolean", "appstore-compliant": "boolean", diff --git a/configure.pri b/configure.pri index bd282df0aa..a04aa17236 100644 --- a/configure.pri +++ b/configure.pri @@ -627,12 +627,17 @@ defineTest(qtConfOutput_prepareOptions) { isEmpty(platform): \ platform = android-23 + android_javac_target = $$eval(config.input.android-javac-target) + android_javac_source = $$eval(config.input.android-javac-source) + $${currentConfig}.output.devicePro += \ "DEFAULT_ANDROID_SDK_ROOT = $$val_escape(sdk_root)" \ "DEFAULT_ANDROID_NDK_ROOT = $$val_escape(ndk_root)" \ "DEFAULT_ANDROID_PLATFORM = $$platform" \ "DEFAULT_ANDROID_NDK_HOST = $$ndk_host" \ - "DEFAULT_ANDROID_ABIS = $$split(android_abis, ',')" + "DEFAULT_ANDROID_ABIS = $$split(android_abis, ',')" \ + "ANDROID_JAVAC_TARGET_VERSION = $$android_javac_target" \ + "ANDROID_JAVAC_SOURCE_VERSION = $$android_javac_source" } export($${currentConfig}.output.devicePro) diff --git a/mkspecs/features/java.prf b/mkspecs/features/java.prf index 1d52f05e52..20dc719699 100644 --- a/mkspecs/features/java.prf +++ b/mkspecs/features/java.prf @@ -20,7 +20,16 @@ CONFIG += plugin no_plugin_name_prefix javac.input = JAVASOURCES javac.output = $$CLASS_DIR javac.CONFIG += combine -javac.commands = javac -source 7 -target 7 -Xlint:unchecked -bootclasspath $$ANDROID_JAR_FILE -cp $$shell_quote($$system_path($$join(JAVACLASSPATH, $$DIRLIST_SEPARATOR))) -d $$shell_quote($$CLASS_DIR) ${QMAKE_FILE_IN} + +# Check for user defined javac build version +javac_target_version = $$ANDROID_JAVAC_TARGET_VERSION +isEmpty(javac_target_version): javac_target_version = 7 + +javac_source_version = $$ANDROID_JAVAC_SOURCE_VERSION +isEmpty(javac_source_version): javac_source_version = 7 + +javac.commands = javac -source $$javac_source_version -target $$javac_target_version -Xlint:unchecked -bootclasspath $$ANDROID_JAR_FILE -cp $$shell_quote($$system_path($$join(JAVACLASSPATH, $$DIRLIST_SEPARATOR))) -d $$shell_quote($$CLASS_DIR) ${QMAKE_FILE_IN} + # Force rebuild every time, because we don't know the paths of the destination files # as they depend on the code. javac.depends = FORCE