Title: [169042] trunk/Tools
Revision
169042
Author
[email protected]
Date
2014-05-19 02:17:53 -0700 (Mon, 19 May 2014)

Log Message

webkitdirs.pm: Add setupMacWebKitEnvironment() to set __XPC_DYLD_FRAMEWORK_PATH consistently
<http://webkit.org/b/132954>

Reviewed by Darin Adler.

Extract code into setupMacWebKitEnvironment() for setting up
common environment variables so it may be shared.  Sets
__XPC_DYLD_FRAMEWORK_PATH consistently and adds support for
using guardmalloc to some scripts.

Also adds support for parsing shared (common) command-line
switches, initially just -g|--guard-malloc.

* Scripts/bisect-builds: Add -g|--guard-malloc support by using
sharedCommandLineOptions() and sharedCommandLineOptionsUsage().
(mountAndRunNightly): Call setupMacWebKitEnvironment().  Use a
local copy of %ENV when launching Safari so we don't have to
restore variables.

* Scripts/run-api-tests: Add -g|--guard-malloc support by using
sharedCommandLineOptions() and sharedCommandLineOptionsUsage().
Check result of GetOptions() to catch invalid command-line
switches.
(runTest): Use a local copy of %ENV when running tests so we
don't have to restore variables.
(prepareEnvironmentForRunningTestTool): Call
setupMacWebKitEnvironment().

* Scripts/run-pageloadtest: Add -g|--guard-malloc support by
using sharedCommandLineOptions() and
sharedCommandLineOptionsUsage().  Call
setupMacWebKitEnvironment().

* Scripts/webkitdirs.pm:
(sharedCommandLineOptions): Return array of common switches to
pass to Getopt::Long::GetOptions().
(sharedCommandLineOptionsUsage): Return formatted string of
common switches for printing usage help text.
(setUpGuardMallocIfNeeded): Support using '-g' for enabling
guardmalloc.
(printHelpAndExitForRunAndDebugWebKitAppIfNeeded): Ditto.
(setupMacWebKitEnvironment): Extracted from runMacWebKitApp()
and changed not to clobber DYLD_FRAMEWORK_PATH if already set.
(runMacWebKitApp): Call setupMacWebKitEnvironment().  Use a
local copy of %ENV when launching Safari so we don't have to
restore variables.
(execMacWebKitAppForDebugging): Call
setupMacWebKitEnvironment().

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (169041 => 169042)


--- trunk/Tools/ChangeLog	2014-05-19 09:02:04 UTC (rev 169041)
+++ trunk/Tools/ChangeLog	2014-05-19 09:17:53 UTC (rev 169042)
@@ -1,3 +1,54 @@
+2014-05-19  David Kilzer  <[email protected]>
+
+        webkitdirs.pm: Add setupMacWebKitEnvironment() to set __XPC_DYLD_FRAMEWORK_PATH consistently
+        <http://webkit.org/b/132954>
+
+        Reviewed by Darin Adler.
+
+        Extract code into setupMacWebKitEnvironment() for setting up
+        common environment variables so it may be shared.  Sets
+        __XPC_DYLD_FRAMEWORK_PATH consistently and adds support for
+        using guardmalloc to some scripts.
+
+        Also adds support for parsing shared (common) command-line
+        switches, initially just -g|--guard-malloc.
+
+        * Scripts/bisect-builds: Add -g|--guard-malloc support by using
+        sharedCommandLineOptions() and sharedCommandLineOptionsUsage().
+        (mountAndRunNightly): Call setupMacWebKitEnvironment().  Use a
+        local copy of %ENV when launching Safari so we don't have to
+        restore variables.
+
+        * Scripts/run-api-tests: Add -g|--guard-malloc support by using
+        sharedCommandLineOptions() and sharedCommandLineOptionsUsage().
+        Check result of GetOptions() to catch invalid command-line
+        switches.
+        (runTest): Use a local copy of %ENV when running tests so we
+        don't have to restore variables.
+        (prepareEnvironmentForRunningTestTool): Call
+        setupMacWebKitEnvironment().
+
+        * Scripts/run-pageloadtest: Add -g|--guard-malloc support by
+        using sharedCommandLineOptions() and
+        sharedCommandLineOptionsUsage().  Call
+        setupMacWebKitEnvironment().
+
+        * Scripts/webkitdirs.pm:
+        (sharedCommandLineOptions): Return array of common switches to
+        pass to Getopt::Long::GetOptions().
+        (sharedCommandLineOptionsUsage): Return formatted string of
+        common switches for printing usage help text.
+        (setUpGuardMallocIfNeeded): Support using '-g' for enabling
+        guardmalloc.
+        (printHelpAndExitForRunAndDebugWebKitAppIfNeeded): Ditto.
+        (setupMacWebKitEnvironment): Extracted from runMacWebKitApp()
+        and changed not to clobber DYLD_FRAMEWORK_PATH if already set.
+        (runMacWebKitApp): Call setupMacWebKitEnvironment().  Use a
+        local copy of %ENV when launching Safari so we don't have to
+        restore variables.
+        (execMacWebKitAppForDebugging): Call
+        setupMacWebKitEnvironment().
+
 2014-05-18  Rik Cabanier  <[email protected]>
 
         support for navigator.hardwareConcurrency

