Bug 802254 - Add support for multiple app dirs in add-on packaging (mc bits), r=glandium
authorJim Mathies <jmathies@mozilla.com>
Wed, 06 Feb 2013 15:21:32 -0600
changeset 121123 62b7e0a68a11d906fb1b0e37984a735959cdbe54
parent 121122 f21da1055c468cc998cec3815d2ac9364b7ca762
child 121124 1010b6f16db40fc4c84663478ddd054ec20199e6
push id22602
push userjmathies@mozilla.com
push dateThu, 07 Feb 2013 13:54:07 +0000
treeherdermozilla-inbound@62b7e0a68a11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs802254
milestone21.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 802254 - Add support for multiple app dirs in add-on packaging (mc bits), r=glandium
config/JarMaker.py
config/rules.mk
js/src/config/rules.mk
toolkit/locales/l10n.mk
--- a/config/JarMaker.py
+++ b/config/JarMaker.py
@@ -76,16 +76,17 @@ class JarMaker(object):
     self.useChromeManifest = useChromeManifest
     self.pp = Preprocessor()
     self.topsourcedir = None
     self.sourcedirs = []
     self.localedirs = None
     self.l10nbase = None
     self.l10nmerge = None
     self.relativesrcdir = None
+    self.rootManifestAppId = None
 
   def getCommandLineParser(self):
     '''Get a optparse.OptionParser for jarmaker.
 
     This OptionParser has the options for jarmaker as well as
     the options for the inner PreProcessor.
     '''
     # HACK, we need to unescape the string variables we get,
@@ -112,16 +113,18 @@ class JarMaker(object):
     p.add_option('--l10n-base', type="string", action="store",
                  help="base directory to be used for localization (requires relativesrcdir)")
     p.add_option('--locale-mergedir', type="string", action="store",
                  help="base directory to be used for l10n-merge (requires l10n-base and relativesrcdir)")
     p.add_option('--relativesrcdir', type="string",
                  help="relativesrcdir to be used for localization")
     p.add_option('-j', type="string",
                  help="jarfile directory")
+    p.add_option('--root-manifest-entry-appid', type="string",
+                 help="add an app id specific root chrome manifest entry.")
     return p
 
   def processIncludes(self, includes):
     '''Process given includes with the inner PreProcessor.
 
     Only use this for #defines, the includes shouldn't generate
     content.
     '''
@@ -151,16 +154,27 @@ class JarMaker(object):
     if self.useJarfileManifest:
       self.updateManifest(jarPath + '.manifest', chromebasepath % '',
                           register)
       addEntriesToListFile(chromeManifest, ['manifest chrome/%s.manifest' % (os.path.basename(jarPath),)])
     if self.useChromeManifest:
       self.updateManifest(chromeManifest, chromebasepath % 'chrome/',
                           register)
 
+    # If requested, add a root chrome manifest entry (assumed to be in the parent directory
+    # of chromeManifest) with the application specific id. In cases where we're building
+    # lang packs, the root manifest must know about application sub directories.
+    if self.rootManifestAppId:
+      rootChromeManifest = os.path.join(os.path.normpath(os.path.dirname(chromeManifest)),
+                                        '..', 'chrome.manifest')
+      rootChromeManifest = os.path.normpath(rootChromeManifest)
+      chromeDir = os.path.basename(os.path.dirname(os.path.normpath(chromeManifest)))
+      logging.info("adding '%s' entry to root chrome manifest appid=%s" % (chromeDir, self.rootManifestAppId))
+      addEntriesToListFile(rootChromeManifest, ['manifest %s/chrome.manifest application=%s' % (chromeDir, self.rootManifestAppId)])
+
   def updateManifest(self, manifestPath, chromebasepath, register):
     '''updateManifest replaces the % in the chrome registration entries
     with the given chrome base path, and updates the given manifest file.
     '''
     lock = lockFile(manifestPath + '.lck')
     try:
       myregister = dict.fromkeys(map(lambda s: s.replace('%', chromebasepath),
                                      register.iterkeys()))
@@ -442,16 +456,18 @@ def main():
     if options.l10n_src:
       p.error('both l10n-src and l10n-base are not supported')
     jm.l10nbase = options.l10n_base
     jm.relativesrcdir = options.relativesrcdir
     jm.l10nmerge = options.locale_mergedir
   elif options.locale_mergedir:
     p.error('l10n-base required when using locale-mergedir')
   jm.localedirs = options.l10n_src
+  if options.root_manifest_entry_appid:
+    jm.rootManifestAppId = options.root_manifest_entry_appid
   noise = logging.INFO
   if options.verbose is not None:
     noise = (options.verbose and logging.DEBUG) or logging.WARN
   if sys.version_info[:2] > (2,3):
     logging.basicConfig(format = "%(message)s")
   else:
     logging.basicConfig()
   logging.getLogger().setLevel(noise)
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -1436,21 +1436,38 @@ chrome::
 	$(LOOP_OVER_PARALLEL_DIRS)
 	$(LOOP_OVER_DIRS)
 	$(LOOP_OVER_TOOL_DIRS)
 
 $(FINAL_TARGET)/chrome: $(call mkdir_deps,$(FINAL_TARGET)/chrome)
 
 ifneq (,$(wildcard $(JAR_MANIFEST)))
 ifndef NO_DIST_INSTALL
