diff --git a/Tools/XcodeCapp/Jakefile b/Tools/XcodeCapp/Jakefile index cc3301f8c..764cce92f 100644 --- a/Tools/XcodeCapp/Jakefile +++ b/Tools/XcodeCapp/Jakefile @@ -41,6 +41,17 @@ task ("build", function() if (OS.system("xcodebuild " + args)) OS.exit(1); + + if (!executableExists("xcc")) + { + print("\nWould you like to install the xcc command line tool in /usr/local/bin? yes or no:"); + + if (system.stdin.readLine() == "yes\n") + { + sudo(["mkdir", "-p", "/usr/local/bin"]); + sudo(["ln", "-s", "/Applications/XcodeCapp.app/Contents/MacOS/xcc", "/usr/local/bin/"]); + } + } } else { diff --git a/Tools/XcodeCapp/XcodeCapp.xcodeproj/project.pbxproj b/Tools/XcodeCapp/XcodeCapp.xcodeproj/project.pbxproj index 702fc3676..a82c07ba8 100644 --- a/Tools/XcodeCapp/XcodeCapp.xcodeproj/project.pbxproj +++ b/Tools/XcodeCapp/XcodeCapp.xcodeproj/project.pbxproj @@ -28,6 +28,10 @@ E170C40517298833003DC489 /* icon-error@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = E170C40017298833003DC489 /* icon-error@2x.png */; }; E170C40617298833003DC489 /* icon-inactive@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = E170C40117298833003DC489 /* icon-inactive@2x.png */; }; E170C40717298833003DC489 /* icon-working@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = E170C40217298833003DC489 /* icon-working@2x.png */; }; + E171D25F173C168C00210893 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E171D25E173C168C00210893 /* Foundation.framework */; }; + E171D262173C168C00210893 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E171D261173C168C00210893 /* main.m */; }; + E171D26A173C1ADD00210893 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E164FE1D1720F50100263CE3 /* CoreServices.framework */; }; + E171D26C173C1C8300210893 /* xcc in CopyFiles */ = {isa = PBXBuildFile; fileRef = E171D25D173C168C00210893 /* xcc */; }; E17A822D172700B90095CD83 /* XcodeCapp.iconset in Resources */ = {isa = PBXBuildFile; fileRef = E17A822C172700B90095CD83 /* XcodeCapp.iconset */; }; E17B55411732F57700809FFB /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E17B55401732F57700809FFB /* Quartz.framework */; }; E17B55431732F72700809FFB /* help.pdf in Resources */ = {isa = PBXBuildFile; fileRef = E17B55421732F72700809FFB /* help.pdf */; }; @@ -45,6 +49,16 @@ E1ED6B72173414E100641628 /* icon_128x128@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = E1ED6B70173414E100641628 /* icon_128x128@2x.png */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + E171D26D173C405C00210893 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = E164FDC71720E77100263CE3 /* Project object */; + proxyType = 1; + remoteGlobalIDString = E171D25C173C168C00210893; + remoteInfo = xcc; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXCopyFilesBuildPhase section */ E164FE201720F54800263CE3 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; @@ -68,6 +82,25 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + E171D25B173C168C00210893 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; + E171D26B173C1C6900210893 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 6; + files = ( + E171D26C173C1C8300210893 /* xcc in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ @@ -97,6 +130,10 @@ E170C40017298833003DC489 /* icon-error@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "icon-error@2x.png"; path = "Resources/icon-error@2x.png"; sourceTree = ""; }; E170C40117298833003DC489 /* icon-inactive@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "icon-inactive@2x.png"; path = "Resources/icon-inactive@2x.png"; sourceTree = ""; }; E170C40217298833003DC489 /* icon-working@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "icon-working@2x.png"; path = "Resources/icon-working@2x.png"; sourceTree = ""; }; + E171D25D173C168C00210893 /* xcc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = xcc; sourceTree = BUILT_PRODUCTS_DIR; }; + E171D25E173C168C00210893 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + E171D261173C168C00210893 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + E171D264173C168C00210893 /* xcc-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "xcc-Prefix.pch"; sourceTree = ""; }; E17A822C172700B90095CD83 /* XcodeCapp.iconset */ = {isa = PBXFileReference; lastKnownFileType = folder.iconset; name = XcodeCapp.iconset; path = Resources/XcodeCapp.iconset; sourceTree = ""; }; E17B55401732F57700809FFB /* Quartz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quartz.framework; path = System/Library/Frameworks/Quartz.framework; sourceTree = SDKROOT; }; E17B55421732F72700809FFB /* help.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; name = help.pdf; path = Resources/help.pdf; sourceTree = ""; }; @@ -137,6 +174,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + E171D25A173C168C00210893 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + E171D26A173C1ADD00210893 /* CoreServices.framework in Frameworks */, + E171D25F173C168C00210893 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -144,6 +190,7 @@ isa = PBXGroup; children = ( E164FDD81720E77100263CE3 /* XcodeCapp */, + E171D260173C168C00210893 /* xcc */, E164FDD11720E77100263CE3 /* Frameworks */, E164FDD01720E77100263CE3 /* Products */, ); @@ -153,6 +200,7 @@ isa = PBXGroup; children = ( E164FDCF1720E77100263CE3 /* XcodeCapp.app */, + E171D25D173C168C00210893 /* xcc */, ); name = Products; sourceTree = ""; @@ -163,6 +211,7 @@ E164FDD21720E77100263CE3 /* Cocoa.framework */, E164FE1D1720F50100263CE3 /* CoreServices.framework */, E164FDF61720EBD600263CE3 /* Growl.framework */, + E171D25E173C168C00210893 /* Foundation.framework */, E164FDD41720E77100263CE3 /* Other Frameworks */, ); name = Frameworks; @@ -246,6 +295,23 @@ path = Scripts; sourceTree = ""; }; + E171D260173C168C00210893 /* xcc */ = { + isa = PBXGroup; + children = ( + E171D261173C168C00210893 /* main.m */, + E171D263173C168C00210893 /* Supporting Files */, + ); + path = xcc; + sourceTree = ""; + }; + E171D263173C168C00210893 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + E171D264173C168C00210893 /* xcc-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; E1A55947172C5EA80088FB61 /* Operations */ = { isa = PBXGroup; children = ( @@ -282,16 +348,35 @@ E164FDCD1720E77100263CE3 /* Resources */, E164FE201720F54800263CE3 /* CopyFiles */, E170C3F9172961E6003DC489 /* CopyFiles */, + E171D26B173C1C6900210893 /* CopyFiles */, ); buildRules = ( ); dependencies = ( + E171D26E173C405C00210893 /* PBXTargetDependency */, ); name = XcodeCapp; productName = XcodeCapp; productReference = E164FDCF1720E77100263CE3 /* XcodeCapp.app */; productType = "com.apple.product-type.application"; }; + E171D25C173C168C00210893 /* xcc */ = { + isa = PBXNativeTarget; + buildConfigurationList = E171D269173C168C00210893 /* Build configuration list for PBXNativeTarget "xcc" */; + buildPhases = ( + E171D259173C168C00210893 /* Sources */, + E171D25A173C168C00210893 /* Frameworks */, + E171D25B173C168C00210893 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = xcc; + productName = xcc; + productReference = E171D25D173C168C00210893 /* xcc */; + productType = "com.apple.product-type.tool"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -314,6 +399,7 @@ projectRoot = ""; targets = ( E164FDCE1720E77100263CE3 /* XcodeCapp */, + E171D25C173C168C00210893 /* xcc */, ); }; /* End PBXProject section */ @@ -364,8 +450,24 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + E171D259173C168C00210893 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E171D262173C168C00210893 /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + E171D26E173C405C00210893 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = E171D25C173C168C00210893 /* xcc */; + targetProxy = E171D26D173C405C00210893 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin PBXVariantGroup section */ E1E90C60173B42D0005C6D5B /* MainMenu.xib */ = { isa = PBXVariantGroup; @@ -426,6 +528,72 @@ }; name = Release; }; + E171D267173C168C00210893 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "xcc/xcc-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.8; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Debug; + }; + E171D268173C168C00210893 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEPLOYMENT_LOCATION = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "xcc/xcc-Prefix.pch"; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.8; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -447,6 +615,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + E171D269173C168C00210893 /* Build configuration list for PBXNativeTarget "xcc" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E171D267173C168C00210893 /* Debug */, + E171D268173C168C00210893 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = E164FDC71720E77100263CE3 /* Project object */; diff --git a/Tools/XcodeCapp/XcodeCapp/AppController.h b/Tools/XcodeCapp/XcodeCapp/AppController.h index b90190ae5..e07a10a81 100644 --- a/Tools/XcodeCapp/XcodeCapp/AppController.h +++ b/Tools/XcodeCapp/XcodeCapp/AppController.h @@ -44,7 +44,7 @@ - (IBAction)openHelp:(id)aSender; - (IBAction)openAbout:(id)aSender; -- (void)loadProjectAtPath:(NSString *)path; +- (BOOL)loadProjectAtPath:(NSString *)path; @end diff --git a/Tools/XcodeCapp/XcodeCapp/AppController.m b/Tools/XcodeCapp/XcodeCapp/AppController.m index cfe32157f..b7051f78e 100644 --- a/Tools/XcodeCapp/XcodeCapp/AppController.m +++ b/Tools/XcodeCapp/XcodeCapp/AppController.m @@ -37,6 +37,8 @@ AppController *SharedAppControllerInstance = nil; @property (nonatomic) NSMenu *recentMenu; @property NSStatusItem *statusItem; @property NSString *finderName; +@property BOOL appFinishedLaunching; +@property NSString *pathToOpenAtLaunch; @end @@ -68,8 +70,25 @@ AppController *SharedAppControllerInstance = nil; [self checkFirstLaunch]; } +- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename +{ + if (filename) + { + NSString *path = filename.stringByStandardizingPath; + + if (self.appFinishedLaunching) + return [self loadProjectAtPath:path]; + else + self.pathToOpenAtLaunch = path; + } + + return YES; +} + - (void)applicationDidFinishLaunching:(NSNotification *)notification { + self.appFinishedLaunching = YES; + if (![self.xcc executablesAreAccessible]) { [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; @@ -80,17 +99,21 @@ AppController *SharedAppControllerInstance = nil; return; } + // If we were opened from the command line, xcc.projectPath will be set. NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - - if (![defaults boolForKey:kDefaultXCCReopenLastProject]) - return; - - NSString *lastOpenedPath = [defaults objectForKey:kDefaultLastOpenedPath]; - - if (lastOpenedPath) + + if (!self.pathToOpenAtLaunch) { - if ([[NSFileManager defaultManager] fileExistsAtPath:lastOpenedPath]) - [self loadProjectAtPath:lastOpenedPath]; + if (![defaults boolForKey:kDefaultXCCReopenLastProject]) + return; + + self.pathToOpenAtLaunch = [defaults objectForKey:kDefaultLastOpenedPath]; + } + + if (self.pathToOpenAtLaunch) + { + if ([[NSFileManager defaultManager] fileExistsAtPath:self.pathToOpenAtLaunch]) + [self loadProjectAtPath:self.pathToOpenAtLaunch]; else [defaults removeObjectForKey:kDefaultLastOpenedPath]; } @@ -403,10 +426,10 @@ AppController *SharedAppControllerInstance = nil; #pragma mark - Private Helpers -- (void)loadProjectAtPath:(NSString *)path +- (BOOL)loadProjectAtPath:(NSString *)path { if ([self.xcc.projectPath isEqualToString:path]) - return; + return YES; [self closeProject:self]; @@ -437,7 +460,12 @@ AppController *SharedAppControllerInstance = nil; [self updateHistoryMenu]; if (exists && isDirectory) + { [self.xcc loadProjectAtPath:path]; + return YES; + } + else + return NO; } - (void)openWindow:(NSWindow *)aWindow diff --git a/Tools/XcodeCapp/XcodeCapp/Info.plist b/Tools/XcodeCapp/XcodeCapp/Info.plist index 09736b23d..384395ab0 100644 --- a/Tools/XcodeCapp/XcodeCapp/Info.plist +++ b/Tools/XcodeCapp/XcodeCapp/Info.plist @@ -17,11 +17,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 3.0.2 + 3.0.3 CFBundleSignature ???? CFBundleVersion - 3.0.2 + 3.0.3 LSApplicationCategoryType public.app-category.developer-tools LSUIElement diff --git a/Tools/XcodeCapp/XcodeCapp/Resources/XcodeCapp help.pages b/Tools/XcodeCapp/XcodeCapp/Resources/XcodeCapp help.pages index f397df57a..c0fba7f8b 100644 Binary files a/Tools/XcodeCapp/XcodeCapp/Resources/XcodeCapp help.pages and b/Tools/XcodeCapp/XcodeCapp/Resources/XcodeCapp help.pages differ diff --git a/Tools/XcodeCapp/XcodeCapp/Resources/help.pdf b/Tools/XcodeCapp/XcodeCapp/Resources/help.pdf index 753e4b1e7..c9325748e 100644 Binary files a/Tools/XcodeCapp/XcodeCapp/Resources/help.pdf and b/Tools/XcodeCapp/XcodeCapp/Resources/help.pdf differ diff --git a/Tools/XcodeCapp/xcc/main.m b/Tools/XcodeCapp/xcc/main.m new file mode 100644 index 000000000..ba912c8f9 --- /dev/null +++ b/Tools/XcodeCapp/xcc/main.m @@ -0,0 +1,56 @@ +// +// main.m +// xcc +// +// Created by Aparajita on 5/9/13. +// Copyright (c) 2013 Cappuccino Project. All rights reserved. +// + +#import + +int main(int argc, const char * argv[]) +{ + @autoreleasepool + { + BOOL validArgs = argc == 1; + NSMutableArray *arguments = [[NSMutableArray alloc] initWithObjects:@"-b", @"org.cappuccino.xcodecapp", @"-g", nil]; + + if (argc > 1) + { + const char *arg = argv[1]; + + if (arg[0] == '-') + { + printf("Usage: xcc [--help | directory]\n"); + } + else + { + NSString *path = [[NSString stringWithUTF8String:arg] stringByStandardizingPath]; + NSFileManager *fm = [NSFileManager defaultManager]; + BOOL isDirectory; + BOOL exists = [fm fileExistsAtPath:path isDirectory:&isDirectory]; + + if (!exists) + fprintf(stderr, "%s: no such file or directory\n", arg); + else if (!isDirectory) + fprintf(stderr, "%s is not a directory\n", arg); + else + { + validArgs = YES; + [arguments addObject:path]; + } + } + } + + if (validArgs) + { + NSTask *task = [[NSTask alloc] init]; + task.launchPath = @"/usr/bin/open"; + task.arguments = arguments; + [task launch]; + } + } + + return 0; +} + diff --git a/Tools/XcodeCapp/xcc/xcc-Prefix.pch b/Tools/XcodeCapp/xcc/xcc-Prefix.pch new file mode 100644 index 000000000..3ab4e33a8 --- /dev/null +++ b/Tools/XcodeCapp/xcc/xcc-Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'xcc' target in the 'xcc' project +// + +#ifdef __OBJC__ + #import +#endif