Modified: trunk/Tools/Scripts/bisect-builds (169041 => 169042)


--- trunk/Tools/Scripts/bisect-builds	2014-05-19 09:02:04 UTC (rev 169041)
+++ trunk/Tools/Scripts/bisect-builds	2014-05-19 09:17:53 UTC (rev 169042)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 
-# Copyright (C) 2007, 2008, 2009, 2011, 2012, 2013 Apple Inc.  All rights reserved.
+# Copyright (C) 2007-2009, 2011-2014 Apple Inc.  All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -84,6 +84,7 @@
 @ARGV = map { /^(-r)(.+)$/ ? ($1, $2) : $_ } @ARGV;
 
 my $result = GetOptions(
+    sharedCommandLineOptions(),
     "b|branch=s"             => \$branch,
     "d|download-directory=s" => \$nightlyDownloadDirectory,
     "h|help"                 => \$showHelp,
@@ -114,6 +115,7 @@
   [--safari-path path]           path to Safari application bundle (default: /Applications/Safari.app)
   [-s|--sanity-check]            verify both starting and ending revisions before bisecting
 END
+    print STDERR sharedCommandLineOptionsUsage(brackets => 1, indent => 2, switchWidth => 30);
     exit 1;
 }
 
@@ -405,8 +407,14 @@
     }
 
     $tempFile ||= "";
-    `DYLD_FRAMEWORK_PATH=$frameworkPath WEBKIT_UNSET_DYLD_FRAMEWORK_PATH=YES $safari $tempFile`;
 
+    {
+        local %ENV = %ENV;
+        setupMacWebKitEnvironment($frameworkPath);
+
+        `$safari $tempFile`;
+    }
+
     `hdiutil detach '$mountPath' 2> $devNull`;
 }
 

Modified: trunk/Tools/Scripts/run-api-tests (169041 => 169042)


--- trunk/Tools/Scripts/run-api-tests	2014-05-19 09:02:04 UTC (rev 169041)
+++ trunk/Tools/Scripts/run-api-tests	2014-05-19 09:17:53 UTC (rev 169042)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 
-# Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
+# Copyright (C) 2010-2012, 2014 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -65,7 +65,7 @@
   -d|--dump-tests       Dump the names of testcases without running them
   --[no-]build          Build (or do not build) unit tests prior to running (default: $buildDefault)
   --root=               Path to the pre-built root containing TestWebKitAPI
-
+@{[ sharedCommandLineOptionsUsage(indent => 2, switchWidth => 21) ]}
 Examples
 
 The following command will run a single test:
@@ -76,7 +76,8 @@
 
 EOF
 
-GetOptions(
+my $getOptionsResult = GetOptions(
+    sharedCommandLineOptions(),
     'help' => \$showHelp,
     'verbose|v' => \$verbose,
     'dump|d' => \$dumpTests,
@@ -84,7 +85,7 @@
     'root=s' => \$root
 );
 
-if ($showHelp) {
+if (!$getOptionsResult || $showHelp) {
    print STDERR $usage;
    exit 1;
 }
@@ -174,6 +175,7 @@
 
     die "run-api-tests is not supported on this platform.\n" unless isSupportedPlatform();
 
+    local %ENV = %ENV;
     prepareEnvironmentForRunningTestTool();
 
     local *DEVNULL;
@@ -335,8 +337,7 @@
 {
     return unless isAppleMacWebKit();
 
-    $ENV{DYLD_FRAMEWORK_PATH} = productDir();
-    $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES";
+    setupMacWebKitEnvironment(productDir());
 }
 
 sub testToolPath()

Modified: trunk/Tools/Scripts/run-pageloadtest (169041 => 169042)


--- trunk/Tools/Scripts/run-pageloadtest	2014-05-19 09:02:04 UTC (rev 169041)
+++ trunk/Tools/Scripts/run-pageloadtest	2014-05-19 09:17:53 UTC (rev 169042)
@@ -1,6 +1,7 @@
 #!/usr/bin/perl
 
 # Copyright (C) 2006 Eric Seidel ([email protected])
+# Copyright (C) 2014 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -47,9 +48,13 @@
 
 my $usage =
     "Usage: " . basename($0) . "[options] testName\n" .
-    "  --help                  Show this help message\n";
+    "  --help                  Show this help message\n" .
+    sharedCommandLineOptionsUsage(indent => 2, switchWidth => 23);
 
-my $getOptionsResult = GetOptions('help' => \$showHelp);
+my $getOptionsResult = GetOptions(
+    sharedCommandLineOptions(),
+   'help' => \$showHelp
+);
 
 if (!$getOptionsResult || $showHelp) {
     print STDERR $usage;
@@ -81,8 +86,7 @@
 
 # Set up DYLD_FRAMEWORK_PATH to point to the product directory.
 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";
+setupMacWebKitEnvironment($productDir);
 
 my @testCommands = ('activate');
 # Autovicki would clear history, we skip that here as this is likely an active user account

Modified: trunk/Tools/Scripts/webkitdirs.pm (169041 => 169042)


--- trunk/Tools/Scripts/webkitdirs.pm	2014-05-19 09:02:04 UTC (rev 169041)
+++ trunk/Tools/Scripts/webkitdirs.pm	2014-05-19 09:17:53 UTC (rev 169042)
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006, 2007, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
+# Copyright (C) 2005-2007, 2010-2014 Apple Inc. All rights reserved.
 # Copyright (C) 2009 Google Inc. All rights reserved.
 # Copyright (C) 2011 Research In Motion Limited. All rights reserved.
 # Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
@@ -39,6 +39,7 @@
 use File::Path qw(mkpath rmtree);
 use File::Spec;
 use File::stat;
+use List::Util;
 use POSIX;
 use VCSUtils;
 
@@ -65,6 +66,9 @@
        &runMacWebKitApp
        &safariPath
        &setConfiguration
+       &setupMacWebKitEnvironment
+       &sharedCommandLineOptions
+       &sharedCommandLineOptionsUsage
        USE_OPEN_COMMAND
    );
    %EXPORT_TAGS = ( );
@@ -1287,6 +1291,34 @@
     }
 }
 
