mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 1212773 - Extend jar maker syntax for jar file location. r=gps
Indicating a jar currently looks like the following in a jar manifest: path/to/name.jar: The `path/to` doesn't contain the implicit "chrome/" directory. This, in turn, doesn't allow much flexibility to use the jar maker for what is not necessarily under chrome/. To use the jar maker to fill some chrome manifest for the default theme extension, we currently use a hackish path to get to the right location, and rely on the chrome.manifest file in the parent directory never to be picked by the package manifest, which is a quite horrible way to do this, but worked well enough for that specific use case. With the need to handle system addons at the build system level, it becomes necessary to come up with something less hackish. What this change introduces is an additional syntax for the jar manifest, in the following form: [base/path] sub/path/to/name.jar: Using this syntax, there is no implicit 'chrome' path. The `base/path` is relative to the current DIST_SUBDIR, and the `sub/path` is relative to that `base/path`. The distinction can be useful for build system backends. The assumption that the "root" chrome.manifest is in the parent directory of the implicit "chrome" directory dies, and the `base/path` is where the root chrome.manifest is placed.
This commit is contained in:
parent
a8bec728dc
commit
223417d648
@ -166,7 +166,7 @@ browser.jar:
|
||||
skin/classic/browser/e10s-64@2x.png (../shared/e10s-64@2x.png)
|
||||
#endif
|
||||
|
||||
../extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/chrome.jar:
|
||||
[extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}] chrome.jar:
|
||||
% override chrome://browser/skin/feeds/audioFeedIcon.png chrome://browser/skin/feeds/feedIcon.png
|
||||
% override chrome://browser/skin/feeds/audioFeedIcon16.png chrome://browser/skin/feeds/feedIcon16.png
|
||||
% override chrome://browser/skin/feeds/videoFeedIcon.png chrome://browser/skin/feeds/feedIcon.png
|
||||
|
@ -275,7 +275,7 @@ browser.jar:
|
||||
skin/classic/browser/e10s-64@2x.png (../shared/e10s-64@2x.png)
|
||||
#endif
|
||||
|
||||
../extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/chrome.jar:
|
||||
[extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}] chrome.jar:
|
||||
% override chrome://browser/skin/feeds/audioFeedIcon.png chrome://browser/skin/feeds/feedIcon.png
|
||||
% override chrome://browser/skin/feeds/audioFeedIcon16.png chrome://browser/skin/feeds/feedIcon16.png
|
||||
% override chrome://browser/skin/feeds/videoFeedIcon.png chrome://browser/skin/feeds/feedIcon.png
|
||||
|
@ -285,7 +285,7 @@ browser.jar:
|
||||
skin/classic/browser/e10s-64@2x.png (../shared/e10s-64@2x.png)
|
||||
#endif
|
||||
|
||||
../extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/chrome.jar:
|
||||
[extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}] chrome.jar:
|
||||
% override chrome://browser/skin/page-livemarks.png chrome://browser/skin/feeds/feedIcon16.png
|
||||
% override chrome://browser/skin/feeds/audioFeedIcon.png chrome://browser/skin/feeds/feedIcon.png
|
||||
% override chrome://browser/skin/feeds/audioFeedIcon16.png chrome://browser/skin/feeds/feedIcon16.png
|
||||
|
@ -31,6 +31,13 @@ To ship chrome files in a JAR, an indented line indicates a file to be packaged:
|
||||
<jarfile>.jar:
|
||||
path/in/jar/file_name.xul (source/tree/location/file_name.xul)
|
||||
|
||||
The JAR location may be preceded with a base path between square brackets::
|
||||
[base/path] <jarfile>.jar:
|
||||
path/in/jar/file_name.xul (source/tree/location/file_name.xul)
|
||||
|
||||
In this case, the jar will be directly located under the given ``base/bath``,
|
||||
while without a base path, it will be under a ``chrome`` directory.
|
||||
|
||||
If the JAR manifest and packaged file live in the same directory, the path and
|
||||
parenthesis can be omitted. In other words, the following two lines are
|
||||
equivalent::
|
||||
|
@ -210,15 +210,8 @@ class FasterMakeBackend(CommonBackend):
|
||||
|
||||
for jarinfo in pp.out:
|
||||
install_target = obj.install_target
|
||||
# Bug 1150417 added some gross hacks, which we don't try to
|
||||
# support generically. Fortunately, the hacks don't define more
|
||||
# than chrome manifest entries, so just assume we don't get
|
||||
# any installation entries.
|
||||
if jarinfo.name.startswith('../'):
|
||||
assert not jarinfo.entries
|
||||
|
||||
base = mozpath.join('chrome', jarinfo.name)
|
||||
|
||||
if jarinfo.base:
|
||||
install_target = mozpath.join(install_target, jarinfo.base)
|
||||
for e in jarinfo.entries:
|
||||
if e.is_locale:
|
||||
src = mozpath.join(
|
||||
@ -241,11 +234,11 @@ class FasterMakeBackend(CommonBackend):
|
||||
yield p + '/'
|
||||
prefix = ''.join(_prefix(src))
|
||||
|
||||
self._install_manifests[obj.install_target] \
|
||||
self._install_manifests[install_target] \
|
||||
.add_pattern_symlink(
|
||||
prefix,
|
||||
src[len(prefix):],
|
||||
mozpath.join(base, e.output))
|
||||
mozpath.join(jarinfo.name, e.output))
|
||||
continue
|
||||
|
||||
if not os.path.exists(src):
|
||||
@ -261,7 +254,7 @@ class FasterMakeBackend(CommonBackend):
|
||||
# it, but it's how it works in the recursive make,
|
||||
# not that anything relies on that, but it's simpler.
|
||||
src = mozpath.join(obj.objdir, e.source)
|
||||
self._dependencies['install-%s' % obj.install_target] \
|
||||
self._dependencies['install-%s' % install_target] \
|
||||
.append(mozpath.relpath(
|
||||
src, self.environment.topobjdir))
|
||||
|
||||
@ -272,26 +265,26 @@ class FasterMakeBackend(CommonBackend):
|
||||
self._add_preprocess(
|
||||
obj,
|
||||
src,
|
||||
mozpath.join(base, mozpath.dirname(e.output)),
|
||||
mozpath.join(jarinfo.name, mozpath.dirname(e.output)),
|
||||
mozpath.basename(e.output),
|
||||
defines=defines,
|
||||
**kwargs)
|
||||
else:
|
||||
self._install_manifests[obj.install_target].add_symlink(
|
||||
self._install_manifests[install_target].add_symlink(
|
||||
src,
|
||||
mozpath.join(base, e.output))
|
||||
mozpath.join(jarinfo.name, e.output))
|
||||
|
||||
manifest = mozpath.normpath(mozpath.join(obj.install_target, base))
|
||||
manifest = mozpath.normpath(mozpath.join(install_target,
|
||||
jarinfo.name))
|
||||
manifest += '.manifest'
|
||||
for m in jarinfo.chrome_manifests:
|
||||
self._manifest_entries[manifest].append(
|
||||
m.replace('%', jarinfo.name + '/'))
|
||||
m.replace('%', mozpath.basename(jarinfo.name) + '/'))
|
||||
|
||||
# ../ special cased for bug 1150417 again.
|
||||
if not jarinfo.name.startswith('../'):
|
||||
manifest = mozpath.normpath(mozpath.join(obj.install_target,
|
||||
if jarinfo.name != 'chrome':
|
||||
manifest = mozpath.normpath(mozpath.join(install_target,
|
||||
'chrome.manifest'))
|
||||
entry = 'manifest %s.manifest' % base
|
||||
entry = 'manifest %s.manifest' % jarinfo.name
|
||||
if entry not in self._manifest_entries[manifest]:
|
||||
self._manifest_entries[manifest].append(entry)
|
||||
|
||||
|
@ -79,8 +79,19 @@ class JarManifestEntry(object):
|
||||
|
||||
|
||||
class JarInfo(object):
|
||||
def __init__(self, name):
|
||||
def __init__(self, base_or_jarinfo, name=None):
|
||||
if name is None:
|
||||
assert isinstance(base_or_jarinfo, JarInfo)
|
||||
self.base = base_or_jarinfo.base
|
||||
self.name = base_or_jarinfo.name
|
||||
else:
|
||||
assert not isinstance(base_or_jarinfo, JarInfo)
|
||||
self.base = base_or_jarinfo or ''
|
||||
self.name = name
|
||||
# For compatibility with existing jar.mn files, if there is no
|
||||
# base, the jar name is under chrome/
|
||||
if not self.base:
|
||||
self.name = mozpath.join('chrome', self.name)
|
||||
self.relativesrcdir = None
|
||||
self.chrome_manifests = []
|
||||
self.entries = []
|
||||
@ -89,7 +100,14 @@ class JarInfo(object):
|
||||
class JarManifestParser(object):
|
||||
|
||||
ignore = re.compile('\s*(\#.*)?$')
|
||||
jarline = re.compile('(?:(?P<jarfile>[\w\d.\-\_\\\/{}]+).jar\:)|(?:\s*(\#.*)?)\s*$')
|
||||
jarline = re.compile('''
|
||||
(?:
|
||||
(?:\[(?P<base>[\w\d.\-\_\\\/{}]+)\]\s*)? # optional [base/path]
|
||||
(?P<jarfile>[\w\d.\-\_\\\/{}]+).jar\: # filename.jar:
|
||||
|
|
||||
(?:\s*(\#.*)?) # comment
|
||||
)\s*$ # whitespaces
|
||||
''', re.VERBOSE)
|
||||
relsrcline = re.compile('relativesrcdir\s+(?P<relativesrcdir>.+?):')
|
||||
regline = re.compile('\%\s+(.*)$')
|
||||
entryre = '(?P<optPreprocess>\*)?(?P<optOverwrite>\+?)\s+'
|
||||
@ -110,13 +128,18 @@ class JarManifestParser(object):
|
||||
|
||||
# A jar manifest file can declare several different sections, each of
|
||||
# which applies to a given "jar file". Each of those sections starts
|
||||
# with "<name>.jar:".
|
||||
# with "<name>.jar:", in which case the path is assumed relative to
|
||||
# a "chrome" directory, or "[<base/path>] <subpath/name>.jar:", where
|
||||
# a base directory is given (usually pointing at the root of the
|
||||
# application or addon) and the jar path is given relative to the base
|
||||
# directory.
|
||||
if self._current_jar is None:
|
||||
m = self.jarline.match(line)
|
||||
if not m:
|
||||
raise RuntimeError(line)
|
||||
if m.group('jarfile'):
|
||||
self._current_jar = JarInfo(m.group('jarfile'))
|
||||
self._current_jar = JarInfo(m.group('base'),
|
||||
m.group('jarfile'))
|
||||
self._jars.append(self._current_jar)
|
||||
return
|
||||
|
||||
@ -128,7 +151,7 @@ class JarManifestParser(object):
|
||||
m = self.relsrcline.match(line)
|
||||
if m:
|
||||
if self._current_jar.chrome_manifests or self._current_jar.entries:
|
||||
self._current_jar = JarInfo(self._current_jar.name)
|
||||
self._current_jar = JarInfo(self._current_jar)
|
||||
self._jars.append(self._current_jar)
|
||||
self._current_jar.relativesrcdir = m.group('relativesrcdir')
|
||||
return
|
||||
@ -250,7 +273,7 @@ class JarMaker(object):
|
||||
logging.info('WARNING: Includes produce non-empty output')
|
||||
self.pp.out = None
|
||||
|
||||
def finalizeJar(self, jarPath, chromebasepath, register, doZip=True):
|
||||
def finalizeJar(self, jardir, jarbase, jarname, chromebasepath, register, doZip=True):
|
||||
'''Helper method to write out the chrome registration entries to
|
||||
jarfile.manifest or chrome.manifest, or both.
|
||||
|
||||
@ -261,18 +284,19 @@ class JarMaker(object):
|
||||
if not register:
|
||||
return
|
||||
|
||||
chromeManifest = os.path.join(os.path.dirname(jarPath), '..',
|
||||
'chrome.manifest')
|
||||
chromeManifest = os.path.join(jardir, jarbase, 'chrome.manifest')
|
||||
|
||||
if self.useJarfileManifest:
|
||||
self.updateManifest(jarPath + '.manifest',
|
||||
self.updateManifest(os.path.join(jardir, jarbase,
|
||||
jarname + '.manifest'),
|
||||
chromebasepath.format(''), register)
|
||||
if jarname != 'chrome':
|
||||
addEntriesToListFile(chromeManifest,
|
||||
['manifest chrome/{0}.manifest'.format(os.path.basename(jarPath))])
|
||||
['manifest {0}.manifest'.format(jarname)])
|
||||
if self.useChromeManifest:
|
||||
chromebase = os.path.dirname(jarname) + '/'
|
||||
self.updateManifest(chromeManifest,
|
||||
chromebasepath.format('chrome/'),
|
||||
register)
|
||||
chromebasepath.format(chromebase), 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
|
||||
@ -378,7 +402,7 @@ class JarMaker(object):
|
||||
chromebasepath = 'jar:' + chromebasepath + '.jar!'
|
||||
chromebasepath += '/'
|
||||
|
||||
jarfile = os.path.join(jardir, 'chrome', jarinfo.name)
|
||||
jarfile = os.path.join(jardir, jarinfo.base, jarinfo.name)
|
||||
jf = None
|
||||
if self.outputFormat == 'jar':
|
||||
# jar
|
||||
@ -400,7 +424,8 @@ class JarMaker(object):
|
||||
for e in jarinfo.entries:
|
||||
self._processEntryLine(e, outHelper, jf)
|
||||
|
||||
self.finalizeJar(jarfile, chromebasepath, jarinfo.chrome_manifests)
|
||||
self.finalizeJar(jardir, jarinfo.base, jarinfo.name, chromebasepath,
|
||||
jarinfo.chrome_manifests)
|
||||
if jf is not None:
|
||||
jf.close()
|
||||
|
||||
|
@ -37,6 +37,6 @@ toolkit.jar:
|
||||
#endif
|
||||
|
||||
#if MOZ_BUILD_APP == browser
|
||||
../browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/chrome.jar:
|
||||
[browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}] chrome.jar:
|
||||
#endif
|
||||
% override chrome://mozapps/skin/passwordmgr/key.png chrome://mozapps/skin/passwordmgr/key-16.png
|
||||
|
@ -186,6 +186,6 @@ toolkit.jar:
|
||||
skin/classic/global/tree/folder@2x.png (tree/folder@2x.png)
|
||||
|
||||
#if MOZ_BUILD_APP == browser
|
||||
../browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/chrome.jar:
|
||||
[browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}] chrome.jar:
|
||||
#endif
|
||||
% override chrome://global/skin/dirListing/local.png chrome://global/skin/dirListing/folder.png
|
||||
|
@ -85,7 +85,7 @@ toolkit.jar:
|
||||
skin/classic/mozapps/handling/handling.css (handling/handling.css)
|
||||
|
||||
#if MOZ_BUILD_APP == browser
|
||||
../browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/chrome.jar:
|
||||
[browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}] chrome.jar:
|
||||
#endif
|
||||
% override chrome://mozapps/skin/extensions/category-extensions.png chrome://mozapps/skin/extensions/extensionGeneric.png
|
||||
% override chrome://mozapps/skin/extensions/category-languages.png chrome://mozapps/skin/extensions/localeGeneric.png
|
||||
|
@ -221,7 +221,7 @@ toolkit.jar:
|
||||
skin/classic/global/tree/twisty-open-XP.png (tree/twisty-open-XP.png)
|
||||
|
||||
#if MOZ_BUILD_APP == browser
|
||||
../browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/chrome.jar:
|
||||
[browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}] chrome.jar:
|
||||
#endif
|
||||
% override chrome://global/skin/console/console-toolbar.png chrome://global/skin/console/console-toolbar-XP.png osversion<6
|
||||
% override chrome://global/skin/dirListing/folder.png chrome://global/skin/dirListing/folder-XP.png osversion<6
|
||||
@ -269,7 +269,7 @@ toolkit.jar:
|
||||
#endif
|
||||
|
||||
#if MOZ_BUILD_APP == browser
|
||||
../browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/chrome.jar:
|
||||
[browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}] chrome.jar:
|
||||
#endif
|
||||
% override chrome://global/skin/arrow/arrow-lft-hov.gif chrome://global/skin/arrow/arrow-lft.gif
|
||||
% override chrome://global/skin/arrow/arrow-rit-hov.gif chrome://global/skin/arrow/arrow-rit.gif
|
||||
|
@ -95,7 +95,7 @@ toolkit.jar:
|
||||
skin/classic/mozapps/update/downloadButtons-XP.png (update/downloadButtons-XP.png)
|
||||
|
||||
#if MOZ_BUILD_APP == browser
|
||||
../browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/chrome.jar:
|
||||
[browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}] chrome.jar:
|
||||
#endif
|
||||
% override chrome://mozapps/skin/downloads/downloadButtons.png chrome://mozapps/skin/downloads/downloadButtons-XP.png osversion<6
|
||||
% override chrome://mozapps/skin/downloads/downloadIcon.png chrome://mozapps/skin/downloads/downloadIcon-XP.png osversion<6
|
||||
@ -116,7 +116,7 @@ toolkit.jar:
|
||||
#endif
|
||||
|
||||
#if MOZ_BUILD_APP == browser
|
||||
../browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/chrome.jar:
|
||||
[browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}] chrome.jar:
|
||||
#endif
|
||||
% override chrome://mozapps/skin/extensions/category-dictionaries.png chrome://mozapps/skin/extensions/dictionaryGeneric.png
|
||||
% override chrome://mozapps/skin/extensions/category-experiments.png chrome://mozapps/skin/extensions/experimentGeneric.png
|
||||
|
Loading…
Reference in New Issue
Block a user