more builder changes to close in on a functional build. Moved
authorKevin Dangoor <kdangoor@mozilla.com>
Fri, 16 Oct 2009 15:50:31 -0400
changeset 135 4c131f80a556bfe1d6d8a43ab09a8c75b4acdcf3
parent 134 9ce75d47bc2cf9f5e19acb3c23e2d398d142c688
child 136 7f3a2c5a7747cac09e646ff09d084b20f4bfd17e
push id50
push userkdangoor@mozilla.com
push dateFri, 16 Oct 2009 20:00:19 +0000
more builder changes to close in on a functional build. Moved worker into bespin-labs, because that's the only place it's used currently
src/bespin-build/lib/bespin/builder.js
src/bespin-core/lib/bespin/util/worker.js
src/bespin-labs/lib/bespin/util/worker.js
--- a/src/bespin-build/lib/bespin/builder.js
+++ b/src/bespin-build/lib/bespin/builder.js
@@ -55,17 +55,18 @@ var STANDARD_INCLUDES = [
     "sandbox", 
     "narwhal/client", 
     "array", 
     "object", 
     "string", 
     "function", 
     "regexp", 
     "reactor", 
-    "date", 
+    "date",
+    "json", // TODO remove this one. We don't need to include this module.
     "global", 
     "system", 
     "binary",
     {file: "src/html/dojo/dojo.js.uncompressed.js"},
     "sproutcore",
     {moduleDir: "bespin/boot"},
     {file: "src/bespin-build/launchbespin.js"}
 ];
@@ -134,18 +135,18 @@ exports.expandIncludes = function(loader
             } catch (e) {
                 throw new BuilderError("Unable to find module " + filespec.moduleDir 
                     + " for a moduleDir include");
             }
             path = new file.Path(path).dirname();
             var items = file.listTree(path);
             for (var j = 0; j < items.length; j++) {
                 var fullname = items[j];
-                // we don't care about directories
-                if (fullname == "" || (/\/$/.exec(fullname))) {
+                // we don't care about directories or non-js files
+                if (fullname == "" || (/\/$/.exec(fullname)) || !(/\.js$/.exec(fullname))) {
                     continue;
                 }
                 fullname = packageName + "/" + fullname;
                 
                 fullname = fullname.replace(/\.js$/, "");
                 
                 // at some point, we'll likely have a more flexible way to 
                 // exclude certain files.
@@ -209,17 +210,22 @@ exports.getFileContents = function(loade
     
     return contents;
 };
 
 /*
 * Creates a new sandbox.Loader with the current path.
 */
 exports._getLoader = function() {
-    return new sandbox.Loader({paths: require.paths});
+    var paths = require.paths.map(function (path) {
+        return String(path);
+    });
+    paths.unshift(file.join(system.prefix, "engines", "browser", "lib"));
+    
+    return new sandbox.Loader({paths: paths});
 };
 
 /*
 * Generates an output script based on one item
 * description from the profile.
 * @param {Object} description One item from the list of items in a profile.
 */
 exports.generateScript = function(description) {
@@ -228,16 +234,20 @@ exports.generateScript = function(descri
     log.info("Generating " + outputPath);
     
     if (!outputPath.dirname().exists()) {
         outputPath.dirname().mkdirs();
     }
     
     var loader = exports._getLoader();
     
+    // TODO this is temporary because narwhal-jsc doesn't automatically
+    // clear the file first.
+    outputPath.remove();
+    
     var outputFile = file.open(outputPath.toString(), "w");
     
     var includes = exports.expandIncludes(loader, description.includes);
     
     for (var i = 0; i < includes.length; i++) {
         var filespec = includes[i];
         
         if (log.level == log.DEBUG) {
rename from src/bespin-core/lib/bespin/util/worker.js
rename to src/bespin-labs/lib/bespin/util/worker.js