Skip to content

Commit

Permalink
move all modules from nested package hierarchy into modules/, whomp o…
Browse files Browse the repository at this point in the history
…n the loader code until it digs the new structure. issue mozilla#82
  • Loading branch information
lloyd committed May 10, 2011
1 parent a512139 commit 0118051
Show file tree
Hide file tree
Showing 164 changed files with 25 additions and 7,968 deletions.
Expand Up @@ -160,11 +160,6 @@ function buildHarnessService(rootFileSpec, dump, logError,
}

function buildLoader() {
// TODO: This variable doesn't seem to be used, we should
// be able to remove it.
var compMgr = Components.manager;
compMgr = compMgr.QueryInterface(Ci.nsIComponentRegistrar);

for (name in options.resources) {
var path = options.resources[name];
var dir;
Expand Down Expand Up @@ -236,7 +231,7 @@ function buildHarnessService(rootFileSpec, dump, logError,
};
if (info.packageName in options.packageData)
info.packageData = options.packageData[info.packageName];

return info;

/*
Expand Down Expand Up @@ -540,7 +535,7 @@ function getDefaults(rootFileSpec) {
}

options = JSON.parse(jsonData);

if ("staticArgs" in options) {
dirbase = rootFileSpec.clone();
options.staticArgs.appBasePath=dirbase.path;
Expand Down
92 changes: 16 additions & 76 deletions impl/cuddlefish/__init__.py
Expand Up @@ -8,6 +8,7 @@
import subprocess
import signal
import tempfile
import chromeless

from copy import copy
import simplejson as json
Expand Down Expand Up @@ -399,27 +400,6 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None,
print "Created docs in %s." % dirname
return

target_cfg_json = None
if not target_cfg:
if not options.pkgdir:
options.pkgdir = find_parent_package(os.getcwd())
if not options.pkgdir:
print >>sys.stderr, ("cannot find 'package.json' in the"
" current directory or any parent.")
sys.exit(1)
else:
options.pkgdir = os.path.abspath(options.pkgdir)
if not os.path.exists(os.path.join(options.pkgdir, 'package.json')):
print >>sys.stderr, ("cannot find 'package.json' in"
" %s." % options.pkgdir)
sys.exit(1)

target_cfg_json = os.path.join(options.pkgdir, 'package.json')
target_cfg = packaging.get_config_in_dir(options.pkgdir)

# At this point, we're either building an XPI or running Jetpack code in
# a Mozilla application (which includes running tests).

use_main = False
timeout = None
inherited_options = ['verbose', 'enable_e10s']
Expand All @@ -436,49 +416,13 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None,
print >>sys.stderr, "Try using '--help' for assistance."
sys.exit(1)

if use_main and 'main' not in target_cfg:
print >>sys.stderr, "package.json does not have a 'main' entry."
sys.exit(1)

print "MAIN: " + target_cfg['main']

if not pkg_cfg:
pkg_cfg = packaging.build_config(env_root, target_cfg)

target = target_cfg.name
target = "main"

# the harness_guid is used for an XPCOM class ID.
import uuid
harness_guid = str(uuid.uuid4())

print("harness_guid: %s" % harness_guid);

# TODO: Consider keeping a cache of dynamic UUIDs, based
# on absolute filesystem pathname, in the root directory
# or something.
if command in ('package', 'run', 'appify'):
from cuddlefish.preflight import preflight_config
if target_cfg_json:
config_was_ok, modified = preflight_config(
target_cfg,
target_cfg_json,
keydir=options.keydir,
err_if_privkey_not_found=False
)
if not config_was_ok:
if modified:
# we need to re-read package.json . The safest approach
# is to re-run the "cfx xpi"/"cfx run" command.
print >>sys.stderr, ("package.json modified: please re-run"
" 'cfx %s'" % command)
else:
print >>sys.stderr, ("package.json needs modification:"
" please update it and then re-run"
" 'cfx %s'" % command)
sys.exit(1)
# if we make it this far, we have a JID
else:
assert command == "test"

unique_prefix = '%s-' % target

Expand All @@ -494,17 +438,14 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None,
if options.extra_packages:
targets.extend(options.extra_packages.split(","))

deps = packaging.get_deps_for_targets(pkg_cfg, targets)
build = packaging.generate_build_for_target(
pkg_cfg, target, deps,
prefix=unique_prefix, # used to create resource: URLs
include_dep_tests=options.dep_tests
)

if 'resources' in build:
resources = build.resources
for name in resources:
resources[name] = os.path.abspath(resources[name])
resources = { }
rootPaths = [ ]
import chromeless
path_to_modules = os.path.join(chromeless.Dirs().cuddlefish_root, "modules")
for f in os.listdir(path_to_modules):
resourceName = harness_guid + "-" + f
resources[harness_guid + "-" + f] = os.path.join(path_to_modules, f)
rootPaths.append("resource://" + resourceName + "/");

harness_contract_id = ('@mozilla.org/harness-service;1?id=%s' % harness_guid)
harness_options = {
Expand All @@ -515,20 +456,19 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None,
'jetpackID': harness_guid,
'bundleID': harness_guid,
'staticArgs': options.static_args,
'resources': resources,
'loader': "resource://%s-%s/%s" % (harness_guid, "internal", "cuddlefish.js"),
'rootPaths': rootPaths
}

harness_options.update(build)

if command == "test":
# This should be contained in the test runner package.
harness_options['main'] = 'run-tests'
else:
harness_options['main'] = 'main'

for option in inherited_options:
harness_options[option] = getattr(options, option)

harness_options['metadata'] = packaging.get_metadata(pkg_cfg, deps)
# for option in inherited_options:
# harness_options[option] = getattr(options, option)

retval = 0

Expand All @@ -545,7 +485,7 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None,
harness_options=harness_options,
dev_mode=False)

else:
else:
browser_code_path = options.static_args["browser"]

if options.profiledir:
Expand Down
Expand Up @@ -46,10 +46,10 @@
var securableModule;
var myURI = Components.stack.filename.split(" -> ").slice(-1)[0];

if (global.require)
if (global.require) {
// We're being loaded in a SecurableModule.
securableModule = require("securable-module");
else {
} else {
var ios = Cc['@mozilla.org/network/io-service;1']
.getService(Ci.nsIIOService);
var securableModuleURI = ios.newURI("securable-module.js", null,
Expand Down Expand Up @@ -135,44 +135,6 @@
function makeManifestChecker(packaging) {
var mc = {
_allow: function _allow(loader, basePath, module, module_info) {
if (!basePath) {
return true; /* top-level import */
}
let mi = packaging.getModuleInfo(basePath);
if (mi.needsChrome)
/* The module requires chrome, it can import whatever it
* wants. */
return true;
if (!mi.dependencies) {
/* the parent isn't in the manifest: we know nothing about it */
} else {
if (mi.dependencies[module]) {
/* they're on the list: the require() is allowed, but let's
check that they're loading the right thing */
let parent_mi = packaging.getModuleInfo(basePath);
// parent_mi is the parent, who invoked require()
// module_info is the child, the output of resolveModule
var should_load = parent_mi.dependencies[module].url;
var is_loading = module_info.filename;
if (!should_load) {
/* the linker wasn't able to find the target module when the
XPI was constructed. */
loader.console.warn("require("+ module +") (called from " +
basePath + ") is loading " + is_loading +
", but the manifest couldn't find it");
} else if (should_load != is_loading) {
loader.console.warn("require(" + module + ") (called from " +
basePath + ") is loading " + is_loading +
", but is supposed to be loading " +
should_load);
//return false; // enable this in 0.9
}
return true;
}
}
loader.console.warn("undeclared require(" + module +
") called from " + basePath);
//return false; // enable this in 0.9
return true;
},
allowEval: function allowEval(loader, basePath, module, module_info) {
Expand All @@ -181,16 +143,6 @@

allowImport: function allowImport(loader, basePath, module, module_info,
exports) {
if (module == "chrome") {
let parent_mi = packaging.getModuleInfo(basePath);
if (parent_mi.needsChrome)
return true; /* chrome is on the list, allow it */
loader.console.warn("undeclared require(chrome) called from " +
basePath);
//return false; // enable this in 0.9
return true;
}

return this._allow(loader, basePath, module, module_info);
}
};
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions packages/chromeless/lib/main.js → modules/internal/main.js
Expand Up @@ -45,21 +45,21 @@ const {Ci, Cc, Cr, Cu} = require("chrome");
const path = require('path');
const appinfo = require('appinfo');

var appWindow = null;
var appWindow = null;

// These functions are used from the test application.
// These functions are used from the test application.
/*
exports.getAppWindow = function () {
return appWindow;
}
*/
exports.__defineGetter__('getAppWindow', function () {
return appWindow;
exports.__defineGetter__('getAppWindow', function () {
return appWindow;
} );

exports.getAppBrowser = function () {
return appWindow._browser;
}
}

function testFunction(html) {
return html.replace("World", "Hello");
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 0 additions & 8 deletions packages/addon-kit/README.md

This file was deleted.

58 changes: 0 additions & 58 deletions packages/addon-kit/docs/clipboard.md

This file was deleted.

0 comments on commit 0118051

Please sign in to comment.