Bug 1533051 - Package GeckoView prefs at architecture-specific paths for Android fat AAR/GeckoView multi-architecture builds. r=glandium
☠☠ backed out by 17b8002251d0 ☠ ☠
authorNick Alexander <nalexander@mozilla.com>
Wed, 27 Mar 2019 17:35:26 +0000
changeset 466462 e5117d2f9311ff75bb90feb26cdeb148b8cdb025
parent 466461 d316af005a94a465d486fe09eb2b5a94e46d185f
child 466463 d1e03f3bba1aabd64389e3c98c660242c6d59bb9
push id35768
push useropoprus@mozilla.com
push dateThu, 28 Mar 2019 09:55:54 +0000
treeherdermozilla-central@c045dd97faf2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1533051, 1533425
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1533051 - Package GeckoView prefs at architecture-specific paths for Android fat AAR/GeckoView multi-architecture builds. r=glandium Bug 1533425 makes Gecko try to load from $ARCH/greprefs.js, etc on Android. This patch teaches the packager to put preferences into those architecture-specific locations for that code to find. Differential Revision: https://phabricator.services.mozilla.com/D24984
config/rules.mk
mobile/android/installer/package-manifest.in
mobile/android/locales/Makefile.in
mobile/locales/Makefile.in
modules/libpref/moz.build
python/mozbuild/mozbuild/frontend/context.py
python/mozbuild/mozpack/packager/formats.py
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -962,23 +962,27 @@ ifneq ($(XPI_NAME),)
 	$(NSINSTALL) -D $@
 
 export:: $(FINAL_TARGET)
 endif
 
 ################################################################################
 # The default location for prefs is the gre prefs directory.
 # PREF_DIR is used for L10N_PREF_JS_EXPORTS in various locales/ directories.
-PREF_DIR = defaults/pref
+PREF_DIR := defaults/pref
 
 # If DIST_SUBDIR is defined it indicates that app and gre dirs are
 # different and that we are building app related resources. Hence,
 # PREF_DIR should point to the app prefs location.
 ifneq (,$(DIST_SUBDIR)$(XPI_NAME))
-PREF_DIR = defaults/preferences
+PREF_DIR := defaults/preferences
+endif
+
+ifeq ($(MOZ_BUILD_APP),mobile/android)
+PREF_DIR := $(PREF_DIR)/$(ANDROID_CPU_ARCH)
 endif
 
 ################################################################################
 # CHROME PACKAGING
 
 chrome::
 	$(MAKE) realchrome
 	$(LOOP_OVER_DIRS)
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -159,17 +159,17 @@
 ; All the pref files must be part of base to prevent migration bugs
 #ifdef MOZ_GECKOVIEW_JAR
 @BINPATH@/@PREF_DIR@/geckoview-prefs.js
 #else
 @BINPATH@/@PREF_DIR@/mobile.js
 #endif
 @BINPATH@/@PREF_DIR@/channel-prefs.js
 @BINPATH@/ua-update.json
-@BINPATH@/greprefs.js
+@BINPATH@/@ANDROID_CPU_ARCH@/greprefs.js
 @BINPATH@/defaults/autoconfig/prefcalls.js
 
 ; [Layout Engine Resources]
 ; Style Sheets, Graphics and other Resources used by the layout engine.
 @BINPATH@/res/EditorOverride.css
 @BINPATH@/res/contenteditable.css
 @BINPATH@/res/designmode.css
 @BINPATH@/res/table-add-column-after-active.gif
@@ -255,14 +255,14 @@
 #endif
 
 ; Remote control protocol
 #ifdef ENABLE_MARIONETTE
 @BINPATH@/chrome/marionette@JAREXT@
 @BINPATH@/chrome/marionette.manifest
 @BINPATH@/components/marionette.manifest
 @BINPATH@/components/marionette.js
-@BINPATH@/defaults/pref/marionette.js
+@BINPATH@/@PREF_DIR@/marionette.js
 #endif
 
 #ifdef PKG_LOCALE_MANIFEST
 #include @PKG_LOCALE_MANIFEST@
 #endif
--- a/mobile/android/locales/Makefile.in
+++ b/mobile/android/locales/Makefile.in
@@ -38,17 +38,17 @@ clobber-stage:
 	$(RM) $(DEPTH)/mobile/android/base/res/raw-*/suggestedsites.json
 
 # merge if we're not en-US, using conditional function as we need
 # the current value of AB_CD
 libs-%: AB_CD=$*
 libs-%:
 	$(if $(filter en-US,$(AB_CD)),, $(MAKE) merge-$*)
 	$(MAKE) -C $(DEPTH)/mobile/locales libs-$*
-	$(MAKE) libs AB_CD=$* XPI_NAME=locale-$* PREF_DIR=defaults/pref
+	$(MAKE) libs AB_CD=$* XPI_NAME=locale-$* PREF_DIR=defaults/pref/$(ANDROID_CPU_ARCH)
 	$(MAKE) multilocale.txt-$* AB_CD=$* XPI_NAME=locale-$*
 ifeq ($(OS_TARGET),Android)
 	$(MAKE) -C $(DEPTH)/mobile/android/base AB_CD=$* XPI_NAME=locale-$*
 endif
 
 # Tailored target to just add the chrome processing for multi-locale builds
 # merge if we're not en-US, using conditional function as we need
 # the current value of AB_CD
