summaryrefslogtreecommitdiffstats
path: root/mkspecs
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>2013-04-26 16:23:16 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-01 11:24:15 +0200
commit522c7ba1acaa02904e810662017b19e55c328d11 (patch)
treee9055a8988120bb8d05495ba2c2eb9f54a66279d /mkspecs
parent94bed3ad148a6ecba91c0a32e0ee52deda3aec9f (diff)
Enable bundling Qt in Android package in build system
For bundling Qt, we need two things: 1. We need to build a regular .jar file out of the Java files, so that they can be built into the app package. Dexing the classes first (i.e. compiling the JVM bytecode to Dalvik bytecode) is required for loading the .jar file at run-time, but cannot be used for building it into the app, so we need two different paths. 2. We need to specify which extra files have to be bundled for each module (this is primarily for plugins and imports). This is because there is no static dependency on these files, so it cannot be detected during deployment. Task-number: QTBUG-30751 Change-Id: I733603ee5d1c64bd7c5b9357eb5d993b9d0298f7 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Diffstat (limited to 'mkspecs')
-rw-r--r--mkspecs/features/java.prf18
-rw-r--r--mkspecs/features/qt_android_deps.prf23
2 files changed, 32 insertions, 9 deletions
diff --git a/mkspecs/features/java.prf b/mkspecs/features/java.prf
index 6cbd690c37..25f6e66427 100644
--- a/mkspecs/features/java.prf
+++ b/mkspecs/features/java.prf
@@ -17,7 +17,10 @@ android {
CONFIG += android_app
}
-isEmpty(CLASS_DIR): CLASS_DIR = .classes
+isEmpty(CLASS_DIR) {
+ bundled_jar_file: CLASS_DIR = .classes.bundled
+ else: CLASS_DIR = .classes
+}
CONFIG -= qt
@@ -47,17 +50,16 @@ QMAKE_LIBS_OPENGL_ES2 =
QMAKE_LIBDIR =
QMAKE_EXTENSION_SHLIB = jar
-# Override linker with dex (for Android) or jar (for other java builds)
-android {
- QMAKE_LINK_O_FLAG = --output=
+# Override linker with dex (for distributable Android archives) or jar (for other java builds)
+android:!bundled_jar_file {
contains(QMAKE_HOST.os, Windows) {
- QMAKE_LINK = $$PWD/data/android/dx $$SDK_ROOT --dex
+ DEX_CMD = $$PWD/data/android/dx $$SDK_ROOT
} else {
- QMAKE_LINK = $$SDK_ROOT/platform-tools/dx --dex
+ DEX_CMD = $$SDK_ROOT/platform-tools/dx
}
+ QMAKE_LINK_SHLIB_CMD = $$DEX_CMD --dex --output $(TARGET) $$CLASS_DIR
} else {
- QMAKE_LINK_O_FLAG = "cf "
- QMAKE_LINK = jar
+ QMAKE_LINK_SHLIB_CMD = jar cf $(TARGET) -C $$CLASS_DIR .
}
# Force link step to always happen, since we are always updating the
diff --git a/mkspecs/features/qt_android_deps.prf b/mkspecs/features/qt_android_deps.prf
index 27814a90a5..ba37649201 100644
--- a/mkspecs/features/qt_android_deps.prf
+++ b/mkspecs/features/qt_android_deps.prf
@@ -17,6 +17,12 @@ ANDROID_DEPENDS_DIR = $$MODULE_QMAKE_OUTDIR/lib/
DEPENDENCY_FILE = $$ANDROID_DEPENDS_DIR$$TARGET-android-dependencies.xml
!build_pass {
+ !isEmpty(MODULE_PLUGIN_TYPES) {
+ for(PLUGIN_TYPE, MODULE_PLUGIN_TYPES) {
+ ANDROID_BUNDLED_FILES += "plugins/$$PLUGIN_TYPE"
+ }
+ }
+
!isEmpty(ANDROID_JAR_DEPENDENCIES) {
for(JAR_FILE, ANDROID_JAR_DEPENDENCIES) {
INIT_CLASS = $$section(JAR_FILE, ":", 1, 1)
@@ -26,6 +32,15 @@ DEPENDENCY_FILE = $$ANDROID_DEPENDS_DIR$$TARGET-android-dependencies.xml
}
}
+ !isEmpty(ANDROID_BUNDLED_JAR_DEPENDENCIES) {
+ for(JAR_FILE, ANDROID_BUNDLED_JAR_DEPENDENCIES) {
+ INIT_CLASS = $$section(JAR_FILE, ":", 1, 1)
+ !isEmpty(INIT_CLASS): INIT_CLASS = "initClass=\"$$INIT_CLASS\""
+ JAR_FILE = $$section(JAR_FILE, ":", 0, 0)
+ FILE_CONTENT += "<jar bundling=\"1\" file=\"$$JAR_FILE\" $$INIT_CLASS />"
+ }
+ }
+
!isEmpty(ANDROID_LIB_DEPENDENCIES) {
for(LIB_FILE, ANDROID_LIB_DEPENDENCIES) {
FILE_CONTENT += "<lib file=\"$$LIB_FILE\" />"
@@ -40,13 +55,19 @@ DEPENDENCY_FILE = $$ANDROID_DEPENDS_DIR$$TARGET-android-dependencies.xml
}
}
+ !isEmpty(ANDROID_BUNDLED_FILES) {
+ for (BUNDLED_FILE, ANDROID_BUNDLED_FILES) {
+ FILE_CONTENT += "<bundled file=\"$$BUNDLED_FILE\" />"
+ }
+ }
+
!isEmpty(FILE_CONTENT) {
FILE_CONTENT = "<rules><dependencies><lib name=\"$$TARGET\"><depends>" $$FILE_CONTENT "</depends></lib></dependencies></rules>"
write_file($$DEPENDENCY_FILE, FILE_CONTENT) | error("Aborting.")
}
}
-!isEmpty(ANDROID_JAR_DEPENDENCIES)|!isEmpty(ANDROID_LIB_DEPENDENCIES)|!isEmpty(ANDROID_LIB_DEPENDENCY_REPLACEMENTS) {
+!isEmpty(ANDROID_JAR_DEPENDENCIES)|!isEmpty(ANDROID_LIB_DEPENDENCIES)|!isEmpty(ANDROID_LIB_DEPENDENCY_REPLACEMENTS)|!isEmpty(ANDROID_BUNDLED_JAR_DEPENDENCIES)|!isEmpty(ANDROID_BUNDLED_FILES) {
install_dependencies_file.files = $$DEPENDENCY_FILE
install_dependencies_file.path = $$[QT_INSTALL_LIBS]
INSTALLS += install_dependencies_file