diff --git a/Tools/XcodeCapp/FSEventCallback.m b/Tools/XcodeCapp/FSEventCallback.m index 6c3c87938..f457b6a85 100644 --- a/Tools/XcodeCapp/FSEventCallback.m +++ b/Tools/XcodeCapp/FSEventCallback.m @@ -43,7 +43,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, NSString *path = [[(NSArray *)eventPaths objectAtIndex:i] stringByStandardizingPath]; if (useFileBasedListening) - { + { if (flags & kFSEventStreamEventFlagItemIsFile && flags & kFSEventStreamEventFlagItemRemoved) { diff --git a/Tools/XcodeCapp/TNXCodeCapp.m b/Tools/XcodeCapp/TNXCodeCapp.m index 0953d0768..22d40a7dd 100644 --- a/Tools/XcodeCapp/TNXCodeCapp.m +++ b/Tools/XcodeCapp/TNXCodeCapp.m @@ -68,7 +68,7 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification [self setSupportFileLevelAPI:versionMajor >= 10 && versionMinor >= 7]; // Uncomment to simulate 10.6 mode - [self setSupportFileLevelAPI:NO]; + // [self setSupportFileLevelAPI:NO]; [self configure]; @@ -277,11 +277,14 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification */ - (void)handleFileModification:(NSString*)fullPath notify:(BOOL)shouldNotify { + if (![self isXIBFile:fullPath] && ![self isObjJFile:fullPath] && ![self isXCCIgnoreFile:fullPath]) + return; + if ([self isPathMatchingIgnoredPaths:fullPath] || ![fm fileExistsAtPath:fullPath]) return; - + DLog(@"Parsing modified file: %@", fullPath); - + NSArray *arguments = nil; NSString *successTitle = nil; NSString *successMsg = nil; @@ -292,58 +295,54 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification DLog(@"Shadow path: %@", shadowPath); - if ([self isXIBFile:fullPath] || [self isObjJFile:fullPath] || [self isXCCIgnoreFile:fullPath]) + [[NSNotificationCenter defaultCenter] postNotificationName:XCCConversionStartNotification object:self]; + + if ([self isXIBFile:fullPath]) { - [[NSNotificationCenter defaultCenter] postNotificationName:XCCConversionStartNotification object:self]; - - if ([self isXIBFile:fullPath]) - { - 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]; - successTitle = @"Objective-J source processed"; - successMsg = splitPath; - } - else if ([self isXCCIgnoreFile:fullPath]) - { - [self computeIgnoredPaths]; - successTitle = @".xcodecapp-ignore processed"; - successMsg = @"Ignored files list updated"; - arguments = nil; - } - - // Run the task and get the response if needed - if (arguments) - { - DLog(@"Running task..."); - NSArray *statusInfo = [self runTask:arguments]; - - status = [statusInfo objectAtIndex:0]; - response = [statusInfo objectAtIndex:1]; - - DLog(@"Task result/response: %@/%@", status, response); - } - - - if ([status intValue] == 0 && shouldNotify) - { - [delegate performSelector:@selector(growlWithTitle:message:) withObject:successTitle withObject:successMsg]; - } - else if (![status intValue] == 0) - { - if (response) - [errorList addObject:response]; - - [delegate performSelector:@selector(growlWithTitle:message:) withObject:@"Error processing file" withObject:splitPath]; - } - - [[NSNotificationCenter defaultCenter] postNotificationName:XCCConversionStopNotification object:self]; - DLog(@"Processed: %@", fullPath); + 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]; + successTitle = @"Objective-J source processed"; + successMsg = splitPath; + } + else if ([self isXCCIgnoreFile:fullPath]) + { + [self computeIgnoredPaths]; + successTitle = @".xcodecapp-ignore processed"; + successMsg = @"Ignored files list updated"; + arguments = nil; + } + + // Run the task and get the response if needed + if (arguments) + { + DLog(@"Running task..."); + NSArray *statusInfo = [self runTask:arguments]; + + status = [statusInfo objectAtIndex:0]; + response = [statusInfo objectAtIndex:1]; + + DLog(@"Task result/response: %@/%@", status, response); + } + + if ([status intValue] == 0 && shouldNotify) + { + [delegate performSelector:@selector(growlWithTitle:message:) withObject:successTitle withObject:successMsg]; + } + else if (![status intValue] == 0) + { + if (response) + [errorList addObject:response]; + + [delegate performSelector:@selector(growlWithTitle:message:) withObject:@"Error processing file" withObject:splitPath]; + } + + [[NSNotificationCenter defaultCenter] postNotificationName:XCCConversionStopNotification object:self]; + DLog(@"Processed: %@", fullPath); } /*! @@ -443,7 +442,7 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification [PBXContent writeToFile:XCodeSupportPBXPath atomically:YES encoding:NSUTF8StringEncoding error:nil]; DLog(@"PBX file adapted to the project"); - DLog(@"Creating source folder"); + DLog(@"Creating source folder %@", [XCodeSupportProjectSources path]); [fm createDirectoryAtPath:[XCodeSupportProjectSources path] withIntermediateDirectories:YES attributes:nil error:nil]; return NO; } @@ -471,11 +470,10 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification BOOL isDir = NO; [fm fileExistsAtPath:filePath isDirectory:&isDir]; - if (isDir - || (![self isXIBFile:filePath] && ![self isObjJFile:filePath])) + if (isDir || (![self isXIBFile:filePath] && ![self isObjJFile:filePath])) continue; - NSURL *eventualShadow = [self shadowURLForSourceURL:[NSURL URLWithString:filePath]]; + NSURL *eventualShadow = [self shadowURLForSourceURL:[NSURL fileURLWithPath:filePath]]; if (![fm fileExistsAtPath:[eventualShadow path]]) { @@ -539,7 +537,7 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification options:0 range:NSMakeRange(0, [unshadowedPath length])]; - return [NSURL URLWithString:[NSString stringWithString:unshadowedPath]]; + return [NSURL fileURLWithPath:[NSString stringWithString:unshadowedPath]]; } @@ -585,31 +583,35 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification { if ([ignoredPath length] == 0) continue; - - NSMutableString *regexp = [NSMutableString stringWithFormat:@"%@/%@", [currentProjectURL path], ignoredPath]; + + NSMutableString *regexp = [ignoredPath mutableCopy]; + [regexp replaceOccurrencesOfString:@"/" withString:@"\\/" options:0 range:NSMakeRange(0, [regexp length])]; - + [regexp replaceOccurrencesOfString:@"." withString:@"\\." options:0 range:NSMakeRange(0, [regexp length])]; - + [regexp replaceOccurrencesOfString:@"*" withString:@".*" options:0 range:NSMakeRange(0, [regexp length])]; - + + [regexp replaceOccurrencesOfString:@" " + withString:@"\\ " + options:0 + range:NSMakeRange(0, [regexp length])]; + NSPredicate *regextest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regexp]; - + if ([regextest evaluateWithObject:aPath]) - { return YES; - } } - + return NO; } @@ -621,8 +623,8 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification { NSMutableString *tempName = [NSMutableString stringWithString:[path lastPathComponent]]; - currentProjectURL = [NSURL URLWithString:path]; - + currentProjectURL = [NSURL fileURLWithPath:path]; + [tempName replaceOccurrencesOfString:@" " withString:@"_" options:NSCaseInsensitiveSearch @@ -654,7 +656,7 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification { NSString *unshadowed = [[self sourceURLForShadowName:subpath] path]; NSString *shadowFullPath = [NSString stringWithFormat:@"%@/%@", [XCodeSupportProjectSources path], subpath]; - + if (![fm fileExistsAtPath:unshadowed]) { DLog(@"cleaning shadow file: %@", subpath);