|
@@ -0,0 +1,349 @@
|
|
|
|
+# HG changeset patch
|
|
|
|
+# Date 1727650331 -7200
|
|
|
|
+# Parent 86173d21f2d52d8636bfe5aaf94ac0e38f3e7f53
|
|
|
|
+
|
|
|
|
+diff --git a/python/mozbuild/mozpack/chrome/manifest.py b/python/mozbuild/mozpack/chrome/manifest.py
|
|
|
|
+--- a/python/mozbuild/mozpack/chrome/manifest.py
|
|
|
|
++++ b/python/mozbuild/mozpack/chrome/manifest.py
|
|
|
|
+@@ -251,24 +251,16 @@ class ManifestResource(ManifestEntry):
|
|
|
|
+ u = urlparse(self.target)
|
|
|
|
+ if u.scheme and u.scheme != 'jar':
|
|
|
|
+ return ManifestEntry.rebase(self, base)
|
|
|
|
+ clone = ManifestEntry.rebase(self, base)
|
|
|
|
+ clone.target = mozpath.rebase(self.base, base, self.target)
|
|
|
|
+ return clone
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+-class ManifestBinaryComponent(ManifestEntryWithRelPath):
|
|
|
|
+- '''
|
|
|
|
+- Class for 'binary-component' entries.
|
|
|
|
+- binary-component some/path/to/a/component.dll
|
|
|
|
+- '''
|
|
|
|
+- type = 'binary-component'
|
|
|
|
+-
|
|
|
|
+-
|
|
|
|
+ class ManifestComponent(ManifestEntryWithRelPath):
|
|
|
|
+ '''
|
|
|
|
+ Class for 'component' entries.
|
|
|
|
+ component {b2bba4df-057d-41ea-b6b1-94a10a8ede68} foo.js
|
|
|
|
+ '''
|
|
|
|
+ type = 'component'
|
|
|
|
+
|
|
|
|
+ def __init__(self, base, cid, file, *flags):
|
|
|
|
+diff --git a/python/mozbuild/mozpack/packager/__init__.py b/python/mozbuild/mozpack/packager/__init__.py
|
|
|
|
+--- a/python/mozbuild/mozpack/packager/__init__.py
|
|
|
|
++++ b/python/mozbuild/mozpack/packager/__init__.py
|
|
|
|
+@@ -8,17 +8,16 @@ import codecs
|
|
|
|
+ from collections import deque
|
|
|
|
+ import json
|
|
|
|
+ import os
|
|
|
|
+ import re
|
|
|
|
+ import six
|
|
|
|
+ from mozpack.errors import errors
|
|
|
|
+ from mozpack.chrome.manifest import (
|
|
|
|
+ Manifest,
|
|
|
|
+- ManifestBinaryComponent,
|
|
|
|
+ ManifestChrome,
|
|
|
|
+ ManifestInterfaces,
|
|
|
|
+ is_manifest,
|
|
|
|
+ parse_manifest,
|
|
|
|
+ )
|
|
|
|
+ import mozpack.path as mozpath
|
|
|
|
+ from mozbuild.preprocessor import Preprocessor
|
|
|
|
+
|
|
|
|
+@@ -316,22 +315,16 @@ class SimplePackager(object):
|
|
|
|
+ # ManifestResources need to be given after ManifestChrome, so just
|
|
|
|
+ # put all ManifestChrome in a separate queue to make them first.
|
|
|
|
+ if isinstance(e, ManifestChrome):
|
|
|
|
+ # e.move(e.base) just returns a clone of the entry.
|
|
|
|
+ self._chrome_queue.append(self.formatter.add_manifest,
|
|
|
|
+ e.move(e.base))
|
|
|
|
+ elif not isinstance(e, (Manifest, ManifestInterfaces)):
|
|
|
|
+ self._queue.append(self.formatter.add_manifest, e.move(e.base))
|
|
|
|
+- # If a binary component is added to an addon, prevent the addon
|
|
|
|
+- # from being packed.
|
|
|
|
+- if isinstance(e, ManifestBinaryComponent):
|
|
|
|
+- addon = mozpath.basedir(e.base, self._addons)
|
|
|
|
+- if addon:
|
|
|
|
+- self._addons[addon] = 'unpacked'
|
|
|
|
+ if isinstance(e, Manifest):
|
|
|
|
+ if e.flags:
|
|
|
|
+ errors.fatal('Flags are not supported on ' +
|
|
|
|
+ '"manifest" entries')
|
|
|
|
+ self._included_manifests[e.path] = path
|
|
|
|
+
|
|
|
|
+ def get_bases(self, addons=True):
|
|
|
|
+ '''
|
|
|
|
+diff --git a/python/mozbuild/mozpack/packager/formats.py b/python/mozbuild/mozpack/packager/formats.py
|
|
|
|
+--- a/python/mozbuild/mozpack/packager/formats.py
|
|
|
|
++++ b/python/mozbuild/mozpack/packager/formats.py
|
|
|
|
+@@ -3,17 +3,16 @@
|
|
|
|
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
+
|
|
|
|
+ from __future__ import absolute_import, print_function, unicode_literals
|
|
|
|
+
|
|
|
|
+ from mozpack.chrome.manifest import (
|
|
|
|
+ Manifest,
|
|
|
|
+ ManifestInterfaces,
|
|
|
|
+ ManifestChrome,
|
|
|
|
+- ManifestBinaryComponent,
|
|
|
|
+ ManifestResource,
|
|
|
|
+ ManifestMultiContent,
|
|
|
|
+ )
|
|
|
|
+ from mozpack.errors import errors
|
|
|
|
+ from six.moves.urllib.parse import urlparse
|
|
|
|
+ import mozpack.path as mozpath
|
|
|
|
+ from mozpack.files import (
|
|
|
|
+ ManifestFile,
|
|
|
|
+@@ -304,19 +303,17 @@ class OmniJarSubFormatter(PiecemealForma
|
|
|
|
+ def _get_base(self, path):
|
|
|
|
+ base = self._omnijar_name if self.is_resource(path) else ''
|
|
|
|
+ # Only add the omnijar file if something ends up in it.
|
|
|
|
+ if base and not self.copier.contains(base):
|
|
|
|
+ self.copier.add(base, self._sub_formatter[base].copier)
|
|
|
|
+ return base, path
|
|
|
|
+
|
|
|
|
+ def add_manifest(self, entry):
|
|
|
|
+- base = ''
|
|
|
|
+- if not isinstance(entry, ManifestBinaryComponent):
|
|
|
|
+- base = self._omnijar_name
|
|
|
|
++ base = self._omnijar_name
|
|
|
|
+ formatter = self._sub_formatter[base]
|
|
|
|
+ return formatter.add_manifest(entry)
|
|
|
|
+
|
|
|
|
+ def is_resource(self, path):
|
|
|
|
+ '''
|
|
|
|
+ Return whether the given path corresponds to a resource to be put in an
|
|
|
|
+ omnijar archive.
|
|
|
|
+ '''
|
|
|
|
+diff --git a/python/mozbuild/mozpack/test/test_chrome_manifest.py b/python/mozbuild/mozpack/test/test_chrome_manifest.py
|
|
|
|
+--- a/python/mozbuild/mozpack/test/test_chrome_manifest.py
|
|
|
|
++++ b/python/mozbuild/mozpack/test/test_chrome_manifest.py
|
|
|
|
+@@ -12,17 +12,16 @@ from mozpack.chrome.manifest import (
|
|
|
|
+ ManifestLocale,
|
|
|
|
+ ManifestSkin,
|
|
|
|
+ Manifest,
|
|
|
|
+ ManifestResource,
|
|
|
|
+ ManifestOverride,
|
|
|
|
+ ManifestComponent,
|
|
|
|
+ ManifestContract,
|
|
|
|
+ ManifestInterfaces,
|
|
|
|
+- ManifestBinaryComponent,
|
|
|
|
+ ManifestCategory,
|
|
|
|
+ ManifestStyle,
|
|
|
|
+ ManifestOverlay,
|
|
|
|
+ MANIFESTS_TYPES,
|
|
|
|
+ parse_manifest,
|
|
|
|
+ parse_manifest_line,
|
|
|
|
+ )
|
|
|
|
+ from mozpack.errors import errors, AccumulatedErrors
|
|
|
|
+@@ -76,17 +75,16 @@ class TestManifest(unittest.TestCase):
|
|
|
|
+ ManifestResource('', 'gre-resources', 'toolkit/res/'),
|
|
|
|
+ ManifestOverride('', 'chrome://global/locale/netError.dtd',
|
|
|
|
+ 'chrome://browser/locale/netError.dtd'),
|
|
|
|
+ ManifestComponent('', '{b2bba4df-057d-41ea-b6b1-94a10a8ede68}',
|
|
|
|
+ 'foo.js'),
|
|
|
|
+ ManifestContract('', '@mozilla.org/foo;1',
|
|
|
|
+ '{b2bba4df-057d-41ea-b6b1-94a10a8ede68}'),
|
|
|
|
+ ManifestInterfaces('', 'foo.xpt'),
|
|
|
|
+- ManifestBinaryComponent('', 'bar.so'),
|
|
|
|
+ ManifestCategory('', 'command-line-handler', 'm-browser',
|
|
|
|
+ '@mozilla.org/browser/clh;1', 'application=' +
|
|
|
|
+ '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}'),
|
|
|
|
+ ManifestStyle('', 'chrome://global/content/customizeToolbar.xul',
|
|
|
|
+ 'chrome://browser/skin/'),
|
|
|
|
+ ManifestOverlay('', 'chrome://global/content/viewSource.xul',
|
|
|
|
+ 'chrome://browser/content/viewSourceOverlay.xul'),
|
|
|
|
+ ]
|
|
|
|
+diff --git a/python/mozbuild/mozpack/test/test_packager.py b/python/mozbuild/mozpack/test/test_packager.py
|
|
|
|
+--- a/python/mozbuild/mozpack/test/test_packager.py
|
|
|
|
++++ b/python/mozbuild/mozpack/test/test_packager.py
|
|
|
|
+@@ -12,17 +12,16 @@ from mozpack.packager import (
|
|
|
|
+ preprocess_manifest,
|
|
|
|
+ CallDeque,
|
|
|
|
+ Component,
|
|
|
|
+ SimplePackager,
|
|
|
|
+ SimpleManifestSink,
|
|
|
|
+ )
|
|
|
|
+ from mozpack.files import GeneratedFile
|
|
|
|
+ from mozpack.chrome.manifest import (
|
|
|
|
+- ManifestBinaryComponent,
|
|
|
|
+ ManifestContent,
|
|
|
|
+ ManifestResource,
|
|
|
|
+ )
|
|
|
|
+ from mozunit import MockedOpen
|
|
|
|
+ from mozbuild.preprocessor import Preprocessor
|
|
|
|
+ from mozpack.errors import (
|
|
|
|
+ errors,
|
|
|
|
+ ErrorMessage,
|
|
|
|
+@@ -296,26 +295,20 @@ class TestSimplePackager(unittest.TestCa
|
|
|
|
+ ((os.path.join(curdir, 'foo', 'bar.manifest'), 2),
|
|
|
|
+ 'add_manifest', ManifestContent('foo', 'bar', 'bar/')),
|
|
|
|
+ ((os.path.join(curdir, 'foo', 'bar.manifest'), 1),
|
|
|
|
+ 'add_manifest', ManifestResource('foo', 'bar', 'bar/')),
|
|
|
|
+ (('bar/baz.manifest', 1),
|
|
|
|
+ 'add_manifest', ManifestResource('bar', 'baz', 'baz/')),
|
|
|
|
+ (('qux/qux.manifest', 1),
|
|
|
|
+ 'add_manifest', ManifestResource('qux', 'qux', 'qux/')),
|
|
|
|
+- (('qux/qux.manifest', 2),
|
|
|
|
+- 'add_manifest', ManifestBinaryComponent('qux', 'qux.so')),
|
|
|
|
+ (('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/')),
|
|
|
|
+- (('addon2/chrome.manifest', 1), 'add_manifest',
|
|
|
|
+- ManifestBinaryComponent('addon2', 'addon2.so')),
|
|
|
|
+- (('addon3/components/components.manifest', 1), 'add_manifest',
|
|
|
|
+- ManifestBinaryComponent('addon3/components', 'addon3.so')),
|
|
|
|
+ (('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),
|
|
|
|
+ (('manifest', 10), 'add', 'addon2/install.rdf', install_rdf),
|
|
|
|
+ (('manifest', 11), 'add', 'addon3/install.rdf', install_rdf),
|
|
|
|
+ (('manifest', 12), 'add', 'addon4/install.rdf',
|
|
|
|
+ install_rdf_addon4),
|
|
|
|
+ (('manifest', 13), 'add', 'addon5/install.rdf',
|
|
|
|
+diff --git a/python/mozbuild/mozpack/test/test_packager_formats.py b/python/mozbuild/mozpack/test/test_packager_formats.py
|
|
|
|
+--- a/python/mozbuild/mozpack/test/test_packager_formats.py
|
|
|
|
++++ b/python/mozbuild/mozpack/test/test_packager_formats.py
|
|
|
|
+@@ -15,17 +15,16 @@ from mozpack.copier import FileRegistry
|
|
|
|
+ from mozpack.files import (
|
|
|
|
+ GeneratedFile,
|
|
|
|
+ ManifestFile,
|
|
|
|
+ )
|
|
|
|
+ from mozpack.chrome.manifest import (
|
|
|
|
+ ManifestContent,
|
|
|
|
+ ManifestComponent,
|
|
|
|
+ ManifestResource,
|
|
|
|
+- ManifestBinaryComponent,
|
|
|
|
+ ManifestSkin,
|
|
|
|
+ ManifestLocale,
|
|
|
|
+ )
|
|
|
|
+ from mozpack.errors import (
|
|
|
|
+ ErrorMessage,
|
|
|
|
+ )
|
|
|
|
+ from mozpack.test.test_files import (
|
|
|
|
+ MockDest,
|
|
|
|
+@@ -46,27 +45,25 @@ CONTENTS = {
|
|
|
|
+ 'app': False,
|
|
|
|
+ 'addon0': 'unpacked',
|
|
|
|
+ 'addon1': True,
|
|
|
|
+ },
|
|
|
|
+ 'manifests': [
|
|
|
|
+ ManifestContent('chrome/f', 'oo', 'oo/'),
|
|
|
|
+ ManifestContent('chrome/f', 'bar', 'oo/bar/'),
|
|
|
|
+ ManifestResource('chrome/f', 'foo', 'resource://bar/'),
|
|
|
|
+- ManifestBinaryComponent('components', 'foo.so'),
|
|
|
|
+ ManifestContent('app/chrome', 'content', 'foo/'),
|
|
|
|
+ ManifestComponent('app/components', '{foo-id}', 'foo.js'),
|
|
|
|
+ ManifestContent('addon0/chrome', 'content', 'foo/bar/'),
|
|
|
|
+ ManifestContent('addon1/chrome', 'content', 'foo/bar/'),
|
|
|
|
+ ],
|
|
|
|
+ 'files': {
|
|
|
|
+ 'chrome/f/oo/bar/baz': GeneratedFile(b'foobarbaz'),
|
|
|
|
+ 'chrome/f/oo/baz': GeneratedFile(b'foobaz'),
|
|
|
|
+ 'chrome/f/oo/qux': GeneratedFile(b'fooqux'),
|
|
|
|
+- 'components/foo.so': GeneratedFile(b'foo.so'),
|
|
|
|
+ 'components/foo.xpt': foo_xpt,
|
|
|
|
+ 'components/bar.xpt': bar_xpt,
|
|
|
|
+ 'foo': GeneratedFile(b'foo'),
|
|
|
|
+ 'app/chrome/foo/foo': GeneratedFile(b'appfoo'),
|
|
|
|
+ 'app/components/foo.js': GeneratedFile(b'foo.js'),
|
|
|
|
+ 'addon0/chrome/foo/bar/baz': GeneratedFile(b'foobarbaz'),
|
|
|
|
+ 'addon0/components/foo.xpt': foo2_xpt,
|
|
|
|
+ 'addon0/components/bar.xpt': bar_xpt,
|
|
|
|
+@@ -90,20 +87,18 @@ RESULT_FLAT = {
|
|
|
|
+ 'content oo oo/',
|
|
|
|
+ 'content bar oo/bar/',
|
|
|
|
+ 'resource foo resource://bar/',
|
|
|
|
+ ],
|
|
|
|
+ 'chrome/f/oo/bar/baz': FILES['chrome/f/oo/bar/baz'],
|
|
|
|
+ 'chrome/f/oo/baz': FILES['chrome/f/oo/baz'],
|
|
|
|
+ 'chrome/f/oo/qux': FILES['chrome/f/oo/qux'],
|
|
|
|
+ 'components/components.manifest': [
|
|
|
|
+- 'binary-component foo.so',
|
|
|
|
+ 'interfaces interfaces.xpt',
|
|
|
|
+ ],
|
|
|
|
+- 'components/foo.so': FILES['components/foo.so'],
|
|
|
|
+ 'components/interfaces.xpt': {
|
|
|
|
+ 'foo': read_interfaces(foo_xpt.open())['foo'],
|
|
|
|
+ 'bar': read_interfaces(bar_xpt.open())['bar'],
|
|
|
|
+ },
|
|
|
|
+ 'foo': FILES['foo'],
|
|
|
|
+ 'app/chrome.manifest': [
|
|
|
|
+ 'manifest chrome/chrome.manifest',
|
|
|
|
+ 'manifest components/components.manifest',
|
|
|
|
+@@ -141,17 +136,16 @@ for addon in ('addon0', 'addon1'):
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ RESULT_JAR = {
|
|
|
|
+ p: RESULT_FLAT[p]
|
|
|
|
+ for p in (
|
|
|
|
+ 'chrome.manifest',
|
|
|
|
+ 'chrome/chrome.manifest',
|
|
|
|
+ 'components/components.manifest',
|
|
|
|
+- 'components/foo.so',
|
|
|
|
+ 'components/interfaces.xpt',
|
|
|
|
+ 'foo',
|
|
|
|
+ 'app/chrome.manifest',
|
|
|
|
+ 'app/components/components.manifest',
|
|
|
|
+ 'app/components/foo.js',
|
|
|
|
+ 'addon0/chrome.manifest',
|
|
|
|
+ 'addon0/components/components.manifest',
|
|
|
|
+ 'addon0/components/interfaces.xpt',
|
|
|
|
+@@ -186,17 +180,16 @@ RESULT_JAR.update({
|
|
|
|
+ for p, f in six.iteritems(RESULT_FLAT)
|
|
|
|
+ if p.startswith('addon1/')
|
|
|
|
+ },
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ RESULT_OMNIJAR = {
|
|
|
|
+ p: RESULT_FLAT[p]
|
|
|
|
+ for p in (
|
|
|
|
+- 'components/foo.so',
|
|
|
|
+ 'foo',
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ RESULT_OMNIJAR.update({
|
|
|
|
+ p: RESULT_JAR[p]
|
|
|
|
+ for p in RESULT_JAR
|
|
|
|
+ if p.startswith('addon')
|
|
|
|
+@@ -206,19 +199,16 @@ RESULT_OMNIJAR.update({
|
|
|
|
+ 'omni.foo': {
|
|
|
|
+ 'components/components.manifest': [
|
|
|
|
+ 'interfaces interfaces.xpt',
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+ 'chrome.manifest': [
|
|
|
|
+ 'manifest components/components.manifest',
|
|
|
|
+ ],
|
|
|
|
+- 'components/components.manifest': [
|
|
|
|
+- 'binary-component foo.so',
|
|
|
|
+- ],
|
|
|
|
+ 'app/omni.foo': {
|
|
|
|
+ p: RESULT_FLAT['app/' + p]
|
|
|
|
+ for p in (
|
|
|
|
+ 'chrome.manifest',
|
|
|
|
+ 'chrome/chrome.manifest',
|
|
|
|
+ 'chrome/foo/foo',
|
|
|
|
+ 'components/components.manifest',
|
|
|
|
+ 'components/foo.js',
|
|
|
|
+@@ -415,17 +405,16 @@ class TestFormatters(TestErrors, unittes
|
|
|
|
+ return True
|
|
|
|
+
|
|
|
|
+ for base in ['', 'app/']:
|
|
|
|
+ self.assertTrue(is_resource(base, 'chrome'))
|
|
|
|
+ self.assertTrue(
|
|
|
|
+ is_resource(base, 'chrome/foo/bar/baz.properties'))
|
|
|
|
+ self.assertFalse(is_resource(base, 'chrome/icons/foo.png'))
|
|
|
|
+ self.assertTrue(is_resource(base, 'components/foo.js'))
|
|
|
|
+- self.assertFalse(is_resource(base, 'components/foo.so'))
|
|
|
|
+ self.assertTrue(is_resource(base, 'res/foo.css'))
|
|
|
|
+ self.assertFalse(is_resource(base, 'res/cursors/foo.png'))
|
|
|
|
+ self.assertFalse(is_resource(base, 'res/MainMenu.nib/foo'))
|
|
|
|
+ self.assertTrue(is_resource(base, 'defaults/pref/foo.js'))
|
|
|
|
+ self.assertFalse(
|
|
|
|
+ is_resource(base, 'defaults/pref/channel-prefs.js'))
|
|
|
|
+ self.assertTrue(
|
|
|
|
+ is_resource(base, 'defaults/preferences/foo.js'))
|