+2007-03-13 Mark Rowe <mrowe@apple.com>
+
+ Reviewed by Maciej.
+
+ Have the nightly launcher prefer Safari found in /Applications or ~/Applications
+ if present, otherwise fall back on using LaunchServices to locate it elsewhere
+ on the system. The motivation for this is to make the behaviour of the nightly
+ builds more predictable on machines with multiple copies of Safari present.
+
+ * WebKitLauncher/main.m:
+ (locateSafariBundle):
+ (main):
+
2007-03-12 Darin Adler <darin@apple.com>
Reviewed by Tim Hatcher.
execve([executable fileSystemRepresentation], argv, env);
}
-int main(int argc, char *argv[])
+NSBundle *locateSafariBundle()
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- checkMacOSXVersion();
+ NSArray *applicationDirectories = NSSearchPathForDirectoriesInDomains(NSApplicationDirectory, NSAllDomainsMask, YES);
+ NSEnumerator *e = [applicationDirectories objectEnumerator];
+ NSString *applicationDirectory;
+ while (applicationDirectory = [e nextObject]) {
+ NSString *possibleSafariPath = [applicationDirectory stringByAppendingPathComponent:@"Safari.app"];
+ NSBundle *possibleSafariBundle = [NSBundle bundleWithPath:possibleSafariPath];
+ if ([[possibleSafariBundle bundleIdentifier] isEqualToString:@"com.apple.Safari"])
+ return possibleSafariBundle;
+ }
CFURLRef safariURL = nil;
OSStatus err = LSFindApplicationForInfo(kLSUnknownCreator, CFSTR("com.apple.Safari"), nil, nil, &safariURL);
if (err != noErr)
displayErrorAndQuit(@"Unable to locate Safari", @"Nightly builds of WebKit require Safari to run. Please check that it is available and then try again.");
+ NSBundle *safariBundle = [NSBundle bundleWithPath:[(NSURL *)safariURL path]];
+ CFRelease(safariURL);
+ return safariBundle;
+}
+
+int main(int argc, char *argv[])
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ checkMacOSXVersion();
+
+ NSBundle *safariBundle = locateSafariBundle();
+ NSString *executablePath = [safariBundle executablePath];
NSString *frameworkPath = [[NSBundle mainBundle] resourcePath];
- NSString *executablePath = [[NSBundle bundleWithPath:[(NSURL *)safariURL path]] executablePath];
NSString *pathToEnablerLib = [[NSBundle mainBundle] pathForResource:@"WebKitNightlyEnabler" ofType:@"dylib"];
NSMutableArray *arguments = [NSMutableArray arrayWithObjects:executablePath, @"-WebKitDeveloperExtras", @"YES", @"-WebKitScriptDebuggerEnabled", @"YES", nil];
myExecve(executablePath, arguments, environment);
char *error = strerror(errno);
- NSString *errorMessage = [NSString stringWithFormat:@"Launching Safari at %@ failed with the error '%s' (%d)", [(NSURL *)safariURL path], error, errno];
+ NSString *errorMessage = [NSString stringWithFormat:@"Launching Safari at %@ failed with the error '%s' (%d)", [safariBundle bundlePath], error, errno];
displayErrorAndQuit(@"Unable to launch Safari", errorMessage);
[pool release];