diff --git a/Tools/XcodeCapp/XcodeCapp/AppController.m b/Tools/XcodeCapp/XcodeCapp/AppController.m index 3586512c1..8cbb1689b 100644 --- a/Tools/XcodeCapp/XcodeCapp/AppController.m +++ b/Tools/XcodeCapp/XcodeCapp/AppController.m @@ -150,7 +150,8 @@ AppController *SharedAppControllerInstance = nil; kDefaultMaxRecentProjects: @20, kDefaultLogLevel: [NSNumber numberWithInt:LOG_LEVEL_WARN], kDefaultAutoOpenXcodeProject: @YES, - kDefaultShowProcessingNotices: @YES + kDefaultShowProcessingNotices: @YES, + kDefaultUseSymlinkWhenCreatingProject: @YES }; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; diff --git a/Tools/XcodeCapp/XcodeCapp/UserDefaults.h b/Tools/XcodeCapp/XcodeCapp/UserDefaults.h index 8811b97f4..7e7726099 100644 --- a/Tools/XcodeCapp/XcodeCapp/UserDefaults.h +++ b/Tools/XcodeCapp/XcodeCapp/UserDefaults.h @@ -26,5 +26,6 @@ extern NSString * const kDefaultMaxRecentProjects; extern NSString * const kDefaultLogLevel; extern NSString * const kDefaultAutoOpenXcodeProject; extern NSString * const kDefaultShowProcessingNotices; +extern NSString * const kDefaultUseSymlinkWhenCreatingProject; #endif diff --git a/Tools/XcodeCapp/XcodeCapp/UserDefaults.m b/Tools/XcodeCapp/XcodeCapp/UserDefaults.m index 7d0c5651a..4701d7052 100644 --- a/Tools/XcodeCapp/XcodeCapp/UserDefaults.m +++ b/Tools/XcodeCapp/XcodeCapp/UserDefaults.m @@ -24,3 +24,4 @@ NSString * const kDefaultMaxRecentProjects = @"maxRecentProjects"; NSString * const kDefaultLogLevel = @"logLevel"; NSString * const kDefaultAutoOpenXcodeProject = @"autoOpenXcodeProject"; NSString * const kDefaultShowProcessingNotices = @"showProcessingNotices"; +NSString * const kDefaultUseSymlinkWhenCreatingProject = @"useSymlinkWhenCreatingProject"; diff --git a/Tools/XcodeCapp/XcodeCapp/XcodeCapp.h b/Tools/XcodeCapp/XcodeCapp/XcodeCapp.h index a8ae9e3e7..f6a5df812 100644 --- a/Tools/XcodeCapp/XcodeCapp/XcodeCapp.h +++ b/Tools/XcodeCapp/XcodeCapp/XcodeCapp.h @@ -79,6 +79,9 @@ extern NSString * const XCCProjectDidFinishLoadingNotification; // Full path to pbxprojModifier.py @property NSString *pbxModifierScriptPath; +// Tooltip for the radio button symlink +@property NSString *toolTipSymlinkRadioButton; + // Full paths to the executables we rely on: jsc, objj, nib2cib, python @property NSMutableDictionary *executablePaths; @@ -97,6 +100,9 @@ extern NSString * const XCCProjectDidFinishLoadingNotification; // Whether we are currently processing source files @property BOOL isProcessing; +// Whether $CAPP_BUILD is defined or not +@property BOOL isCappBuildDefined; + // A mapping from full paths to project-relative paths @property NSMutableDictionary *projectPathsForSourcePaths; diff --git a/Tools/XcodeCapp/XcodeCapp/XcodeCapp.m b/Tools/XcodeCapp/XcodeCapp/XcodeCapp.m index 6ad288bc5..b6177f746 100644 --- a/Tools/XcodeCapp/XcodeCapp/XcodeCapp.m +++ b/Tools/XcodeCapp/XcodeCapp/XcodeCapp.m @@ -187,6 +187,8 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, self.pbxOperations = [NSMutableDictionary new]; self.executablePaths = [NSMutableDictionary new]; self.projectPathFileDescriptor = -1; + self.isCappBuildDefined = YES; + self.toolTipSymlinkRadioButton = @"If this is checked, when a Cappuccino project is created, the frameworks of the new project will be symlinked from the $CAPP_BUILD"; [self initTaskEnvironment]; @@ -240,6 +242,28 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, self.environment[@"NARWHAL_ENGINE"] = @"jsc"; self.executables = @[@"python", @"narwhal-jsc", @"objj", @"nib2cib", @"capp"]; + + // This is used to get the env var of $CAPP_BUILD + NSDictionary *processEnvironment = [[NSProcessInfo processInfo] environment]; + NSArray *arguments = [NSArray arrayWithObjects:@"-l", @"-c", @"echo $CAPP_BUID", nil]; + + NSDictionary *taskResult = [self runTaskWithLaunchPath:[processEnvironment objectForKey:@"SHELL"] + arguments:arguments + returnType:kTaskReturnTypeStdOut]; + + // Make sure to remove the \n at the end of the response + NSString *response = [taskResult[@"response"] stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]]; + + self.environment[@"CAPP_BUILD"] = response; + + // Make sure we have found a CAPP_BUILD + if ([response length] == 0 || [taskResult[@"status"] intValue] == -1) + { + self.toolTipSymlinkRadioButton = @"To use this option you need to have the variable $CAPP_BUILD in your environement (export CAPP_BUILD='path/to/your/cappuccino/build')"; + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + [defaults setObject:@NO forKey:kDefaultUseSymlinkWhenCreatingProject]; + self.isCappBuildDefined = NO; + } } - (void)initObservers @@ -576,15 +600,20 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, - (NSDictionary*)createProject:(NSString*)aPath { + NSDictionary *taskResult; + NSMutableArray *arguments = [NSMutableArray arrayWithObjects:@"gen", aPath ,@"-t", @"NibApplication", nil]; + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + // This is used when an user wants to replace an existing project NSArray *argumentsRemove = [NSArray arrayWithObjects:@"-rf", aPath, nil]; [self runTaskWithLaunchPath:@"/bin/rm" arguments:argumentsRemove returnType:kTaskReturnTypeAny]; - // Don't know if we have to use the argument -l or not. In this case we should add $CAPP_BUILD in the taskEnv - NSArray *arguments = [NSArray arrayWithObjects:@"gen", aPath ,@"-t", @"NibApplication", nil]; - NSDictionary *taskResult = [self runTaskWithLaunchPath:self.executablePaths[@"capp"] - arguments:arguments - returnType:kTaskReturnTypeStdOut]; + if ([defaults boolForKey:kDefaultUseSymlinkWhenCreatingProject]) + [arguments addObject:@"-l"]; + + taskResult = [self runTaskWithLaunchPath:self.executablePaths[@"capp"] + arguments:arguments + returnType:kTaskReturnTypeStdOut]; NSInteger status = [taskResult[@"status"] intValue]; NSString *response = taskResult[@"response"]; diff --git a/Tools/XcodeCapp/XcodeCapp/en.lproj/MainMenu.xib b/Tools/XcodeCapp/XcodeCapp/en.lproj/MainMenu.xib index 6bad9c7a7..cd4fdb455 100644 --- a/Tools/XcodeCapp/XcodeCapp/en.lproj/MainMenu.xib +++ b/Tools/XcodeCapp/XcodeCapp/en.lproj/MainMenu.xib @@ -241,17 +241,17 @@ Original Cocoa version developed by: - + - + - + - + + @@ -298,7 +315,7 @@ Original Cocoa version developed by: - + @@ -393,7 +410,7 @@ Original Cocoa version developed by: - + @@ -408,6 +425,7 @@ Original Cocoa version developed by: + @@ -421,6 +439,7 @@ Original Cocoa version developed by: + @@ -436,4 +455,40 @@ Original Cocoa version developed by: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file