Title: [159599] trunk/Tools
Revision
159599
Author
[email protected]
Date
2013-11-20 17:39:50 -0800 (Wed, 20 Nov 2013)

Log Message

Modify webkitdirs to reuse checkForArgumentAndRemoveFromARGV
https://bugs.webkit.org/show_bug.cgi?id=124581

Patch by Nick Diego Yamane <[email protected]> on 2013-11-20
Reviewed by Daniel Bates.

Some subroutines are replicating code from checkForArgument**
functions instead of reusing them as is being done by all other functions.

* Scripts/webkitdirs.pm:
(determineXcodeSDK): Added.
(determinePassedConfiguration): Added.
(determinePassedArchitecture): Added.
(checkForArgumentAndRemoveFromARGV): Added.
(checkForArgumentAndRemoveFromARGVGettingValue): Added.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (159598 => 159599)


--- trunk/Tools/ChangeLog	2013-11-21 01:28:35 UTC (rev 159598)
+++ trunk/Tools/ChangeLog	2013-11-21 01:39:50 UTC (rev 159599)
@@ -1,3 +1,20 @@
+2013-11-20  Nick Diego Yamane  <[email protected]>
+
+        Modify webkitdirs to reuse checkForArgumentAndRemoveFromARGV
+        https://bugs.webkit.org/show_bug.cgi?id=124581
+
+        Reviewed by Daniel Bates.
+
+        Some subroutines are replicating code from checkForArgument**
+        functions instead of reusing them as is being done by all other functions.
+
+        * Scripts/webkitdirs.pm:
+        (determineXcodeSDK): Added.
+        (determinePassedConfiguration): Added.
+        (determinePassedArchitecture): Added.
+        (checkForArgumentAndRemoveFromARGV): Added.
+        (checkForArgumentAndRemoveFromARGVGettingValue): Added.
+
 2013-11-20  Jozsef Berta  <[email protected]>
 
         Delete baseline optimizer

Modified: trunk/Tools/Scripts/webkitdirs.pm (159598 => 159599)


--- trunk/Tools/Scripts/webkitdirs.pm	2013-11-21 01:28:35 UTC (rev 159598)
+++ trunk/Tools/Scripts/webkitdirs.pm	2013-11-21 01:39:50 UTC (rev 159599)
@@ -389,18 +389,14 @@
 sub determineXcodeSDK
 {
     return if defined $xcodeSDK;
-    for (my $i = 0; $i <= $#ARGV; $i++) {
-        my $opt = $ARGV[$i];
-        if ($opt =~ /^--sdk$/i) {
-            splice(@ARGV, $i, 1);
-            $xcodeSDK = splice(@ARGV, $i, 1);
-        } elsif ($opt =~ /^--device$/i) {
-            splice(@ARGV, $i, 1);
-            $xcodeSDK = 'iphoneos.internal';
-        } elsif ($opt =~ /^--sim(ulator)?/i) {
-            splice(@ARGV, $i, 1);
-            $xcodeSDK = 'iphonesimulator';
-        }
+    my $sdk;
+    if (checkForArgumentAndRemoveFromARGVGettingValue("--sdk", \$sdk)) {
+        $xcodeSDK = $sdk;
+    } elsif (checkForArgumentAndRemoveFromARGV("--device")) {
+        $xcodeSDK = 'iphoneos.internal';
+    } elsif (checkForArgumentAndRemoveFromARGV("--sim") ||
+        checkForArgumentAndRemoveFromARGV("--simulator")) {
+        $xcodeSDK = 'iphonesimulator';
     }
 }
 
@@ -613,29 +609,17 @@
 {
     return if $searchedForPassedConfiguration;
     $searchedForPassedConfiguration = 1;
+    $passedConfiguration = undef;
 
-    for my $i (0 .. $#ARGV) {
-        my $opt = $ARGV[$i];
-        if ($opt =~ /^--debug$/i) {
-            splice(@ARGV, $i, 1);
-            $passedConfiguration = "Debug";
-            $passedConfiguration .= "_WinCairo" if (isWinCairo() && isCygwin());
-            return;
-        }
-        if ($opt =~ /^--release$/i) {
-            splice(@ARGV, $i, 1);
-            $passedConfiguration = "Release";
-            $passedConfiguration .= "_WinCairo" if (isWinCairo() && isCygwin());
-            return;
-        }
-        if ($opt =~ /^--profil(e|ing)$/i) {
-            splice(@ARGV, $i, 1);
-            $passedConfiguration = "Profiling";
-            $passedConfiguration .= "_WinCairo" if (isWinCairo() && isCygwin());
-            return;
-        }
+    if (checkForArgumentAndRemoveFromARGV("--debug")) {
+        $passedConfiguration = "Debug";
+    } elsif(checkForArgumentAndRemoveFromARGV("--release")) {
+        $passedConfiguration = "Release";
+    } elsif (checkForArgumentAndRemoveFromARGV("--profile") || checkForArgumentAndRemoveFromARGV("--profiling")) {
+        $passedConfiguration = "Profiling";
     }
-    $passedConfiguration = undef;
+
+    $passedConfiguration .= "_WinCairo" if (defined($passedConfiguration) && isWinCairo() && isCygwin());
 }
 
 sub passedConfiguration
@@ -665,18 +649,13 @@
     return if $searchedForPassedArchitecture;
     $searchedForPassedArchitecture = 1;
 
-    for my $i (0 .. $#ARGV) {
-        my $opt = $ARGV[$i];
-        if ($opt =~ /^--32-bit$/i) {
-            splice(@ARGV, $i, 1);
-            if (isAppleMacWebKit()) {
-                $passedArchitecture = `arch`;
-                chomp $passedArchitecture;
-            }
-            return;
+    $passedArchitecture = undef;
+    if (checkForArgumentAndRemoveFromARGV("--32-bit")) {
+        if (isAppleMacWebKit()) {
+            $passedArchitecture = `arch`;
+            chomp $passedArchitecture;
         }
     }
-    $passedArchitecture = undef;
 }
 
 sub passedArchitecture
@@ -858,12 +837,21 @@
     return `$command --version 2> $devnull`;
 }
 
-sub checkForArgumentAndRemoveFromARGV
+sub checkForArgumentAndRemoveFromARGV($)
 {
     my $argToCheck = shift;
     return checkForArgumentAndRemoveFromArrayRef($argToCheck, \@ARGV);
 }
 
+sub checkForArgumentAndRemoveFromARGVGettingValue($$)
+{
+    my ($argToCheck, $valueRef) = @_;
+    my @matchingIndices = findMatchingArguments($argToCheck, \@ARGV);
+    return 0 unless ($#matchingIndices != 1);
+    splice(@ARGV, $matchingIndices[0], 1);
+    return $$valueRef = splice(@ARGV, $matchingIndices[0], 1);
+}
+
 sub findMatchingArguments($$)
 {
     my ($argToCheck, $arrayRef) = @_;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to