+sub sharedCommandLineOptions()
+{
+    return (
+        "g|guard-malloc" => \$shouldUseGuardMalloc,
+    );
+}
+
+sub sharedCommandLineOptionsUsage(+@)
+{
+    my %opts = @_;
+
+    my %switches = (
+        '-g|--guard-malloc' => 'Use guardmalloc when running executable',
+    );
+
+    my $indent = " " x ($opts{indent} || 2);
+    my $switchWidth = List::Util::max(int($opts{switchWidth}), List::Util::max(map { length($_) } keys %switches) + ($opts{brackets} ? 2 : 0));
+
+    my $result = "Common switches:\n";
+
+    for my $switch (keys %switches) {
+        my $switchName = $opts{brackets} ? "[" . $switch . "]" : $switch;
+        $result .= sprintf("%s%-" . $switchWidth . "s %s\n", $indent, $switchName, $switches{$switch});
+    }
+
+    return $result;
+}
+
 sub setUpGuardMallocIfNeeded
 {
     if (!isDarwin()) {
@@ -1294,7 +1326,7 @@
     }
 
     if (!defined($shouldUseGuardMalloc)) {
-        $shouldUseGuardMalloc = checkForArgumentAndRemoveFromARGV("--guard-malloc");
+        $shouldUseGuardMalloc = checkForArgumentAndRemoveFromARGV("-g") || checkForArgumentAndRemoveFromARGV("--guard-malloc");
     }
 
     if ($shouldUseGuardMalloc) {
@@ -1989,7 +2021,7 @@
 Usage: @{[basename($0)]} [options] [args ...]
   --help                            Show this help message
   --no-saved-state                  Launch the application without state restoration (OS X 10.7 and later)
-  --guard-malloc                    Enable Guard Malloc (OS X only)
+  -g|--guard-malloc                 Enable Guard Malloc (OS X only)
   --use-web-process-xpc-service     Launch the Web Process as an XPC Service (OS X only)
 EOF
 
@@ -2018,16 +2050,27 @@
     return @args;
 }
 
+sub setupMacWebKitEnvironment($)
+{
+    my ($dyldFrameworkPath) = @_;
+
+    $dyldFrameworkPath = File::Spec->rel2abs($dyldFrameworkPath);
+
+    $ENV{DYLD_FRAMEWORK_PATH} = $ENV{DYLD_FRAMEWORK_PATH} ? join(":", $dyldFrameworkPath, $ENV{DYLD_FRAMEWORK_PATH}) : $dyldFrameworkPath;
+    $ENV{__XPC_DYLD_FRAMEWORK_PATH} = $dyldFrameworkPath;
+    $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES";
+
+    setUpGuardMallocIfNeeded();
+}
+
 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{__XPC_DYLD_FRAMEWORK_PATH} = File::Spec->rel2abs($productDir);
-    $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES";
 
-    setUpGuardMallocIfNeeded();
+    local %ENV = %ENV;
+    setupMacWebKitEnvironment($productDir);
 
     if (defined($useOpenCommand) && $useOpenCommand == USE_OPEN_COMMAND) {
         return system("open", "-W", "-a", $appPath, "--args", argumentsForRunAndDebugMacWebKitApp());
@@ -2059,12 +2102,8 @@
     die "Can't find the $debugger executable.\n" unless -x $debuggerPath;
 
     my $productDir = productDir();
-    $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
-    $ENV{__XPC_DYLD_FRAMEWORK_PATH} = File::Spec->rel2abs($productDir);
-    $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES";
+    setupMacWebKitEnvironment($productDir);
 
-    setUpGuardMallocIfNeeded();
-
     my @architectureFlags = ($architectureSwitch, architecture());
     if (!shouldTargetWebProcess()) {
         print "Starting @{[basename($appPath)]} under $debugger with DYLD_FRAMEWORK_PATH set to point to built WebKit in $productDir.\n";
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to