author Nick Alexander <>
Mon, 23 Oct 2017 13:24:58 -0700
changeset 440947 34f83aab44e6c0a68a448c3c10f61267c0eb649e
parent 440930 0de94b56338e29e469b762fe9e98f2b6e7b99c49
child 441054 a73e202ca31d30bc2b96418fa81d1096f8dc731e
permissions -rw-r--r--
Bug 1411688 - Part 1: Make --with-gradle handle single-locale repacks. r=snorp Single-locale repacks do the following: Download existing APK; unzip APK; update l10n resources; |mach package| with IS_LANGUAGE_REPACK=1. This is pretty hard to accommodate, but we can try. The key issues here are to recognize when IS_LANGUAGE_REPACK=1 and not ask for l10n resources (in particular, strings.xml) to be generated. We do need to include the freshly built classes.dex when repackaging, because newer Gradle/aapt doesn't preserve the IDs. MozReview-Commit-ID: 9FvQtmPOUjg

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at

# This file should ONLY be included from It was
# split into its own file to increase comprehension of

include $(MOZILLA_DIR)/config/

# Files packed into the APK root.  Packing files into the APK root is not
# supported by modern Android build systems, including Gradle, so don't add to
# this list without Android peer approval.
  application.ini \
  package-name.txt \
  ua-update.json \
  platform.ini \
  removed-files \

GECKO_APP_AP_PATH = $(topobjdir)/mobile/android/base

ifeq ($(MOZ_BUILD_APP),mobile/android)
UPLOAD_EXTRA_FILES += robocop.apk

# Robocop/Robotium tests, Android Background tests, and Fennec need to
# be signed with the same key, which means release signing them all.

robocop_apk := $(topobjdir)/mobile/android/tests/browser/robocop/robocop-debug-unsigned-unaligned.apk
robocop_apk := $(topobjdir)/gradle/build/mobile/android/app/outputs/apk/app-official-photon-debug-androidTest.apk

  $(call RELEASE_SIGN_ANDROID_APK,$(robocop_apk),$(ABS_DIST)/robocop.apk)
INNER_ROBOCOP_PACKAGE=echo 'Testing is disabled - No Android Robocop for you'

# Fennec's OMNIJAR_NAME can include a directory; for example, it might
# be "assets/omni.ja". This path specifies where the omni.ja file
# lives in the APK, but should not root the resources it contains
# under assets/ (i.e., resources should not live at chrome://assets/).
# writes /omni.ja in order to be consistent with the
# layout expected by language repacks. Therefore, we move it to the
# correct path here, in INNER_MAKE_PACKAGE. See comment about

# OMNIJAR_DIR is './' for "omni.ja", 'assets/' for "assets/omni.ja".

# We force build an ap_ that does not check dependencies below.
# Language repacks take advantage of this unchecked dependency ap_ to
# insert additional resources (translated strings) into the ap_
# without the build system's participation.  This can do the wrong
# thing if there are resource changes in between build time and
# package time.

  $(MAKE) -C $(GECKO_APP_AP_PATH) gecko-nodeps.ap_ && \
  $(PYTHON) -m mozbuild.action.package_fennec_apk \
    --verbose \
    --inputs \
      $(GECKO_APP_AP_PATH)/gecko-nodeps.ap_ \
    --omnijar $(MOZ_PKG_DIR)/$(OMNIJAR_NAME) \
    --classes-dex $(GECKO_APP_AP_PATH)/classes.dex \
    --lib-dirs $(MOZ_PKG_DIR)/lib \
    --assets-dirs $(MOZ_PKG_DIR)/assets \
    --features-dirs $(MOZ_PKG_DIR)/features \
    --root-files $(foreach f,$(ROOT_FILES),$(MOZ_PKG_DIR)/$(f)) \
    --output $(PACKAGE:.apk=-unsigned-unaligned.apk) && \
  $(call RELEASE_SIGN_ANDROID_APK,$(PACKAGE:.apk=-unsigned-unaligned.apk),$(PACKAGE))

# Packaging produces many optional artifacts.
package_fennec = \

# Re-packaging only replaces Android resources and the omnijar before
# (re-)signing.
repackage_fennec = \
  $(MAKE) -C $(GECKO_APP_AP_PATH) gecko-nodeps.ap_ && \
  $(PYTHON) -m mozbuild.action.package_fennec_apk \
    --verbose \
    --inputs \
      $(UNPACKAGE) \
      $(GECKO_APP_AP_PATH)/gecko-nodeps.ap_ \
    --omnijar $(MOZ_PKG_DIR)/$(OMNIJAR_NAME) \
    --classes-dex $(GECKO_APP_AP_PATH)/classes.dex \
    --output $(PACKAGE:.apk=-unsigned-unaligned.apk) && \
  $(call RELEASE_SIGN_ANDROID_APK,$(PACKAGE:.apk=-unsigned-unaligned.apk),$(PACKAGE))

INNER_MAKE_PACKAGE = $(if $(UNPACKAGE),$(repackage_fennec),$(package_fennec))

# Language repacks root the resources contained in assets/omni.ja
# under assets/, but the repacks expect them to be rooted at /.
# Therefore, we we move the omnijar back to / so the resources are
# under the root here, in INNER_UNMAKE_PACKAGE. See comments about
# OMNIJAR_NAME earlier in this file and in

  mkdir $(MOZ_PKG_DIR) && \
  ( cd $(MOZ_PKG_DIR) && \
    $(if $(filter-out ./,$(OMNIJAR_DIR)), \
      true) )