From 570be9f39a71db98d958d461ca0c68836a8b426f Mon Sep 17 00:00:00 2001 From: "dbates@webkit.org" Date: Sat, 1 Oct 2011 01:40:31 +0000 Subject: [PATCH] Cleanup: Extract code to launch a Mac WebKit application into a common function https://bugs.webkit.org/show_bug.cgi?id=68662 Reviewed by Adam Roben. Extracts common code to launch a WebKit application on Mac OS X into a function so that we can remove duplicate code. * Scripts/run-webkit-app: Modified to use webkitdirs::runMacWebKitApp(). * Scripts/webkitdirs.pm: Sorted @EXPORT list and added constant USE_OPEN_COMMAND. (runMacWebKitApp): Added. (runSafari): Modified to use webkitdirs::runMacWebKitApp(). (runMiniBrowser): Ditto. (runWebKitTestRunner): Ditto. (runTestWebKitAPI): Ditto. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96448 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Tools/ChangeLog | 18 ++++++++++ Tools/Scripts/run-webkit-app | 10 ++---- Tools/Scripts/webkitdirs.pm | 80 +++++++++++++++++++++----------------------- 3 files changed, 59 insertions(+), 49 deletions(-) diff --git a/Tools/ChangeLog b/Tools/ChangeLog index a926771..004c22c 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,3 +1,21 @@ +2011-09-30 Daniel Bates + + Cleanup: Extract code to launch a Mac WebKit application into a common function + https://bugs.webkit.org/show_bug.cgi?id=68662 + + Reviewed by Adam Roben. + + Extracts common code to launch a WebKit application on Mac OS X into a function + so that we can remove duplicate code. + + * Scripts/run-webkit-app: Modified to use webkitdirs::runMacWebKitApp(). + * Scripts/webkitdirs.pm: Sorted @EXPORT list and added constant USE_OPEN_COMMAND. + (runMacWebKitApp): Added. + (runSafari): Modified to use webkitdirs::runMacWebKitApp(). + (runMiniBrowser): Ditto. + (runWebKitTestRunner): Ditto. + (runTestWebKitAPI): Ditto. + 2011-09-29 David Levin watchlist: Add webkit-patch command to run watchlist. diff --git a/Tools/Scripts/run-webkit-app b/Tools/Scripts/run-webkit-app index 452c44c..17a624b 100755 --- a/Tools/Scripts/run-webkit-app +++ b/Tools/Scripts/run-webkit-app @@ -34,17 +34,11 @@ use lib $FindBin::Bin; use webkitdirs; setConfiguration(); -my $productDir = productDir(); die "Did not specify an application to open (e.g. run-webkit-app AppName).\n" unless length($ARGV[0]) > 0; # Check to see that all the frameworks are built. checkFrameworks(); -# Set up DYLD_FRAMEWORK_PATH to point to the product directory. -print "Start $ARGV[0] with DYLD_FRAMEWORK_PATH set to point to built WebKit in $productDir.\n"; -$ENV{DYLD_FRAMEWORK_PATH} = $productDir; -$ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES"; - -unshift(@ARGV, "-a"); -exec "open", @ARGV; +my $appPath = shift(@ARGV); +exit exitStatus(runMacWebKitApp($appPath, USE_OPEN_COMMAND)); diff --git a/Tools/Scripts/webkitdirs.pm b/Tools/Scripts/webkitdirs.pm index 955addc..bf0c20b 100644 --- a/Tools/Scripts/webkitdirs.pm +++ b/Tools/Scripts/webkitdirs.pm @@ -43,11 +43,27 @@ BEGIN { our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); $VERSION = 1.00; @ISA = qw(Exporter); - @EXPORT = qw(&chdirWebKit &baseProductDir &productDir &XcodeOptions &XcodeOptionString &XcodeOptionStringNoConfig &passedConfiguration &setConfiguration &safariPath &checkFrameworks ¤tSVNRevision); + @EXPORT = qw( + &XcodeOptionString + &XcodeOptionStringNoConfig + &XcodeOptions + &baseProductDir + &chdirWebKit + &checkFrameworks + ¤tSVNRevision + &passedConfiguration + &productDir + &runMacWebKitApp + &safariPath + &setConfiguration + USE_OPEN_COMMAND + ); %EXPORT_TAGS = ( ); @EXPORT_OK = (); } +use constant USE_OPEN_COMMAND => 1; # Used in runMacWebKitApp(). + our @EXPORT_OK; my $architecture; @@ -2000,22 +2016,31 @@ sub setPathForRunningWebKitApp } } +sub runMacWebKitApp($;$) +{ + my ($appPath, $useOpenCommand) = @_; + my $productDir = productDir(); + print "Starting @{[basename($appPath)]} with DYLD_FRAMEWORK_PATH set to point to built WebKit in $productDir.\n"; + $ENV{DYLD_FRAMEWORK_PATH} = $productDir; + $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES"; + if ($useOpenCommand == USE_OPEN_COMMAND) { + return system("open", "-W", "-a", $appPath, "--args", @ARGV); + } + if (architecture()) { + return system "arch", "-" . architecture(), $appPath, @ARGV; + } + return system { $appPath } $appPath, @ARGV; +} + sub runSafari { my ($debugger) = @_; if (isAppleMacWebKit()) { - return system "$FindBin::Bin/gdb-safari", argumentsForConfiguration() if $debugger; - - my $productDir = productDir(); - print "Starting Safari with DYLD_FRAMEWORK_PATH set to point to built WebKit in $productDir.\n"; - $ENV{DYLD_FRAMEWORK_PATH} = $productDir; - $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES"; - if (architecture()) { - return system "arch", "-" . architecture(), safariPath(), @ARGV; - } else { - return system safariPath(), @ARGV; + if ($debugger) { + return system "$FindBin::Bin/gdb-safari", argumentsForConfiguration(); } + return runMacWebKitApp(safariPath()); } if (isAppleWinWebKit()) { @@ -2040,16 +2065,7 @@ sub runSafari sub runMiniBrowser { if (isAppleMacWebKit()) { - my $productDir = productDir(); - print "Starting MiniBrowser with DYLD_FRAMEWORK_PATH set to point to $productDir.\n"; - $ENV{DYLD_FRAMEWORK_PATH} = $productDir; - $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES"; - my $miniBrowserPath = "$productDir/MiniBrowser.app/Contents/MacOS/MiniBrowser"; - if (architecture()) { - return system "arch", "-" . architecture(), $miniBrowserPath, @ARGV; - } else { - return system $miniBrowserPath, @ARGV; - } + return runMacWebKitApp(File::Spec->catfile(productDir(), "MiniBrowser.app", "Contents", "MacOS", "MiniBrowser")); } return 1; @@ -2080,16 +2096,7 @@ sub debugMiniBrowser sub runWebKitTestRunner { if (isAppleMacWebKit()) { - my $productDir = productDir(); - print "Starting WebKitTestRunner with DYLD_FRAMEWORK_PATH set to point to $productDir.\n"; - $ENV{DYLD_FRAMEWORK_PATH} = $productDir; - $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES"; - my $webKitTestRunnerPath = "$productDir/WebKitTestRunner"; - if (architecture()) { - return system "arch", "-" . architecture(), $webKitTestRunnerPath, @ARGV; - } else { - return system $webKitTestRunnerPath, @ARGV; - } + return runMacWebKitApp(File::Spec->catfile(productDir(), "WebKitTestRunner")); } elsif (isGtk()) { my $productDir = productDir(); my $injectedBundlePath = "$productDir/Libraries/.libs/libTestRunnerInjectedBundle"; @@ -2126,16 +2133,7 @@ sub debugWebKitTestRunner sub runTestWebKitAPI { if (isAppleMacWebKit()) { - my $productDir = productDir(); - print "Starting TestWebKitAPI with DYLD_FRAMEWORK_PATH set to point to $productDir.\n"; - $ENV{DYLD_FRAMEWORK_PATH} = $productDir; - $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES"; - my $testWebKitAPIPath = "$productDir/TestWebKitAPI"; - if (architecture()) { - return system "arch", "-" . architecture(), $testWebKitAPIPath, @ARGV; - } else { - return system $testWebKitAPIPath, @ARGV; - } + return runMacWebKitApp(File::Spec->catfile(productDir(), "TestWebKitAPI")); } return 1; -- 2.7.4