Bug 870396 - Handle XPI_ROOT_APPID in RecursiveMake backend; remove last defs.mk. r?ted.mielczarek draft
authorNick Alexander <nalexander@mozilla.com>
Mon, 28 May 2018 09:20:31 -0700
changeset 800603 9bee9db6132b4edf627e8cba6cf3b6a1a701bb75
parent 800319 4e9446f9e8f0a75c7ffe063f1dfb311cc90d56cf
push id111422
push usernalexander@mozilla.com
push dateMon, 28 May 2018 16:44:08 +0000
reviewersted.mielczarek
bugs870396
milestone62.0a1
Bug 870396 - Handle XPI_ROOT_APPID in RecursiveMake backend; remove last defs.mk. r?ted.mielczarek The rationale is in the comment in recursivemake.py: as best I can tell, _if_ we're using split GRE and app (which everything but mobile/android uses), anything under MOZ_BUILD_APP needs the appid, _and_ everything that registers locale-aware chrome. Right now, the former is handled by defs.mk and the latter is handled by manually passing XPI_ROOT_APPID around in sub-Make invocations. This is better than both of those approaches. With this patch I produce bit-identical langpack XPIs, and the chrome.manifest files in the langpacks really do include the expected appids. MozReview-Commit-ID: 4MZQdVDdpXD
browser/defs.mk
browser/locales/Makefile.in
browser/moz.configure
config/config.mk
config/rules.mk
python/mozbuild/mozbuild/backend/recursivemake.py
deleted file mode 100644
--- a/browser/defs.mk
+++ /dev/null
@@ -1,1 +0,0 @@
-XPI_ROOT_APPID=$(MOZ_APP_ID)
--- a/browser/locales/Makefile.in
+++ b/browser/locales/Makefile.in
@@ -64,27 +64,27 @@ include $(topsrcdir)/toolkit/locales/l10
 $(list-json): $(call mkdir_deps,$(SEARCHPLUGINS_PATH)) $(if $(IS_LANGUAGE_REPACK),FORCE)
 	$(call py_action,generate_searchjson,$(srcdir)/search/list.json $(AB_CD) $(list-json))
 searchplugins:: $(list-json)
 
 libs-%: AB_CD=$*
 libs-%:
 	$(if $(filter en-US,$(AB_CD)),, @$(MAKE) merge-$*)
 	$(NSINSTALL) -D $(DIST)/install
-	@$(MAKE) -C ../../toolkit/locales libs-$* XPI_ROOT_APPID='$(XPI_ROOT_APPID)'
+	@$(MAKE) -C ../../toolkit/locales libs-$*
 	@$(MAKE) -C ../../services/sync/locales AB_CD=$* XPI_NAME=locale-$*
 	@$(MAKE) -C ../../extensions/spellcheck/locales AB_CD=$* XPI_NAME=locale-$*
 ifneq (,$(wildcard ../extensions/formautofill/locales))
 	@$(MAKE) -C ../extensions/formautofill/locales AB_CD=$* XPI_NAME=locale-$*
 endif
 	@$(MAKE) -C ../extensions/onboarding/locales AB_CD=$* XPI_NAME=locale-$*
 	@$(MAKE) -C ../extensions/pocket/locale AB_CD=$* XPI_NAME=locale-$*
 	@$(MAKE) -C ../extensions/webcompat-reporter/locales AB_CD=$* XPI_NAME=locale-$*
