From 49927fcfb7c6801abb6055ec21e43372cdab3b2a Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Tue, 17 Nov 2009 14:46:54 -0800 Subject: [PATCH 1/2] Fix for building projects where source files are in nested subfolders. Reviewed by me. --- Objective-J/CommonJS/lib/objective-j.js | 8 +++----- .../lib/objective-j/jake/bundletask.js | 20 ++++++++++++------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Objective-J/CommonJS/lib/objective-j.js b/Objective-J/CommonJS/lib/objective-j.js index 1a9f81474..f42cc5b1a 100644 --- a/Objective-J/CommonJS/lib/objective-j.js +++ b/Objective-J/CommonJS/lib/objective-j.js @@ -1,5 +1,4 @@ -var FILE = require("file"), - readline = require("readline").readline; +var FILE = require("file"); var window = require("browser/window"); @@ -144,9 +143,8 @@ exports.run = function(args) try { system.stdout.write("objj> ").flush(); - var input = readline(), - result = objj_eval(input); - + var result = objj_eval(require("readline").readline()); + if (result !== undefined) print(result); diff --git a/Objective-J/CommonJS/lib/objective-j/jake/bundletask.js b/Objective-J/CommonJS/lib/objective-j/jake/bundletask.js index 115e02ac8..d021103b7 100644 --- a/Objective-J/CommonJS/lib/objective-j/jake/bundletask.js +++ b/Objective-J/CommonJS/lib/objective-j/jake/bundletask.js @@ -509,7 +509,11 @@ function directoryInCommon(filenames) { var directory = FILE.dirname(aFilename); - if (!aCommonDirectory) + if (directory === ".") + directory = ""; + + // Empty string is an acceptable common directory. + if (aCommonDirectory === null) aCommonDirectory = directory; else @@ -665,7 +669,8 @@ BundleTask.prototype.defineSourceTasks = function() else if (compilerFlags.join) compilerFlags = compilerFlags.join(" "); - var environments = this.flattenedEnvironments(); + var environments = this.flattenedEnvironments(), + flattensSources = this.flattensSources(); environments.forEach(function(/*Environment*/ anEnvironment) { @@ -683,7 +688,9 @@ BundleTask.prototype.defineSourceTasks = function() } var replacedFiles = [], - environmentCompilerFlags = anEnvironment.compilerFlags().join(" ") + " " + compilerFlags; + environmentCompilerFlags = anEnvironment.compilerFlags().join(" ") + " " + compilerFlags, + flattensSources = this.flattensSources(), + basePathLength = directoryInCommon(environmentSources).length; environmentSources.forEach(function(/*String*/ aFilename) { @@ -691,7 +698,8 @@ BundleTask.prototype.defineSourceTasks = function() if (!FILE.exists(aFilename) || FILE.extension(aFilename) !== '.j') return; - var compiledEnvironmentSource = FILE.join(sourcesPath, FILE.basename(aFilename)); + var relativePath = aFilename.substring(basePathLength), + compiledEnvironmentSource = FILE.join(sourcesPath, relativePath); filedir (compiledEnvironmentSource, [aFilename], function() { @@ -701,9 +709,7 @@ BundleTask.prototype.defineSourceTasks = function() filedir (staticPath, [compiledEnvironmentSource]); - // FIXME: how do we non flatten? - // dir in common - replacedFiles.push(flattensSources ? FILE.basename(aFilename) : FILE.relative(sourcesPath, aFilename)); + replacedFiles.push(flattensSources ? FILE.basename(aFilename) : relativePath); }, this); this._replacedFiles[anEnvironment] = replacedFiles; From 31feec0465f91a9bdf7907f543fe0a6c32c9ef22 Mon Sep 17 00:00:00 2001 From: Tom Robinson Date: Tue, 17 Nov 2009 17:02:07 -0800 Subject: [PATCH 2/2] Flush stdin after writing file to ShrinkSafe process (fixes building in Rhino) --- Objective-J/CommonJS/lib/objective-j/compiler.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Objective-J/CommonJS/lib/objective-j/compiler.js b/Objective-J/CommonJS/lib/objective-j/compiler.js index f5465e1a5..ccc5f675e 100644 --- a/Objective-J/CommonJS/lib/objective-j/compiler.js +++ b/Objective-J/CommonJS/lib/objective-j/compiler.js @@ -43,6 +43,7 @@ function compress(/*String*/ aCode, /*String*/ FIXME) chunk = ""; compressor.stdin.write(tmpFile + "\n"); + compressor.stdin.flush(); while ((chunk = compressor.stdout.readLine()) !== "/*----*/\n") output += chunk;