Skip to content

Commit

Permalink
make XcodeCapp compatible with Xcode 4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
primalmotion committed Aug 9, 2012
1 parent bf6c0c9 commit ea31bd2
Show file tree
Hide file tree
Showing 2 changed files with 417 additions and 16 deletions.
79 changes: 63 additions & 16 deletions Tools/XcodeCapp/TNXCodeCapp.m
Expand Up @@ -318,6 +318,7 @@ - (void)handleFileModification:(NSString*)fullPath notify:(BOOL)shouldNotify
DLog(@"Parsing modified file: %@", fullPath);

NSArray *arguments = nil;
NSArray *PBXArguments = nil;
NSString *successTitle = nil;
NSString *successMsg = nil;
NSString *response = nil;
Expand All @@ -331,13 +332,29 @@ - (void)handleFileModification:(NSString*)fullPath notify:(BOOL)shouldNotify

if ([self isXIBFile:fullPath])
{
arguments = [NSArray arrayWithObjects: @"-c", [NSString stringWithFormat:@"(%@; nib2cib '%@';) 2>&1", profilePath, fullPath],@"",nil];
arguments = [NSArray arrayWithObjects: @"-c",
[NSString stringWithFormat:@"(%@; nib2cib '%@';) 2>&1", profilePath, fullPath],@"",nil];

successTitle = @"XIB converted";
successMsg = splitPath;
}
else if ([self isObjJFile:fullPath])
{
arguments = [NSArray arrayWithObjects: @"-c", [NSString stringWithFormat:@"(%@; objj '%@' '%@' '%@';) 2>&1", profilePath, parserPath, fullPath, shadowPath],@"",nil];
arguments = [NSArray arrayWithObjects: @"-c",
[NSString stringWithFormat:@"(%@; objj '%@' '%@' '%@';) 2>&1",
profilePath,
parserPath,
fullPath,
shadowPath],
@"",nil];

PBXArguments = [NSArray arrayWithObjects: @"-c",
[NSString stringWithFormat:@"(%@; python %@ add '%@' '%@') 2>&1",
profilePath,
PBXModifierScriptPath,
XCodeSupportPBXPath,
shadowPath],nil];

successTitle = @"Objective-J source processed";
successMsg = splitPath;
}
Expand All @@ -352,13 +369,22 @@ - (void)handleFileModification:(NSString*)fullPath notify:(BOOL)shouldNotify
// Run the task and get the response if needed
if (arguments)
{
DLog(@"Running task...");
DLog(@"Running conversion task...");
NSArray *statusInfo = [self runTask:arguments];

status = [statusInfo objectAtIndex:0];
response = [statusInfo objectAtIndex:1];

DLog(@"Task result/response: %@/%@", status, response);
DLog(@"Conversion task result/response: %@/%@", status, response);
}

if (PBXArguments)
{
DLog(@"Running update PBX task...");
NSArray *statusInfo = [self runTask:PBXArguments];
status = [statusInfo objectAtIndex:0];
response = [statusInfo objectAtIndex:1];
DLog(@"Update PBX Task result/response: %@/%@", status, response);
}

