Bug 842762: Uplift Add-on SDK changeset 4e44dd094e8636216e8c9ca5664866a5cf7d0cdd

a16bbd5772...4e44dd094e
This commit is contained in:
Dave Townsend
2013-02-19 14:14:54 -08:00
parent b21d195aac
commit 1be39049f5
74 changed files with 1338 additions and 496 deletions

View File

@@ -58,11 +58,22 @@ class ManifestEntry:
self.datamap = None
def get_path(self):
path = "%s/%s/%s" % \
(self.packageName, self.sectionName, self.moduleName)
if not path.endswith(".js"):
path += ".js"
return path
name = self.moduleName
if name.endswith(".js"):
name = name[:-3]
items = []
# Only add package name for addons, so that system module paths match
# the path from the commonjs root directory and also match the loader
# mappings.
if self.packageName != "addon-sdk":
items.append(self.packageName)
# And for the same reason, do not append `lib/`.
if self.sectionName == "tests":
items.append(self.sectionName)
items.append(name)
return "/".join(items)
def get_entry_for_manifest(self):
entry = { "packageName": self.packageName,
@@ -75,13 +86,13 @@ class ManifestEntry:
for req in self.requirements:
if isinstance(self.requirements[req], ManifestEntry):
them = self.requirements[req] # this is another ManifestEntry
them_path = them.get_path()
entry["requirements"][req] = {"path": them_path}
entry["requirements"][req] = them.get_path()
else:
# something magic. The manifest entry indicates that they're
# allowed to require() it
entry["requirements"][req] = self.requirements[req]
assert isinstance(entry["requirements"][req], dict)
assert isinstance(entry["requirements"][req], unicode) or \
isinstance(entry["requirements"][req], str)
return entry
def add_js(self, js_filename):
@@ -226,7 +237,8 @@ class ManifestBuilder:
# search for all tests. self.test_modules will be passed
# through the harness-options.json file in the
# .allTestModules property.
self.test_modules.append(testname)
# Pass the absolute module path.
self.test_modules.append(tme.get_path())
# include files used by the loader
for em in self.extra_modules:
@@ -378,7 +390,7 @@ class ManifestBuilder:
# If requirement is chrome or a pseudo-module (starts with @) make
# path a requirement name.
if reqname == "chrome" or reqname.startswith("@"):
me.add_requirement(reqname, {"path": reqname})
me.add_requirement(reqname, reqname)
else:
# when two modules require() the same name, do they get a
# shared instance? This is a deep question. For now say yes.