From 35bbb1a3d5eae54011bd2087d138d7a209e9e4cb Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Thu, 14 Apr 2011 14:35:29 -0700 Subject: [PATCH] Handle source files being deleted. Reviewed by me. --- Tools/xcodecapp/Resources/FIXME_parser.j | 12 ++---------- Tools/xcodecapp/XCProject.j | 16 ++++++++++++---- Tools/xcodecapp/XCResourceMonitor.j | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Tools/xcodecapp/Resources/FIXME_parser.j b/Tools/xcodecapp/Resources/FIXME_parser.j index bc0180f04..3b586b316 100644 --- a/Tools/xcodecapp/Resources/FIXME_parser.j +++ b/Tools/xcodecapp/Resources/FIXME_parser.j @@ -6,7 +6,7 @@ var FILE = require("file"); function main(args) { var fileURL = new CFURL(args[1]), - sourcesURL = new CFURL(args[2]), + outputURL = new CFURL(args[2]), source = FILE.read(fileURL, { charset: "UTF-8" }), flags = ObjectiveJ.Preprocessor.Flags.IncludeDebugSymbols | ObjectiveJ.Preprocessor.Flags.IncludeTypeSignatures, @@ -94,15 +94,7 @@ function main(args) }); if (ObjectiveCSource.length) - FILE.write(FILE.join(sourcesURL, xCodeSupportShadowURL(fileURL)), ObjectiveCSource, { charset:"UTF-8" }); -} - -function xCodeSupportShadowURL(aURL) -{ - var flattenedPath = (aURL + "").replace(/\//g, "_"), - extension = FILE.extension(flattenedPath); - - return new CFURL(flattenedPath.substr(0, flattenedPath.length - extension.length) + ".h"); + FILE.write(outputURL, ObjectiveCSource, { charset:"UTF-8" }); } function NSCompatibleClassName(aClassName, asPointer) diff --git a/Tools/xcodecapp/XCProject.j b/Tools/xcodecapp/XCProject.j index 521139074..316332de5 100644 --- a/Tools/xcodecapp/XCProject.j +++ b/Tools/xcodecapp/XCProject.j @@ -99,6 +99,15 @@ var FILE = require("file"), [self updateNibFiles]; } +- (CPURL)shadowURLForSourceURL:(CPURL)aSourceURL +{ + var flattenedPath = (aSourceURL + "").replace(new RegExp("\/", "g"), "_"), + extension = FILE.extension(flattenedPath), + basename = flattenedPath.substr(0, flattenedPath.length - extension.length) + ".h"; + + return new CFURL(basename, m_xCodeSupportSourcesURL.asDirectoryPathURL()); +} + - (void)updateSourceFiles { // Require the new parser for this. @@ -107,20 +116,19 @@ var FILE = require("file"), [m_sourceResourceMonitor addedFilePaths].forEach(function(aFilePath) { print("Added " + aFilePath); - OS.system("objj " + [self xCodeProjectParserURL] + " " + aFilePath + " " + m_xCodeSupportSourcesURL); + OS.system("objj " + [self xCodeProjectParserURL] + " " + aFilePath + " " + [self shadowURLForSourceURL:aFilePath]); }); [m_sourceResourceMonitor editedFilePaths].forEach(function(aFilePath) { print("Edited " + aFilePath); - OS.system("objj " + [self xCodeProjectParserURL] + " " + aFilePath + " " + m_xCodeSupportSourcesURL); + OS.system("objj " + [self xCodeProjectParserURL] + " " + aFilePath + " " + [self shadowURLForSourceURL:aFilePath]); }); [m_sourceResourceMonitor removedFilePaths].forEach(function(aFilePath) { - // delete? print("Removed " + aFilePath); - // OS.system("nib2cib " + aFilePath); + FILE.remove([self shadowURLForSourceURL:aFilePath]); }); } diff --git a/Tools/xcodecapp/XCResourceMonitor.j b/Tools/xcodecapp/XCResourceMonitor.j index 58ec88188..5de8af011 100644 --- a/Tools/xcodecapp/XCResourceMonitor.j +++ b/Tools/xcodecapp/XCResourceMonitor.j @@ -51,8 +51,8 @@ var FILE = require("file"), var filePath = nil, filePaths = [m_mtimesForFilePaths keyEnumerator]; - while (filePath = [filePath nextObject]) - if (![mtimesForFilePaths objectForKey:filePath] === nil) + while (filePath = [filePaths nextObject]) + if ([mtimesForFilePaths objectForKey:filePath] === nil) [m_removedFilePaths addObject:filePath]; m_mtimesForFilePaths = mtimesForFilePaths;