if ([status intValue] == 0 && shouldNotify)
Expand Down Expand Up @@ -393,8 +419,21 @@ - (void)handleFileRemoval:(NSString*)fullPath
{
NSString *shadowPath = [[self shadowURLForSourceURL:[NSURL URLWithString:[fullPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]] path];

[fm removeItemAtPath:shadowPath error:nil];
NSArray *PBXArguments = [NSArray arrayWithObjects: @"-c",
[NSString stringWithFormat:@"(%@; python %@ remove '%@' '%@') 2>&1",
profilePath,
PBXModifierScriptPath,
XCodeSupportPBXPath,
shadowPath],nil];

DLog(@"Removing shadow file: %@", shadowPath);
[fm removeItemAtPath:shadowPath error:nil];

DLog(@"Removing PBX reference task...");
NSArray *statusInfo = [self runTask:PBXArguments];
NSNumber *status = [statusInfo objectAtIndex:0];
NSString *response = [statusInfo objectAtIndex:1];
DLog(@"PBX Reference removal status/response: %@/%@", status, response);
}
else if ([self isXCCIgnoreFile:fullPath])
{
Expand Down Expand Up @@ -445,15 +484,17 @@ - (BOOL)prepareXCodeSupportProject
{
XCodeSupportProjectName = [NSString stringWithFormat:@"%@.xcodeproj/", currentProjectName];
XCodeTemplatePBXPath = [[NSBundle mainBundle] pathForResource:@"project.pbxproj" ofType:@"sample"];
XCodeSupportFolder = [NSURL URLWithString:@".xCodeSupport/" relativeToURL:currentProjectURL];
XCodeSupportFolder = currentProjectURL;
XCodeSupportProject = [NSURL URLWithString:XCodeSupportProjectName relativeToURL:XCodeSupportFolder];
XCodeSupportProjectSources = [NSURL URLWithString:@"Sources/" relativeToURL:XCodeSupportFolder];
XCodeSupportProjectSources = [NSURL URLWithString:@"XcodeSupport/" relativeToURL:XCodeSupportFolder];
XCodeSupportPBXPath = [NSString stringWithFormat:@"%@/project.pbxproj", [XCodeSupportProject path]];
PBXModifierScriptPath = [[NSBundle mainBundle] pathForResource:@"pbxprojModifier" ofType:@"py"];


//[fm removeItemAtURL:XCodeSupportFolder error:nil];

// create the template project if it doesn't exist
if (![fm fileExistsAtPath:[XCodeSupportFolder path]])
if (![fm fileExistsAtPath:[XCodeSupportProjectSources path]])
{
NSLog(@"Xcode support folder created at: %@", [XCodeSupportProject path]);
[fm createDirectoryAtPath:[XCodeSupportProject path] withIntermediateDirectories:YES attributes:nil error:nil];
Expand All @@ -463,14 +504,6 @@ - (BOOL)prepareXCodeSupportProject

DLog(@"Reading the content of the project.pbxproj");
NSMutableString *PBXContent = [NSMutableString stringWithContentsOfFile:XCodeSupportPBXPath encoding:NSUTF8StringEncoding error:nil];
[PBXContent replaceOccurrencesOfString:@"${CappuccinoProjectName}"
withString:currentProjectName
options:NSCaseInsensitiveSearch
range:NSMakeRange(0, [PBXContent length])];
[PBXContent replaceOccurrencesOfString:@"${CappuccinoProjectRelativePath}"
withString:@".."
options:NSCaseInsensitiveSearch
range:NSMakeRange(0, [PBXContent length])];

[PBXContent writeToFile:XCodeSupportPBXPath atomically:YES encoding:NSUTF8StringEncoding error:nil];
DLog(@"PBX file adapted to the project");
Expand Down Expand Up @@ -614,6 +647,7 @@ - (void)computeIgnoredPaths
[ignoredFilePaths addObject:@"*/.xCodeSupport/*"];
[ignoredFilePaths addObject:@"*/Build/*"];
[ignoredFilePaths addObject:@"*/NS_*.j"];
[ignoredFilePaths addObject:@"*main.j"];

NSLog(@"Ignoring file paths: %@", ignoredFilePaths);
}
Expand Down Expand Up @@ -710,6 +744,19 @@ - (void)tidyShadowedFiles
{
DLog(@"cleaning shadow file: %@", subpath);
[fm removeItemAtPath:shadowFullPath error:nil];

NSArray *PBXArguments = [NSArray arrayWithObjects: @"-c",
[NSString stringWithFormat:@"(%@; python %@ remove '%@' '%@') 2>&1",
profilePath,
PBXModifierScriptPath,
XCodeSupportPBXPath,
shadowFullPath],nil];

DLog(@"Cleaning PBX reference task...");
NSArray *statusInfo = [self runTask:PBXArguments];
NSNumber *status = [statusInfo objectAtIndex:0];
NSString *response = [statusInfo objectAtIndex:1];
DLog(@"PBX Reference cleaning status/response: %@/%@", status, response);

if (![self supportFileLevelAPI] && [self respondsToSelector:@selector(updateLastModificationDate:forPath:)])
[self performSelector:@selector(updateLastModificationDate:forPath:) withObject:nil withObject:unshadowed];
Expand Down

0 comments on commit ea31bd2

Please sign in to comment.