android-common.mk 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # This Source Code Form is subject to the terms of the Mozilla Public
  2. # License, v. 2.0. If a copy of the MPL was not distributed with this
  3. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. # Ensure ANDROID_SDK is defined before including this file.
  5. # We use common android defaults for boot class path and java version.
  6. ifndef ANDROID_SDK
  7. $(error ANDROID_SDK must be defined before including android-common.mk)
  8. endif
  9. # DEBUG_JARSIGNER always debug signs.
  10. DEBUG_JARSIGNER=$(PYTHON) $(abspath $(topsrcdir)/mobile/android/debug_sign_tool.py) \
  11. --keytool=$(KEYTOOL) \
  12. --jarsigner=$(JARSIGNER) \
  13. $(NULL)
  14. # RELEASE_JARSIGNER release signs if possible.
  15. ifdef MOZ_SIGN_CMD
  16. RELEASE_JARSIGNER := $(MOZ_SIGN_CMD) -f jar
  17. else
  18. RELEASE_JARSIGNER := $(DEBUG_JARSIGNER)
  19. endif
  20. # $(1) is the full path to input: foo-debug-unsigned-unaligned.apk.
  21. # $(2) is the full path to output: foo.apk.
  22. # Use this like: $(call RELEASE_SIGN_ANDROID_APK,foo-debug-unsigned-unaligned.apk,foo.apk)
  23. #
  24. # The |zip -d| there to handle re-signing previously signed APKs. Gradle
  25. # produces signed, unaligned APK files, but this expects unsigned, unaligned
  26. # APK files. The |zip -d| discards any existing signature, turning a signed,
  27. # unaligned APK into an unsigned, unaligned APK. Sadly |zip -q| doesn't
  28. # silence a warning about "nothing to do" so we pipe to /dev/null.
  29. RELEASE_SIGN_ANDROID_APK = \
  30. cp $(1) $(2)-unaligned.apk && \
  31. ($(ZIP) -d $(2)-unaligned.apk 'META-INF/*' > /dev/null || true) && \
  32. $(RELEASE_JARSIGNER) $(2)-unaligned.apk && \
  33. $(ZIPALIGN) -f -v 4 $(2)-unaligned.apk $(2) && \
  34. $(RM) $(2)-unaligned.apk
  35. # For Android, we default to 1.7
  36. ifndef JAVA_VERSION
  37. JAVA_VERSION = 1.7
  38. endif
  39. JAVAC_FLAGS = \
  40. -target $(JAVA_VERSION) \
  41. -source $(JAVA_VERSION) \
  42. -encoding UTF8 \
  43. -g:source,lines \
  44. -Werror \
  45. $(NULL)