summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorLeander Beernaert <leander.beernaert@qt.io>2019-10-18 14:28:08 +0200
committerLeander Beernaert <leander.beernaert@qt.io>2019-10-18 13:20:46 +0000
commit373be4200b162ae9b2244d7019770911bc73317a (patch)
treebdefc6a7e22402d7e08d3b3d2150870a129fc565 /util
parent7e7f41e40c39361059ce4693c5e3a5e1ccd6f7e5 (diff)
Add conversion code for Java code
Add support to pro2cmake to convert java code for android. Add support to override API_LEVEL for the Android sdk jar file. If the sdk is not found, we'll default to the one located by QT_ANDROID_JAR. Change-Id: If0b746dc7f9148ac43e6592a4a4dd23d46bbd4cd Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'util')
-rwxr-xr-xutil/cmake/pro2cmake.py43
1 files changed, 42 insertions, 1 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py
index 5041519348..24c77cb2b1 100755
--- a/util/cmake/pro2cmake.py
+++ b/util/cmake/pro2cmake.py
@@ -2692,6 +2692,44 @@ def write_find_package_section(
cm_fh.write("\n")
+def write_jar(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
+
+ target = scope.TARGET
+
+ install_dir = scope.expandString("target.path")
+ if not install_dir:
+ raise RuntimeError("Could not locate jar install path")
+ install_dir = install_dir.replace("$$[QT_INSTALL_PREFIX]/", "")
+
+ android_sdk_jar = "${QT_ANDROID_JAR}"
+ android_api_level = scope.get_string("API_VERSION")
+ if android_api_level:
+ cm_fh.write(f'{spaces(indent)}qt_get_android_sdk_jar_for_api("{android_api_level}" android_sdk)\n\n')
+ android_sdk_jar ="${android_sdk}"
+
+ write_source_file_list(
+ 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+1)}INCLUDE_JARS {android_sdk_jar}\n")
+ cm_fh.write(f"{spaces(indent+1)}SOURCES ${{java_sources}}\n")
+ cm_fh.write(f"{spaces(indent)})\n\n")
+
+ cm_fh.write(f"{spaces(indent)}install_jar({target}\n")
+ cm_fh.write(f"{spaces(indent+1)}DESTINATION {install_dir}\n")
+ cm_fh.write(f"{spaces(indent+1)}COMPONENT Devel\n")
+ cm_fh.write(f"{spaces(indent)})\n\n")
+
+ return target
+
+
def write_example(
cm_fh: IO[str], scope: Scope, gui: bool = False, *, indent: int = 0, is_plugin: bool = False
) -> str:
@@ -3030,6 +3068,7 @@ def handle_app_or_lib(
assert scope.TEMPLATE in ("app", "lib")
config = scope.get("CONFIG")
+ is_jar = "java" in config
is_lib = scope.TEMPLATE == "lib"
is_qml_plugin = any("qml_plugin" == s for s in scope.get("_LOADED"))
is_plugin = (
@@ -3040,7 +3079,9 @@ def handle_app_or_lib(
val not in config for val in ["console", "cmdline"]
) and "testlib" not in scope.expand("QT")
- if is_example:
+ if is_jar:
+ tar = write_jar(cm_fh, scope, indent=indent)
+ elif is_example:
target = write_example(cm_fh, scope, gui, indent=indent, is_plugin=is_plugin)
elif is_plugin:
assert not is_example