Fix press yet again.

This commit is contained in:
Tom Robinson
2010-03-07 00:53:08 -08:00
parent 276e8b948d
commit fbed77fc64
3 changed files with 54 additions and 14 deletions
+7 -4
View File
@@ -254,7 +254,7 @@ function pressEnvironment(rootPath, outputFiles, environment, options) {
for (var path in requiredFiles)
{
var executable = analyzer.executableForImport(path),
bundle = analyzer.context.global.CFBundle.bundleContainingPath(executable.path()),
bundle = analyzer.context.global.CFBundle.bundleContainingURL(executable.path()),
relativePath = FILE.relative(FILE.join(bundle.path(), ""), executable.path());
if (executable.path() !== path)
@@ -274,7 +274,7 @@ function pressEnvironment(rootPath, outputFiles, environment, options) {
for (var i = 0; i < dependencies.length; i++) {
var dependency = dependencies[i];
var dependencyExecutable = new _OBJJ.FileExecutableSearch(
dependency.isLocal() ? FILE.join(FILE.dirname(path), dependency.path()) : dependency.path(),
new analyzer.context.global.CFURL(dependency.isLocal() ? FILE.join(FILE.dirname(path), dependency.path()) : dependency.path()),
dependency.isLocal()
).result();
var dependencyPath = dependencyExecutable.path();
@@ -286,11 +286,14 @@ function pressEnvironment(rootPath, outputFiles, environment, options) {
RegExp.escape("("),
"[\"']"+RegExp.escape(dependency.path())+"[\"']",
RegExp.escape(","),
RegExp.escape(dependency.isLocal() ? "true" : "false"),
dependency.isLocal() ? "(true|YES)" : "(false|NO)",
RegExp.escape(")")
].join("\\s*"), "g");
// replace instances of "objj_executeFile()" with "(undefined)"
code = code.replace(regex, "/* $& */ (undefined)");
newCode = code.replace(regex, "/* $& */ (undefined)");
if (newCode === code)
stream.print("\0yellow(Warning:\0) Unable to strip import for \0cyan(" + dependency.path() + "\0) (" + dependency.isLocal() + ")");
code = newCode;
// remove from dependencies list (decrement i since we're removing an item)
dependencies.splice(i--, 1);
}
+41 -8
View File
@@ -10,6 +10,24 @@ ObjectiveJRuntimeAnalyzer = function(rootPath)
this.scope = setupObjectiveJ(this.context);
this.require = this.context.global.require;
this.mainBundleURL = new this.context.global.CFURL("file:" + this.rootPath);
var _OBJJ = this.require("objective-j");
// TODO: deprecate these
_OBJJ.Executable.prototype.path = function() {
var url = this.URL();
return url ? url.absoluteURL().path() : null;
}
_OBJJ.FileDependency.prototype.path = function() {
var url = this.URL();
return url ? url.path() : null;
}
this.context.global.CFBundle.prototype.executablePath = function() {
var url = this.executableURL();
return url ? url.absoluteURL().path() : null;
}
}
ObjectiveJRuntimeAnalyzer.prototype.setIncludePaths = function(includePaths) {
@@ -20,6 +38,14 @@ ObjectiveJRuntimeAnalyzer.prototype.setEnvironments = function(environments) {
this.context.global.CFBundle.environments = function() { return environments; };
}
ObjectiveJRuntimeAnalyzer.prototype.makeAbsoluteURL = function(/*CFURL|String*/ aURL)
{
if (aURL instanceof this.context.global.CFURL && aURL.scheme())
return aURL;
return new this.context.global.CFURL(aURL, this.mainBundleURL);
}
ObjectiveJRuntimeAnalyzer.prototype.initializeGlobalRecorder = function()
{
this.initializeGlobalRecorder = function(){}; // run once
@@ -40,7 +66,7 @@ ObjectiveJRuntimeAnalyzer.prototype.initializeGlobalRecorder = function()
var after = cloneProperties(self.scope);
if (before) {
if (before && currentFile) {
self.files[currentFile] = self.files[currentFile] || {};
self.files[currentFile].globals = self.files[currentFile].global || {};
@@ -52,15 +78,22 @@ ObjectiveJRuntimeAnalyzer.prototype.initializeGlobalRecorder = function()
changed : self.files[currentFile].globals
});
}
else if (!currentFile) {
CPLog.warn("currentFile is null. WTF.")
}
before = after;
}
var _OBJJ = this.require("objective-j");
var _fileExecuterForPath = _OBJJ.Executable.fileExecuterForPath;
_OBJJ.Executable.fileExecuterForPath = function(/*String*/ referencePath) {
var fileExecutor = _fileExecuterForPath.apply(this, arguments);
return function(/*String*/ aPath, /*BOOL*/ isLocal, /*BOOL*/ shouldForce) {
var _fileExecuterForURL = _OBJJ.Executable.fileExecuterForURL;
_OBJJ.Executable.fileExecuterForURL = function(/*CFURL*/ referenceURL) {
referenceURL = self.makeAbsoluteURL(referenceURL);
var referencePath = referenceURL.absoluteURL().path()
var fileExecutor = _fileExecuterForURL.apply(this, arguments);
return function(/*CFURL*/ aURL, /*BOOL*/ isQuoted, /*BOOL*/ shouldForce) {
var aPath = typeof aURL === "string" ? aURL : aURL.absoluteURL().path();
recordAndReset();
evaluatingPaths.push(currentFile);
@@ -68,7 +101,7 @@ ObjectiveJRuntimeAnalyzer.prototype.initializeGlobalRecorder = function()
// NOTE: we distinguish local and library imports using absolute and relative paths.
// we resolve the library paths later (in "mergeLibraryImports()") since doing it here seems
// to change the resulting recorded globals.
if (isLocal && !FILE.isAbsolute(aPath))
if (isQuoted && !FILE.isAbsolute(aPath))
currentFile = FILE.normal(FILE.join(referencePath, aPath));
else
currentFile = aPath;
@@ -137,7 +170,7 @@ ObjectiveJRuntimeAnalyzer.prototype.mergeLibraryImports = function()
for (var relativePath in this.files) {
if (FILE.isRelative(relativePath)) {
var absolutePath = this.executableForImport(relativePath, false).path();
// CPLog.debug("Merging " + relativePath + " => " + absolutePath);
CPLog.debug("Merging " + relativePath + " => " + absolutePath);
this.files[absolutePath] = this.files[absolutePath] || {};
this.files[absolutePath].globals = this.files[absolutePath].globals || {};
@@ -155,7 +188,7 @@ ObjectiveJRuntimeAnalyzer.prototype.executableForImport = function(path, isLocal
{
if (isLocal === undefined) isLocal = true;
var _OBJJ = this.require("objective-j");
return new _OBJJ.FileExecutableSearch(path, isLocal).result();
return new _OBJJ.FileExecutableSearch(new this.context.global.CFURL(path), isLocal).result();
}
/*
+6 -2
View File
@@ -630,11 +630,15 @@ CFBundle.prototype.onerror = function(/*Event*/ anEvent)
throw anEvent.error;
}
//
CFBundle.prototype.bundlePath = function()
{
return this._bundleURL.absoluteURL().path();
}
CFBundle.prototype.path = function()
{
return this._bundleURL.absoluteString();
CPLog.warn("CFBundle.prototype.path is deprecated, use CFBundle.prototype.bundlePath instead.");
return this.bundlePath.apply(this, arguments);
}
CFBundle.prototype.pathForResource = function(aResource)