+
+ifdef XPI_NAME
+# For langpack packaging we may specify that an application
+# sub-dir should be added to the root chrome manifest with
+# a specific application id.
+MAKE_JARS_FLAGS += $(addprefix --root-manifest-entry-appid=,$(XPI_ROOT_APPID))
+
+# 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.)
+endif
+endif
+endif
+
 libs realchrome:: $(CHROME_DEPS) $(FINAL_TARGET)/chrome
 	$(PYTHON) $(MOZILLA_DIR)/config/JarMaker.py \
 	  $(QUIET) -j $(FINAL_TARGET)/chrome \
 	  $(MAKE_JARS_FLAGS) $(XULPPFLAGS) $(DEFINES) $(ACDEFINES) \
 	  $(JAR_MANIFEST)
+
 endif
 endif
 
 ifneq ($(DIST_FILES),)
 DIST_FILES_PATH := $(FINAL_TARGET)
 DIST_FILES_FLAGS := $(XULAPP_DEFINES)
 PP_TARGETS += DIST_FILES
 endif
--- a/js/src/config/rules.mk
+++ b/js/src/config/rules.mk
@@ -1436,21 +1436,38 @@ chrome::
 	$(LOOP_OVER_PARALLEL_DIRS)
 	$(LOOP_OVER_DIRS)
 	$(LOOP_OVER_TOOL_DIRS)
 
 $(FINAL_TARGET)/chrome: $(call mkdir_deps,$(FINAL_TARGET)/chrome)
 
 ifneq (,$(wildcard $(JAR_MANIFEST)))
 ifndef NO_DIST_INSTALL
+
+ifdef XPI_NAME
+# For langpack packaging we may specify that an application
+# sub-dir should be added to the root chrome manifest with
+# a specific application id.
+MAKE_JARS_FLAGS += $(addprefix --root-manifest-entry-appid=,$(XPI_ROOT_APPID))
+
+# 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.)
+endif
+endif
+endif
+
 libs realchrome:: $(CHROME_DEPS) $(FINAL_TARGET)/chrome
 	$(PYTHON) $(MOZILLA_DIR)/config/JarMaker.py \
 	  $(QUIET) -j $(FINAL_TARGET)/chrome \
 	  $(MAKE_JARS_FLAGS) $(XULPPFLAGS) $(DEFINES) $(ACDEFINES) \
 	  $(JAR_MANIFEST)
+
 endif
 endif
 
 ifneq ($(DIST_FILES),)
 DIST_FILES_PATH := $(FINAL_TARGET)
 DIST_FILES_FLAGS := $(XULAPP_DEFINES)
 PP_TARGETS += DIST_FILES
 endif
--- a/toolkit/locales/l10n.mk
+++ b/toolkit/locales/l10n.mk
@@ -142,26 +142,32 @@ repackage-zip-%: $(STAGEDIST)
 	@$(MAKE) repackage-zip AB_CD=$* ZIP_IN="$(ZIP_IN)"
 
 APP_DEFINES = $(firstword $(wildcard $(LOCALE_SRCDIR)/defines.inc) \
                           $(srcdir)/en-US/defines.inc)
 TK_DEFINES = $(firstword \
    $(wildcard $(call EXPAND_LOCALE_SRCDIR,toolkit/locales)/defines.inc) \
    $(MOZILLA_DIR)/toolkit/locales/en-US/defines.inc)
 
+# Dealing with app sub dirs: If DIST_SUBDIRS is defined it contains a
+# listing of app sub-dirs we should include in langpack xpis. If not,
+# check DIST_SUBDIR, and if that isn't present, just package the default
+# chrome directory.
+PKG_ZIP_DIRS = chrome $(or $(DIST_SUBDIRS),$(DIST_SUBDIR))
+
 langpack-%: LANGPACK_FILE=$(_ABS_DIST)/$(PKG_LANGPACK_PATH)$(PKG_LANGPACK_BASENAME).xpi
 langpack-%: AB_CD=$*
 langpack-%: XPI_NAME=locale-$*
 langpack-%: libs-%
 	@echo "Making langpack $(LANGPACK_FILE)"
 	$(NSINSTALL) -D $(DIST)/$(PKG_LANGPACK_PATH)
-	$(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) -I$(TK_DEFINES) -I$(APP_DEFINES) $(srcdir)/generic/install.rdf > $(FINAL_TARGET)/install.rdf
+	$(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) \
+	  -I$(TK_DEFINES) -I$(APP_DEFINES) $(srcdir)/generic/install.rdf > $(DIST)/xpi-stage/$(XPI_NAME)/install.rdf
 	cd $(DIST)/xpi-stage/locale-$(AB_CD) && \
-	  $(ZIP) -r9D $(LANGPACK_FILE) install.rdf chrome chrome.manifest
-
+	  $(ZIP) -r9D $(LANGPACK_FILE) install.rdf $(PKG_ZIP_DIRS) chrome.manifest
 
 # This variable is to allow the wget-en-US target to know which ftp server to download from
 ifndef EN_US_BINARY_URL 
 EN_US_BINARY_URL = $(error You must set EN_US_BINARY_URL)
 endif
 
 # This make target allows us to wget the latest en-US binary from a specified website
 # The make installers-% target needs the en-US binary in dist/