--- a/mobile/locales/Makefile.in
+++ b/mobile/locales/Makefile.in
@@ -15,16 +15,16 @@ SUBMAKEFILES += \
         $(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 libs-%: AB_CD=$*
 libs-%:
 	$(NSINSTALL) -D $(DIST)/install
 	@$(MAKE) -C $(DEPTH)/toolkit/locales libs-$*
-	@$(MAKE) libs AB_CD=$* XPI_NAME=locale-$* PREF_DIR=defaults/pref
+	@$(MAKE) libs AB_CD=$* XPI_NAME=locale-$* PREF_DIR=defaults/pref/$(ANDROID_CPU_ARCH)
 	@$(MAKE) -C $(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/locales AB_CD=$* XPI_NAME=locale-$*
 
 # Tailored target to just add the chrome processing for multi-locale builds
 chrome-%: AB_CD=$*
 chrome-%:
 	@$(MAKE) chrome AB_CD=$*
 	@$(MAKE) -C $(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/locales chrome AB_CD=$*
--- a/modules/libpref/moz.build
+++ b/modules/libpref/moz.build
@@ -44,11 +44,14 @@ include('/ipc/chromium/chromium-config.m
 
 FINAL_LIBRARY = 'xul'
 
 DEFINES['OS_ARCH'] = CONFIG['OS_ARCH']
 DEFINES['MOZ_WIDGET_TOOLKIT'] = CONFIG['MOZ_WIDGET_TOOLKIT']
 if CONFIG['MOZ_ENABLE_WEBRENDER']:
     DEFINES['MOZ_ENABLE_WEBRENDER'] = True
 
-FINAL_TARGET_PP_FILES += [
+grepref_location = FINAL_TARGET_PP_FILES
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
+    grepref_location = grepref_location[CONFIG['ANDROID_CPU_ARCH']]
+grepref_location += [
     'greprefs.js',
 ]
--- a/python/mozbuild/mozbuild/frontend/context.py
+++ b/python/mozbuild/mozbuild/frontend/context.py
@@ -2331,16 +2331,30 @@ FUNCTIONS = {
 
         """),
 }
 
 
 TestDirsPlaceHolder = List()
 
 
+def default_prefs_for(context, var):
+    """Return default location for pref files.
+
+On Android, the location varies by architecture to accommodate "fat
+AAR" packages that contain native libraries for multiple architectures
+and must have corresponding architecture-specific Gecko preferences."""
+
+    arch = context.config.substs.get('ANDROID_CPU_ARCH')
+    if arch:
+        return context[var].defaults.pref[arch]
+    else:
+        return context[var].defaults.pref
+
+
 # Special variables. These complement VARIABLES.
 #
 # Each entry is a tuple of:
 #
 #  (function returning the corresponding value from a given context, type, docs)
 #
 SPECIAL_VARIABLES = {
     'TOPSRCDIR': (lambda context: context.config.topsrcdir, str,
@@ -2402,25 +2416,25 @@ SPECIAL_VARIABLES = {
 
     'EXTRA_PP_COMPONENTS': (lambda context: context['FINAL_TARGET_PP_FILES'].components._strings, list,
         """Javascript XPCOM files.
 
        This variable contains a list of files to preprocess.  Generated
        files will be installed in the ``/components`` directory of the distribution.
         """),
 
-    'JS_PREFERENCE_FILES': (lambda context: context['FINAL_TARGET_FILES'].defaults.pref._strings, list,
+    'JS_PREFERENCE_FILES': (lambda context: default_prefs_for(context, 'FINAL_TARGET_FILES')._strings, list,
         """Exported JavaScript files.
 
         A list of files copied into the dist directory for packaging and installation.
         Path will be defined for gre or application prefs dir based on what is building.
         """),
 
-    'JS_PREFERENCE_PP_FILES': (lambda context: context['FINAL_TARGET_PP_FILES'].defaults.pref._strings, list,
-        """Like JS_PREFERENCE_FILES, preprocessed..
+    'JS_PREFERENCE_PP_FILES': (lambda context: default_prefs_for(context, 'FINAL_TARGET_PP_FILES')._strings, list,
+        """Like JS_PREFERENCE_FILES, preprocessed.
         """),
 
     'RESOURCE_FILES': (lambda context: context['FINAL_TARGET_FILES'].res, list,
         """List of resources to be exported, and in which subdirectories.
 
         ``RESOURCE_FILES`` is used to list the resource files to be exported to
         ``dist/bin/res``, but it can be used for other files as well. This variable
         behaves as a list when appending filenames for resources in the top-level
--- a/python/mozbuild/mozpack/packager/formats.py
+++ b/python/mozbuild/mozpack/packager/formats.py
@@ -323,18 +323,20 @@ class OmniJarSubFormatter(PiecemealForma
             return len(path) == 1 or \
                 (path[1] != 'cursors' and
                  path[1] != 'touchbar' and
                  path[1] != 'MainMenu.nib')
         if path[0] == 'defaults':
             return len(path) != 3 or \
                 not (path[2] == 'channel-prefs.js' and
                      path[1] in ['pref', 'preferences'])
+        if len(path) <= 2 and path[-1] == 'greprefs.js':
+            # Accommodate `greprefs.js` and `$ANDROID_CPU_ARCH/greprefs.js`.
+            return True
         return path[0] in [
             'modules',
             'actors',
             'dictionaries',
-            'greprefs.js',
             'hyphenation',
             'localization',
             'update.locale',
             'contentaccessible',
         ]