[webkit-reviews] Review request for Bug 3427: WebKitBuild location should not default to ~/

Stuart Morgan stuart.morgan at alumni.case.edu
Fri Jun 10 23:16:01 PDT 2005


The attached patch fixes http://bugzilla.opendarwin.org/show_bug.cgi? 
id=3427 by making webkitdirs.pm smarter about finding the directory  
holding the other WebKit folders, and placing the WebKitBuild folder  
alongside them if no custom build products directory is set.

-Stuart

-------------- next part --------------
Index: WebKitTools/Scripts/webkitdirs.pm
===================================================================
RCS file: /cvs/root/WebKitTools/Scripts/webkitdirs.pm,v
retrieving revision 1.3
diff -u -r1.3 webkitdirs.pm
--- webkitdirs.pm	2005/06/09 23:17:56	1.3
+++ webkitdirs.pm	2005/06/11 05:37:32
@@ -28,6 +28,8 @@
 
 use strict;
 use warnings;
+use FindBin;
+use Cwd;
 
 BEGIN {
    use Exporter   ();
@@ -47,17 +49,33 @@
 # Check that we're in the right directory.
 sub chdirWebKit
 {
-    if (! -d "WebKitTools") {
-        if (-d "../WebKitTools") {
-            chdir ".." or die;
-        }
-        if (-d "../../WebKitTools") {
-            chdir "../.." or die;
-        }
-        if (! -d "WebKitTools") {
-            die "No WebKitTools directory found. Please run this script from the directory containing WebKitTools.\n";
-        }
+    my $webKitDir = findWebKitDir();
+    if ($webKitDir) {
+        chdir $webKitDir;
+    } else {
+        die "No WebKitTools directory found. Please try running this script from the directory containing WebKitTools.\n";
+    }
+}
+
+# Get WebKit directory.
+# If FindBin doesn't work for some reason, fall bock on scanning
+# parent directories
+sub findWebKitDir
+{
+    my $webKitDir = "$FindBin::Bin/../..";
+    if (-d "$webKitDir/WebKitTools") {
+        return Cwd::abs_path($webKitDir);
+    }
+    if (-d "WebKitTools") {
+        return Cwd::abs_path(".");
+    }
+    if (-d "../WebKitTools") {
+        return Cwd::abs_path("..");
+    }
+    if (-d "../../WebKitTools") {
+        return Cwd::abs_path("../..");
     }
+    return;
 }
 
 # Check that an Xcode product directory is set, setting the SYMROOT environment variable
@@ -73,7 +91,7 @@
         chomp $productDir;
         @options = ();
     } else {
-        $productDir = "$ENV{HOME}/WebKitBuild";
+        $productDir = (findWebKitDir() || $ENV{HOME})."/WebKitBuild";
         @options = ("SYMROOT=$productDir");
     }
     $productDir =~ s|^~/|$ENV{HOME}/|;


More information about the webkit-reviews mailing list