java.prf 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. TEMPLATE = lib
  2. android {
  3. load(sdk)
  4. # FIXME: This is a hack to work around some hardcoded values in the android.prf. The
  5. # android.prf should be fixed and this should be removed.
  6. CONFIG += android_app
  7. }
  8. isEmpty(CLASS_DIR) {
  9. bundled_jar_file: CLASS_DIR = .classes.bundled
  10. else: CLASS_DIR = .classes
  11. }
  12. CONFIG -= qt
  13. # Without these, qmake adds a name prefix and versioning postfixes (as well as file
  14. # links) to the target. This is hardcoded in the qmake code, so for now we use
  15. # the plugin configs to get what we want.
  16. CONFIG += plugin no_plugin_name_prefix
  17. javac.input = JAVASOURCES
  18. javac.output = $$CLASS_DIR
  19. javac.CONFIG += combine
  20. javac.commands = javac -source 6 -target 6 -Xlint:unchecked -bootclasspath $$ANDROID_JAR_FILE -cp $$shell_quote($$system_path($$join(JAVACLASSPATH, $$DIRLIST_SEPARATOR))) -d $$shell_quote($$CLASS_DIR) ${QMAKE_FILE_IN}
  21. # Force rebuild every time, because we don't know the paths of the destination files
  22. # as they depend on the code.
  23. javac.depends = FORCE
  24. QMAKE_EXTRA_COMPILERS += javac
  25. mkpath($$absolute_path($$CLASS_DIR, $$OUT_PWD)) | error("Aborting.")
  26. # Disable all linker flags since we are overriding the regular linker
  27. QMAKE_LFLAGS =
  28. QMAKE_CFLAGS =
  29. QMAKE_LFLAGS_RPATH =
  30. QMAKE_LFLAGS_PLUGIN =
  31. QMAKE_LIBS =
  32. QMAKE_LIBS_OPENGL_ES2 =
  33. QMAKE_LIBDIR =
  34. QMAKE_EXTENSION_SHLIB = jar
  35. # Override linker with dex (for distributable Android archives) or jar (for other java builds)
  36. android:!bundled_jar_file {
  37. contains(QMAKE_HOST.os, Windows) {
  38. # The location where dx.bat expects itself to be found is used as the landmark instead
  39. # of the base sdk folder.
  40. # Doing it this way makes this logic more similar to the other platforms and
  41. # also means that our dx.bat is more like Google's dx.bat
  42. DEX_BAT = $$ANDROID_SDK_ROOT/platform-tools/dx.bat
  43. !exists($$DEX_BAT): DEX_BAT = $$ANDROID_SDK_ROOT/build-tools/$$ANDROID_SDK_BUILD_TOOLS_REVISION/dx.bat
  44. DEX_CMD = $$PWD/data/android/dx $$DEX_BAT
  45. } else {
  46. DEX_CMD = $$ANDROID_SDK_ROOT/platform-tools/dx
  47. !exists($$DEX_CMD): DEX_CMD = $$ANDROID_SDK_ROOT/build-tools/$$ANDROID_SDK_BUILD_TOOLS_REVISION/dx
  48. !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.")
  49. }
  50. QMAKE_LINK_SHLIB_CMD = $$DEX_CMD --dex --output $(TARGET) $$CLASS_DIR
  51. } else {
  52. QMAKE_LINK_SHLIB_CMD = jar cf $(TARGET) -C $$CLASS_DIR .
  53. }
  54. # Force link step to always happen, since we are always updating the
  55. # .class files
  56. PRE_TARGETDEPS += FORCE