-	@$(MAKE) -C ../../devtools/client/locales AB_CD=$* XPI_NAME=locale-$* XPI_ROOT_APPID='$(XPI_ROOT_APPID)'
-	@$(MAKE) -C ../../devtools/startup/locales AB_CD=$* XPI_NAME=locale-$* XPI_ROOT_APPID='$(XPI_ROOT_APPID)'
+	@$(MAKE) -C ../../devtools/client/locales AB_CD=$* XPI_NAME=locale-$*
+	@$(MAKE) -C ../../devtools/startup/locales AB_CD=$* XPI_NAME=locale-$*
 	@$(MAKE) -B searchplugins AB_CD=$* XPI_NAME=locale-$*
 	@$(MAKE) libs AB_CD=$* XPI_NAME=locale-$* PREF_DIR=$(PREF_DIR)
 	@$(MAKE) multilocale.txt-$* AB_CD=$* XPI_NAME=locale-$*
 	@$(MAKE) -C $(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/locales AB_CD=$* XPI_NAME=locale-$*
 
 chrome-%: AB_CD=$*
 chrome-%: IS_LANGUAGE_REPACK=1
 chrome-%:
--- a/browser/moz.configure
+++ b/browser/moz.configure
@@ -4,8 +4,16 @@
 # 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/.
 
 imply_option('MOZ_PLACES', True)
 imply_option('MOZ_SERVICES_HEALTHREPORT', True)
 imply_option('MOZ_SERVICES_SYNC', True)
 
 include('../toolkit/moz.configure')
+
+
+@dependable
+def xpi_root_appid():
+    return '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}'
+
+
+set_config('XPI_ROOT_APPID', xpi_root_appid)
--- a/config/config.mk
+++ b/config/config.mk
@@ -40,28 +40,16 @@ ifndef STANDALONE_MAKEFILE
 GLOBAL_DEPS += backend.mk
 include backend.mk
 endif
 
 endif
 
 space = $(NULL) $(NULL)
 
-# Include defs.mk files that can be found in $(srcdir)/$(DEPTH),
-# $(srcdir)/$(DEPTH-1), $(srcdir)/$(DEPTH-2), etc., and $(srcdir)
-# where $(DEPTH-1) is one level less of depth, $(DEPTH-2), two, etc.
-# i.e. for DEPTH=../../.., DEPTH-1 is ../.. and DEPTH-2 is ..
-# These defs.mk files are used to define variables in a directory
-# and all its subdirectories, recursively.
-__depth := $(subst /, ,$(DEPTH))
-ifeq (.,$(__depth))
-__depth :=
-endif
-$(foreach __d,$(__depth) .,$(eval __depth = $(wordlist 2,$(words $(__depth)),$(__depth))$(eval -include $(subst $(space),/,$(strip $(srcdir) $(__depth) defs.mk)))))
-
 COMMA = ,
 
 # Sanity check some variables
 CHECK_VARS := \
  XPI_NAME \
  LIBRARY_NAME \
  MODULE \
  DEPTH \
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -1221,17 +1221,17 @@ ifdef XPI_ROOT_APPID
 # a specific application id.
 MAKE_JARS_FLAGS += --root-manifest-entry-appid='$(XPI_ROOT_APPID)'
 endif
 
 # if DIST_SUBDIR is defined but XPI_ROOT_APPID is not there's
 # no way langpacks will get packaged right, so error out.
 ifneq (,$(DIST_SUBDIR))
 ifndef XPI_ROOT_APPID
-$(error XPI_ROOT_APPID is not defined - langpacks will break.)
+$(error XPI_ROOT_APPID is not defined in $(CURDIR) - langpacks will break.)
 endif
 endif
 endif
 
 libs realchrome:: $(FINAL_TARGET)/chrome
 	$(call py_action,jar_maker,\
 	  $(QUIET) -d $(FINAL_TARGET) \
 	  $(MAKE_JARS_FLAGS) $(DEFINES) $(ACDEFINES) \
--- a/python/mozbuild/mozbuild/backend/recursivemake.py
+++ b/python/mozbuild/mozbuild/backend/recursivemake.py
@@ -607,16 +607,38 @@ class RecursiveMakeBackend(CommonBackend
            locale='--locale=$(AB_CD) ' if obj.localized else '',
            script=obj.script,
            method=obj.method))
 
         elif isinstance(obj, JARManifest):
             self._no_skip['libs'].add(backend_file.relobjdir)
             backend_file.write('JAR_MANIFEST := %s\n' % obj.path.full_path)
 
+            # If the application has a root appid (all applications save
+            # mobile/android do), and either:
+            # - the jar manifest is under the application directory; or
+            # - the manifest registers locale-aware chrome
+            # then it needs to declare its root appid.
+            def needs_xpi_root_appid(path):
+                relpath = mozpath.relpath(path, self.environment.topsrcdir)
+                if relpath.split()[0] == self.environment.substs['MOZ_BUILD_APP']:
+                    return True
+
+                if re.search(r'^\%\s+locale',
+                             open(path, 'rt').read(),
+                             re.MULTILINE):
+                    return True
+
+                return False
+
+            if 'XPI_ROOT_APPID' in self.environment.substs:
+                if needs_xpi_root_appid(obj.path.full_path):
+                    backend_file.write('XPI_ROOT_APPID := %s\n' %
+                                       (self.environment.substs['XPI_ROOT_APPID']))
+
         elif isinstance(obj, RustProgram):
             self._process_rust_program(obj, backend_file)
             # Hook the program into the compile graph.
             build_target = self._build_target_for_obj(obj)
             self._compile_graph[build_target]
 
         elif isinstance(obj, HostRustProgram):
             self._process_host_rust_program(obj, backend_file)