Bug 910660 - Make the SimplePackager emit a separate base for addons. r=gps, a=sledru
Addons are detected by the presence of an install.rdf file in their base.
This commit is contained in:
@@ -234,6 +234,8 @@ class SimplePackager(object):
|
|||||||
self._chrome_queue = CallDeque()
|
self._chrome_queue = CallDeque()
|
||||||
# Queue for formatter.add() calls.
|
# Queue for formatter.add() calls.
|
||||||
self._file_queue = CallDeque()
|
self._file_queue = CallDeque()
|
||||||
|
# All paths containing addons.
|
||||||
|
self._addons = set()
|
||||||
# All manifest paths imported.
|
# All manifest paths imported.
|
||||||
self._manifests = set()
|
self._manifests = set()
|
||||||
# All manifest paths included from some other manifest.
|
# All manifest paths included from some other manifest.
|
||||||
@@ -251,6 +253,8 @@ class SimplePackager(object):
|
|||||||
self._queue.append(self.formatter.add_interfaces, path, file)
|
self._queue.append(self.formatter.add_interfaces, path, file)
|
||||||
else:
|
else:
|
||||||
self._file_queue.append(self.formatter.add, path, file)
|
self._file_queue.append(self.formatter.add, path, file)
|
||||||
|
if mozpack.path.basename(path) == 'install.rdf':
|
||||||
|
self._addons.add(mozpack.path.dirname(path))
|
||||||
|
|
||||||
def _add_manifest_file(self, path, file):
|
def _add_manifest_file(self, path, file):
|
||||||
'''
|
'''
|
||||||
@@ -278,22 +282,33 @@ class SimplePackager(object):
|
|||||||
'"manifest" entries')
|
'"manifest" entries')
|
||||||
self._included_manifests.add(e.path)
|
self._included_manifests.add(e.path)
|
||||||
|
|
||||||
def get_bases(self):
|
def get_bases(self, addons=True):
|
||||||
'''
|
'''
|
||||||
Return all paths under which root manifests have been found. Root
|
Return all paths under which root manifests have been found. Root
|
||||||
manifests are manifests that are included in no other manifest.
|
manifests are manifests that are included in no other manifest.
|
||||||
|
`addons` indicates whether to include addon bases as well.
|
||||||
'''
|
'''
|
||||||
return set(mozpack.path.dirname(m)
|
all_bases = set(mozpack.path.dirname(m)
|
||||||
for m in self._manifests - self._included_manifests)
|
for m in self._manifests - self._included_manifests)
|
||||||
|
if not addons:
|
||||||
|
all_bases -= self._addons
|
||||||
|
return all_bases
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
'''
|
'''
|
||||||
Push all instructions to the formatter.
|
Push all instructions to the formatter.
|
||||||
'''
|
'''
|
||||||
self._closed = True
|
self._closed = True
|
||||||
|
broken_addons = sorted(m for m in self._included_manifests
|
||||||
|
if mozpack.path.dirname(m) in self._addons)
|
||||||
|
if broken_addons:
|
||||||
|
errors.fatal(
|
||||||
|
'Addon base manifest (%s) is included in some other manifest' %
|
||||||
|
', '.join(broken_addons)
|
||||||
|
)
|
||||||
for base in self.get_bases():
|
for base in self.get_bases():
|
||||||
if base:
|
if base:
|
||||||
self.formatter.add_base(base)
|
self.formatter.add_base(base, base in self._addons)
|
||||||
self._chrome_queue.execute()
|
self._chrome_queue.execute()
|
||||||
self._queue.execute()
|
self._queue.execute()
|
||||||
self._file_queue.execute()
|
self._file_queue.execute()
|
||||||
|
|||||||
@@ -171,6 +171,16 @@ class TestSimplePackager(unittest.TestCase):
|
|||||||
with errors.context('manifest', 7):
|
with errors.context('manifest', 7):
|
||||||
packager.add('foo/qux.xpt', qux_xpt)
|
packager.add('foo/qux.xpt', qux_xpt)
|
||||||
|
|
||||||
|
file = GeneratedFileWithPath(os.path.join(curdir, 'addon',
|
||||||
|
'chrome.manifest'),
|
||||||
|
'resource hoge hoge/')
|
||||||
|
with errors.context('manifest', 8):
|
||||||
|
packager.add('addon/chrome.manifest', file)
|
||||||
|
|
||||||
|
install_rdf = GeneratedFile('<RDF></RDF>')
|
||||||
|
with errors.context('manifest', 9):
|
||||||
|
packager.add('addon/install.rdf', install_rdf)
|
||||||
|
|
||||||
self.assertEqual(formatter.log, [])
|
self.assertEqual(formatter.log, [])
|
||||||
|
|
||||||
with errors.context('dummy', 1):
|
with errors.context('dummy', 1):
|
||||||
@@ -179,7 +189,8 @@ class TestSimplePackager(unittest.TestCase):
|
|||||||
# The formatter is expected to reorder the manifest entries so that
|
# The formatter is expected to reorder the manifest entries so that
|
||||||
# chrome entries appear before the others.
|
# chrome entries appear before the others.
|
||||||
self.assertEqual(formatter.log, [
|
self.assertEqual(formatter.log, [
|
||||||
(('dummy', 1), 'add_base', 'qux'),
|
(('dummy', 1), 'add_base', 'qux', False),
|
||||||
|
(('dummy', 1), 'add_base', 'addon', True),
|
||||||
((os.path.join(curdir, 'foo', 'bar.manifest'), 2),
|
((os.path.join(curdir, 'foo', 'bar.manifest'), 2),
|
||||||
'add_manifest', ManifestContent('foo', 'bar', 'bar/')),
|
'add_manifest', ManifestContent('foo', 'bar', 'bar/')),
|
||||||
((os.path.join(curdir, 'foo', 'bar.manifest'), 1),
|
((os.path.join(curdir, 'foo', 'bar.manifest'), 1),
|
||||||
@@ -190,11 +201,15 @@ class TestSimplePackager(unittest.TestCase):
|
|||||||
'add_manifest', ManifestResource('qux', 'qux', 'qux/')),
|
'add_manifest', ManifestResource('qux', 'qux', 'qux/')),
|
||||||
(('manifest', 4), 'add_interfaces', 'foo/bar.xpt', bar_xpt),
|
(('manifest', 4), 'add_interfaces', 'foo/bar.xpt', bar_xpt),
|
||||||
(('manifest', 7), 'add_interfaces', 'foo/qux.xpt', qux_xpt),
|
(('manifest', 7), 'add_interfaces', 'foo/qux.xpt', qux_xpt),
|
||||||
|
((os.path.join(curdir, 'addon', 'chrome.manifest'), 1),
|
||||||
|
'add_manifest', ManifestResource('addon', 'hoge', 'hoge/')),
|
||||||
(('manifest', 5), 'add', 'foo/bar/foo.html', foo_html),
|
(('manifest', 5), 'add', 'foo/bar/foo.html', foo_html),
|
||||||
(('manifest', 5), 'add', 'foo/bar/bar.html', bar_html),
|
(('manifest', 5), 'add', 'foo/bar/bar.html', bar_html),
|
||||||
|
(('manifest', 9), 'add', 'addon/install.rdf', install_rdf),
|
||||||
])
|
])
|
||||||
|
|
||||||
self.assertEqual(packager.get_bases(), set(['', 'qux']))
|
self.assertEqual(packager.get_bases(), set(['', 'addon', 'qux']))
|
||||||
|
self.assertEqual(packager.get_bases(addons=False), set(['', 'qux']))
|
||||||
|
|
||||||
|
|
||||||
class TestSimpleManifestSink(unittest.TestCase):
|
class TestSimpleManifestSink(unittest.TestCase):
|
||||||
|
|||||||
@@ -214,8 +214,8 @@ class NoPkgFilesRemover(object):
|
|||||||
self._error = errors.warn
|
self._error = errors.warn
|
||||||
self._msg = 'Skipping %s'
|
self._msg = 'Skipping %s'
|
||||||
|
|
||||||
def add_base(self, base):
|
def add_base(self, base, *args):
|
||||||
self._formatter.add_base(base)
|
self._formatter.add_base(base, *args)
|
||||||
|
|
||||||
def add(self, path, content):
|
def add(self, path, content):
|
||||||
if not any(mozpack.path.match(path, spec) for spec in self._files):
|
if not any(mozpack.path.match(path, spec) for spec in self._files):
|
||||||
@@ -382,9 +382,13 @@ def main():
|
|||||||
'bin')
|
'bin')
|
||||||
else:
|
else:
|
||||||
gre_path = None
|
gre_path = None
|
||||||
for base in sorted([[p for p in [mozpack.path.join('bin', b), b]
|
def get_bases():
|
||||||
if os.path.exists(os.path.join(args.source, p))][0]
|
for b in sink.packager.get_bases(addons=False):
|
||||||
for b in sink.packager.get_bases()]):
|
for p in (mozpack.path.join('bin', b), b):
|
||||||
|
if os.path.exists(os.path.join(args.source, p)):
|
||||||
|
yield p
|
||||||
|
break
|
||||||
|
for base in sorted(get_bases()):
|
||||||
if not gre_path:
|
if not gre_path:
|
||||||
gre_path = base
|
gre_path = base
|
||||||
base_path = sink.normalize_path(base)
|
base_path = sink.normalize_path(base)
|
||||||
|
|||||||
Reference in New Issue
Block a user