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()
|
||||
# Queue for formatter.add() calls.
|
||||
self._file_queue = CallDeque()
|
||||
# All paths containing addons.
|
||||
self._addons = set()
|
||||
# All manifest paths imported.
|
||||
self._manifests = set()
|
||||
# All manifest paths included from some other manifest.
|
||||
@@ -251,6 +253,8 @@ class SimplePackager(object):
|
||||
self._queue.append(self.formatter.add_interfaces, path, file)
|
||||
else:
|
||||
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):
|
||||
'''
|
||||
@@ -278,22 +282,33 @@ class SimplePackager(object):
|
||||
'"manifest" entries')
|
||||
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
|
||||
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)
|
||||
for m in self._manifests - self._included_manifests)
|
||||
all_bases = set(mozpack.path.dirname(m)
|
||||
for m in self._manifests - self._included_manifests)
|
||||
if not addons:
|
||||
all_bases -= self._addons
|
||||
return all_bases
|
||||
|
||||
def close(self):
|
||||
'''
|
||||
Push all instructions to the formatter.
|
||||
'''
|
||||
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():
|
||||
if base:
|
||||
self.formatter.add_base(base)
|
||||
self.formatter.add_base(base, base in self._addons)
|
||||
self._chrome_queue.execute()
|
||||
self._queue.execute()
|
||||
self._file_queue.execute()
|
||||
|
||||
@@ -171,6 +171,16 @@ class TestSimplePackager(unittest.TestCase):
|
||||
with errors.context('manifest', 7):
|
||||
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, [])
|
||||
|
||||
with errors.context('dummy', 1):
|
||||
@@ -179,7 +189,8 @@ class TestSimplePackager(unittest.TestCase):
|
||||
# The formatter is expected to reorder the manifest entries so that
|
||||
# chrome entries appear before the others.
|
||||
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),
|
||||
'add_manifest', ManifestContent('foo', 'bar', 'bar/')),
|
||||
((os.path.join(curdir, 'foo', 'bar.manifest'), 1),
|
||||
@@ -190,11 +201,15 @@ class TestSimplePackager(unittest.TestCase):
|
||||
'add_manifest', ManifestResource('qux', 'qux', 'qux/')),
|
||||
(('manifest', 4), 'add_interfaces', 'foo/bar.xpt', bar_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/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):
|
||||
|
||||
Reference in New Issue
Block a user