From 3dce09e76f313b7987ce239008c01bcf81abdf65 Mon Sep 17 00:00:00 2001 From: Nick Alexander Date: Wed, 27 Mar 2019 17:35:26 +0000 Subject: [PATCH] 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 --HG-- extra : moz-landing-system : lando --- config/rules.mk | 8 ++++++-- mobile/android/installer/package-manifest.in | 4 ++-- mobile/android/locales/Makefile.in | 2 +- mobile/locales/Makefile.in | 2 +- modules/libpref/moz.build | 5 ++++- python/mozbuild/mozbuild/frontend/context.py | 20 +++++++++++++++++--- python/mozbuild/mozpack/packager/formats.py | 4 +++- 7 files changed, 34 insertions(+), 11 deletions(-) diff --git a/config/rules.mk b/config/rules.mk index e96f75427915..5a4b3e570ed9 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -967,13 +967,17 @@ 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 ################################################################################ diff --git a/mobile/android/installer/package-manifest.in b/mobile/android/installer/package-manifest.in index 59520381e1fd..06998b0e5655 100644 --- a/mobile/android/installer/package-manifest.in +++ b/mobile/android/installer/package-manifest.in @@ -164,7 +164,7 @@ #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] @@ -260,7 +260,7 @@ @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 diff --git a/mobile/android/locales/Makefile.in b/mobile/android/locales/Makefile.in index 3da01d973fac..996b4d89a4b1 100644 --- a/mobile/android/locales/Makefile.in +++ b/mobile/android/locales/Makefile.in @@ -43,7 +43,7 @@ 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-$* diff --git a/mobile/locales/Makefile.in b/mobile/locales/Makefile.in index 51fb10eea4ab..d7502fd2694b 100644 --- a/mobile/locales/Makefile.in +++ b/mobile/locales/Makefile.in @@ -20,7 +20,7 @@ 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 diff --git a/modules/libpref/moz.build b/modules/libpref/moz.build index 25f7d9869d10..249d866119c8 100644 --- a/modules/libpref/moz.build +++ b/modules/libpref/moz.build @@ -49,6 +49,9 @@ 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', ] diff --git a/python/mozbuild/mozbuild/frontend/context.py b/python/mozbuild/mozbuild/frontend/context.py index f6cbcb0764e7..8ef8c175fe90 100644 --- a/python/mozbuild/mozbuild/frontend/context.py +++ b/python/mozbuild/mozbuild/frontend/context.py @@ -2336,6 +2336,20 @@ 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: @@ -2407,15 +2421,15 @@ SPECIAL_VARIABLES = { 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, diff --git a/python/mozbuild/mozpack/packager/formats.py b/python/mozbuild/mozpack/packager/formats.py index 1295c9155b40..f1ed2c340969 100644 --- a/python/mozbuild/mozpack/packager/formats.py +++ b/python/mozbuild/mozpack/packager/formats.py @@ -328,11 +328,13 @@ class OmniJarSubFormatter(PiecemealFormatter): 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',