2013-03-04 09:16:42 +00:00
TEMPLATE = lib
android {
2013-09-18 09:49:56 +00:00
API_VERSION_TO_USE = $$(ANDROID_API_VERSION)
isEmpty(API_VERSION_TO_USE): API_VERSION_TO_USE = $$API_VERSION
isEmpty(API_VERSION_TO_USE): API_VERSION_TO_USE = android-10
2013-03-04 09:16:42 +00:00
2014-07-29 13:13:57 +00:00
ANDROID_JAR_FILE = $$ANDROID_SDK_ROOT/platforms/$$API_VERSION_TO_USE/android.jar
2013-08-15 10:16:08 +00:00
!exists($$ANDROID_JAR_FILE) {
error("The Path $$ANDROID_JAR_FILE does not exist. Make sure the ANDROID_SDK_ROOT and ANDROID_API_VERSION environment variables are correctly set.")
2013-03-04 09:16:42 +00:00
}
2013-08-15 10:16:08 +00:00
JAVACLASSPATH += $$ANDROID_JAR_FILE
2013-03-04 09:16:42 +00:00
# FIXME: This is a hack to work around some hardcoded values in the android.prf. The
# android.prf should be fixed and this should be removed.
CONFIG += android_app
}
2013-04-26 14:23:16 +00:00
isEmpty(CLASS_DIR) {
bundled_jar_file: CLASS_DIR = .classes.bundled
else: CLASS_DIR = .classes
}
2013-03-04 09:16:42 +00:00
CONFIG -= qt
# Without these, qmake adds a name prefix and versioning postfixes (as well as file
# links) to the target. This is hardcoded in the qmake code, so for now we use
# the plugin configs to get what we want.
CONFIG += plugin no_plugin_name_prefix
javac.input = JAVASOURCES
javac.output = $$CLASS_DIR
javac.CONFIG += combine
2014-04-29 18:15:21 +00:00
javac.commands = javac -source 6 -target 6 -Xlint:unchecked -bootclasspath $$ANDROID_JAR_FILE -cp $$shell_quote($$system_path($$join(JAVACLASSPATH, $$DIRLIST_SEP))) -d $$shell_quote($$CLASS_DIR) ${QMAKE_FILE_IN}
2013-03-04 09:16:42 +00:00
# Force rebuild every time, because we don't know the paths of the destination files
# as they depend on the code.
javac.depends = FORCE
QMAKE_EXTRA_COMPILERS += javac
mkpath($$absolute_path($$CLASS_DIR, $$OUT_PWD)) | error("Aborting.")
# Disable all linker flags since we are overriding the regular linker
QMAKE_LFLAGS =
QMAKE_CFLAGS =
QMAKE_LFLAGS_RPATH =
QMAKE_LFLAGS_PLUGIN =
QMAKE_LIBS =
QMAKE_LIBS_OPENGL_ES2 =
QMAKE_LIBDIR =
QMAKE_EXTENSION_SHLIB = jar
2013-04-26 14:23:16 +00:00
# Override linker with dex (for distributable Android archives) or jar (for other java builds)
android:!bundled_jar_file {
2013-03-28 23:50:30 +00:00
contains(QMAKE_HOST.os, Windows) {
2013-06-09 23:19:12 +00:00
# The location where dx.bat expects itself to be found is used as the landmark instead
# of the base sdk folder.
# Doing it this way makes this logic more similar to the other platforms and
# also means that our dx.bat is more like Google's dx.bat
2014-07-29 13:13:57 +00:00
DEX_BAT = $$ANDROID_SDK_ROOT/platform-tools/dx.bat
!exists($$DEX_BAT): DEX_BAT = $$ANDROID_SDK_ROOT/build-tools/$$ANDROID_SDK_BUILD_TOOLS_REVISION/dx.bat
2013-06-09 23:19:12 +00:00
DEX_CMD = $$PWD/data/android/dx $$DEX_BAT
2013-03-28 23:50:30 +00:00
} else {
2014-07-29 13:13:57 +00:00
DEX_CMD = $$ANDROID_SDK_ROOT/platform-tools/dx
!exists($$DEX_CMD): DEX_CMD = $$ANDROID_SDK_ROOT/build-tools/$$ANDROID_SDK_BUILD_TOOLS_REVISION/dx
2013-05-28 07:10:39 +00:00
!exists($$DEX_CMD): error("The path $$DEX_CMD does not exist. Please set the environment variable ANDROID_BUILD_TOOLS_REVISION to the revision of the build tools installed in your Android SDK.")
2013-03-28 23:50:30 +00:00
}
2013-04-26 14:23:16 +00:00
QMAKE_LINK_SHLIB_CMD = $$DEX_CMD --dex --output $(TARGET) $$CLASS_DIR
2013-03-04 09:16:42 +00:00
} else {
2013-04-26 14:23:16 +00:00
QMAKE_LINK_SHLIB_CMD = jar cf $(TARGET) -C $$CLASS_DIR .
2013-03-04 09:16:42 +00:00
}
# Force link step to always happen, since we are always updating the
# .class files
PRE_TARGETDEPS += FORCE