summaryrefslogtreecommitdiffstats
path: root/mkspecs/features/java.prf
blob: 25f6e66427de5ae38b1d7a58f5120a1b3d8c85f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
TEMPLATE = lib
android {
    isEmpty(SDK_ROOT): SDK_ROOT = $$(ANDROID_SDK_ROOT)
    isEmpty(SDK_ROOT): SDK_ROOT = $$DEFAULT_ANDROID_SDK_ROOT
    isEmpty(API_VERSION) {
        API_VERSION = $$(ANDROID_API_VERSION)
        isEmpty(API_VERSION): API_VERSION = android-10
    }

    !exists($$SDK_ROOT/platforms/$$API_VERSION/android.jar) {
        error("The Path $$SDK_ROOT/platforms/$$API_VERSION/android.jar does not exist. Make sure the ANDROID_SDK_ROOT and ANDROID_API_VERSION environment variables are correctly set.")
    }
    JAVACLASSPATH += $$SDK_ROOT/platforms/$$API_VERSION/android.jar

    # 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
}

isEmpty(CLASS_DIR) {
    bundled_jar_file: CLASS_DIR = .classes.bundled
    else: CLASS_DIR = .classes
}

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
javac.commands = javac -source 6 -target 6 -cp $$shell_quote($$shell_path($$join(JAVACLASSPATH, $$QMAKE_DIRLIST_SEP))) -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
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

# Override linker with dex (for distributable Android archives) or jar (for other java builds)
android:!bundled_jar_file {
    contains(QMAKE_HOST.os, Windows) {
        DEX_CMD = $$PWD/data/android/dx $$SDK_ROOT
    } else {
        DEX_CMD = $$SDK_ROOT/platform-tools/dx
    }
    QMAKE_LINK_SHLIB_CMD = $$DEX_CMD --dex --output $(TARGET) $$CLASS_DIR
} else {
    QMAKE_LINK_SHLIB_CMD = jar cf $(TARGET) -C $$CLASS_DIR .
}

# Force link step to always happen, since we are always updating the
# .class files
PRE_TARGETDEPS += FORCE