Bug 1439742 - Part 3: Restore single-locale repack behaviour. r=ted.mielczarek
There was even another layer of complexity! There are two axes
involved with these files: AB_CD controls localization and the Make
target controls destination. The former always applies and was
handled correctly by the earlier commits. For the record, it is:
regular builds - AB_CD unset
multi-locale builds - AB_CD set
single-locale repacks - AB_CD set
However, the earlier commits did not handle the Make target correctly,
and replaced that logic with always using AB_CD. For the record, the
existing logic (before any changes) is:
regular builds - Make target is `libs` in mobile/android/base/locales
multi-locale builds - Make target is `chrome-%` in mobile/android/base/locales
single-locale repacks - Make target is `libs` in mobile/android/base/locales
The multi-locale builds were correctly using AB_CD (set) and the
chrome-% targets to write resources to
res/{raw-AB-rCD,values-AB-rCD}. However, the single-locale repacks
were incorrectly using AB_CD (set) to write resources to
res/{raw-AB-rCD,values-AB-rCD}, when in reality they're wanted in
res/{raw,values}.
This commit adds targets for both destinations, and uses Make
chrome-%:: and libs:: magic to control what is invoked in the various
situations. Tricky!
MozReview-Commit-ID: 1oezxnd0lWD
--- a/mobile/android/base/locales/moz.build
+++ b/mobile/android/base/locales/moz.build
@@ -1,47 +1,67 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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 http://mozilla.org/MPL/2.0/.
-LOCALIZED_GENERATED_FILES += ['../res/raw{AB_rCD}/browsersearch.json']
-browsersearch = LOCALIZED_GENERATED_FILES['../res/raw{AB_rCD}/browsersearch.json']
-browsersearch.script = 'generate_browsersearch.py'
-browsersearch.inputs = [
- # The `locales/en-US/` in this path will be rewritten to the
- # locale-specific path.
- '/mobile/locales/en-US/chrome/region.properties',
-]
-browsersearch.flags += ['--verbose']
-browsersearch.flags += [
- '--fallback',
- # The `locales/en-US` in this path will not be rewritten.
- TOPSRCDIR + '/mobile/locales/en-US/chrome/region.properties'
-]
+# Regular builds invoke `libs` targets that localize files with no AB_CD set
+# into the default resources (res/{values,raw}).
+#
+# Multi-locale builds invoke `chrome-%` targets that localize files into
+# locale-specific resources (res/{values,raw}-AB-rCD). Single-locale repacks
+# invoke `libs AB_CD=$*` targets that localize files into the default resources
+# (res/{values,raw}).
+#
+# Therefore, every localized generated file needs to be written into both the
+# default resources (res/{values,raw}) and the locale-specific resources
+# (res/{values,raw}-AB-rCD), depending on Make target magic controlled in
+# mobile/android/base (for regular builds) and in mobile/android/locales (for
+# multi-locale builds and single-locale repacks).
+
+for f in ['../res/raw/browsersearch.json',
+ '../res/raw{AB_rCD}/browsersearch.json']:
+ LOCALIZED_GENERATED_FILES += [f]
+ browsersearch = LOCALIZED_GENERATED_FILES[f]
+ browsersearch.script = 'generate_browsersearch.py'
+ browsersearch.inputs = [
+ # The `locales/en-US/` in this path will be rewritten to the
+ # locale-specific path.
+ '/mobile/locales/en-US/chrome/region.properties',
+ ]
+ browsersearch.flags += ['--verbose']
+ browsersearch.flags += [
+ '--fallback',
+ # The `locales/en-US` in this path will not be rewritten.
+ TOPSRCDIR + '/mobile/locales/en-US/chrome/region.properties'
+ ]
-LOCALIZED_GENERATED_FILES += ['../res/raw{AB_rCD}/suggestedsites.json']
-suggestedsites = LOCALIZED_GENERATED_FILES['../res/raw{AB_rCD}/suggestedsites.json']
-suggestedsites.script = 'generate_suggestedsites.py'
-suggestedsites.inputs = [
- # The `locales/en-US/` in this path will be rewritten to the
- # locale-specific path.
- '/mobile/locales/en-US/chrome/region.properties',
-]
-suggestedsites.flags += ['--verbose']
-suggestedsites.flags += ['--android-package-name', CONFIG['ANDROID_PACKAGE_NAME']]
-suggestedsites.flags += ['--resources', TOPSRCDIR + '/mobile/android/app/src/photon/res']
-suggestedsites.flags += [
- '--fallback',
- # The `locales/en-US` in this path will not be rewritten.
- TOPSRCDIR + '/mobile/locales/en-US/chrome/region.properties'
-]
+for f in ['../res/raw/suggestedsites.json',
+ '../res/raw{AB_rCD}/suggestedsites.json']:
+ LOCALIZED_GENERATED_FILES += [f]
+ suggestedsites = LOCALIZED_GENERATED_FILES[f]
+ suggestedsites.script = 'generate_suggestedsites.py'
+ suggestedsites.inputs = [
+ # The `locales/en-US/` in this path will be rewritten to the
+ # locale-specific path.
+ '/mobile/locales/en-US/chrome/region.properties',
+ ]
+ suggestedsites.flags += ['--verbose']
+ suggestedsites.flags += ['--android-package-name', CONFIG['ANDROID_PACKAGE_NAME']]
+ suggestedsites.flags += ['--resources', TOPSRCDIR + '/mobile/android/app/src/photon/res']
+ suggestedsites.flags += [
+ '--fallback',
+ # The `locales/en-US` in this path will not be rewritten.
+ TOPSRCDIR + '/mobile/locales/en-US/chrome/region.properties'
+ ]
-LOCALIZED_GENERATED_FILES += ['../res/values{AB_rCD}/strings.xml']
-strings = LOCALIZED_GENERATED_FILES['../res/values{AB_rCD}/strings.xml']
-strings.script = 'generate_strings_xml.py'
-strings.inputs = [
- '../strings.xml.in',
- # The `en-US/` will be rewritten to the locale-specific path.
- 'en-US/android_strings.dtd',
- 'en-US/sync_strings.dtd',
-]
+for f in ['../res/values/strings.xml',
+ '../res/values{AB_rCD}/strings.xml']:
+ LOCALIZED_GENERATED_FILES += [f]
+ strings = LOCALIZED_GENERATED_FILES[f]
+ strings.script = 'generate_strings_xml.py'
+ strings.inputs = [
+ '../strings.xml.in',
+ # The `en-US/` will be rewritten to the locale-specific path.
+ 'en-US/android_strings.dtd',
+ 'en-US/sync_strings.dtd',
+ ]
--- a/python/mozbuild/mozbuild/backend/recursivemake.py
+++ b/python/mozbuild/mozbuild/backend/recursivemake.py
@@ -575,17 +575,20 @@ class RecursiveMakeBackend(CommonBackend
if needs_AB_rCD:
backend_file.write('include $(topsrcdir)/config/AB_rCD.mk\n')
# If we're doing this during export that means we need it during
# compile, but if we have an artifact build we don't run compile,
# so we can skip it altogether or let the rule run as the result of
# something depending on it.
if tier != 'export' or not self.environment.is_artifact_build:
- backend_file.write('%s:: %s\n' % (tier, first_output))
+ if not needs_AB_rCD:
+ # Android localized resources have special Makefile
+ # handling.
+ backend_file.write('%s:: %s\n' % (tier, first_output))
for output in obj.outputs:
if output != first_output:
backend_file.write('%s: %s ;\n' % (output, first_output))
backend_file.write('GARBAGE += %s\n' % output)
backend_file.write('EXTRA_MDDEPEND_FILES += %s\n' % dep_file)
if obj.script:
backend_file.write("""{output}: {script}{inputs}{backend}{repack_force}
\t$(REPORT_BUILD)