<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[169042] trunk/Tools</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/169042">169042</a></dd>
<dt>Author</dt> <dd>ddkilzer@apple.com</dd>
<dt>Date</dt> <dd>2014-05-19 02:17:53 -0700 (Mon, 19 May 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>webkitdirs.pm: Add setupMacWebKitEnvironment() to set __XPC_DYLD_FRAMEWORK_PATH consistently
&lt;http://webkit.org/b/132954&gt;

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().</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptsbisectbuilds">trunk/Tools/Scripts/bisect-builds</a></li>
<li><a href="#trunkToolsScriptsrunapitests">trunk/Tools/Scripts/run-api-tests</a></li>
<li><a href="#trunkToolsScriptsrunpageloadtest">trunk/Tools/Scripts/run-pageloadtest</a></li>
<li><a href="#trunkToolsScriptswebkitdirspm">trunk/Tools/Scripts/webkitdirs.pm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (169041 => 169042)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2014-05-19 09:02:04 UTC (rev 169041)
+++ trunk/Tools/ChangeLog        2014-05-19 09:17:53 UTC (rev 169042)
</span><span class="lines">@@ -1,3 +1,54 @@
</span><ins>+2014-05-19  David Kilzer  &lt;ddkilzer@apple.com&gt;
+
+        webkitdirs.pm: Add setupMacWebKitEnvironment() to set __XPC_DYLD_FRAMEWORK_PATH consistently
+        &lt;http://webkit.org/b/132954&gt;
+
+        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().
+
</ins><span class="cx"> 2014-05-18  Rik Cabanier  &lt;cabanier@adobe.com&gt;
</span><span class="cx"> 
</span><span class="cx">         support for navigator.hardwareConcurrency
</span></span></pre></div>
<a id="trunkToolsScriptsbisectbuilds"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/bisect-builds (169041 => 169042)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #!/usr/bin/perl -w
</span><span class="cx"> 
</span><del>-# Copyright (C) 2007, 2008, 2009, 2011, 2012, 2013 Apple Inc.  All rights reserved.
</del><ins>+# Copyright (C) 2007-2009, 2011-2014 Apple Inc.  All rights reserved.
</ins><span class="cx"> #
</span><span class="cx"> # Redistribution and use in source and binary forms, with or without
</span><span class="cx"> # modification, are permitted provided that the following conditions
</span><span class="lines">@@ -84,6 +84,7 @@
</span><span class="cx"> @ARGV = map { /^(-r)(.+)$/ ? ($1, $2) : $_ } @ARGV;
</span><span class="cx"> 
</span><span class="cx"> my $result = GetOptions(
</span><ins>+    sharedCommandLineOptions(),
</ins><span class="cx">     &quot;b|branch=s&quot;             =&gt; \$branch,
</span><span class="cx">     &quot;d|download-directory=s&quot; =&gt; \$nightlyDownloadDirectory,
</span><span class="cx">     &quot;h|help&quot;                 =&gt; \$showHelp,
</span><span class="lines">@@ -114,6 +115,7 @@
</span><span class="cx">   [--safari-path path]           path to Safari application bundle (default: /Applications/Safari.app)
</span><span class="cx">   [-s|--sanity-check]            verify both starting and ending revisions before bisecting
</span><span class="cx"> END
</span><ins>+    print STDERR sharedCommandLineOptionsUsage(brackets =&gt; 1, indent =&gt; 2, switchWidth =&gt; 30);
</ins><span class="cx">     exit 1;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -405,8 +407,14 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     $tempFile ||= &quot;&quot;;
</span><del>-    `DYLD_FRAMEWORK_PATH=$frameworkPath WEBKIT_UNSET_DYLD_FRAMEWORK_PATH=YES $safari $tempFile`;
</del><span class="cx"> 
</span><ins>+    {
+        local %ENV = %ENV;
+        setupMacWebKitEnvironment($frameworkPath);
+
+        `$safari $tempFile`;
+    }
+
</ins><span class="cx">     `hdiutil detach '$mountPath' 2&gt; $devNull`;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsScriptsrunapitests"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/run-api-tests (169041 => 169042)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #!/usr/bin/perl -w
</span><span class="cx"> 
</span><del>-# Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
</del><ins>+# Copyright (C) 2010-2012, 2014 Apple Inc. All rights reserved.
</ins><span class="cx"> #
</span><span class="cx"> # Redistribution and use in source and binary forms, with or without
</span><span class="cx"> # modification, are permitted provided that the following conditions
</span><span class="lines">@@ -65,7 +65,7 @@
</span><span class="cx">   -d|--dump-tests       Dump the names of testcases without running them
</span><span class="cx">   --[no-]build          Build (or do not build) unit tests prior to running (default: $buildDefault)
</span><span class="cx">   --root=               Path to the pre-built root containing TestWebKitAPI
</span><del>-
</del><ins>+@{[ sharedCommandLineOptionsUsage(indent =&gt; 2, switchWidth =&gt; 21) ]}
</ins><span class="cx"> Examples
</span><span class="cx"> 
</span><span class="cx"> The following command will run a single test:
</span><span class="lines">@@ -76,7 +76,8 @@
</span><span class="cx"> 
</span><span class="cx"> EOF
</span><span class="cx"> 
</span><del>-GetOptions(
</del><ins>+my $getOptionsResult = GetOptions(
+    sharedCommandLineOptions(),
</ins><span class="cx">     'help' =&gt; \$showHelp,
</span><span class="cx">     'verbose|v' =&gt; \$verbose,
</span><span class="cx">     'dump|d' =&gt; \$dumpTests,
</span><span class="lines">@@ -84,7 +85,7 @@
</span><span class="cx">     'root=s' =&gt; \$root
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-if ($showHelp) {
</del><ins>+if (!$getOptionsResult || $showHelp) {
</ins><span class="cx">    print STDERR $usage;
</span><span class="cx">    exit 1;
</span><span class="cx"> }
</span><span class="lines">@@ -174,6 +175,7 @@
</span><span class="cx"> 
</span><span class="cx">     die &quot;run-api-tests is not supported on this platform.\n&quot; unless isSupportedPlatform();
</span><span class="cx"> 
</span><ins>+    local %ENV = %ENV;
</ins><span class="cx">     prepareEnvironmentForRunningTestTool();
</span><span class="cx"> 
</span><span class="cx">     local *DEVNULL;
</span><span class="lines">@@ -335,8 +337,7 @@
</span><span class="cx"> {
</span><span class="cx">     return unless isAppleMacWebKit();
</span><span class="cx"> 
</span><del>-    $ENV{DYLD_FRAMEWORK_PATH} = productDir();
-    $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = &quot;YES&quot;;
</del><ins>+    setupMacWebKitEnvironment(productDir());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> sub testToolPath()
</span></span></pre></div>
<a id="trunkToolsScriptsrunpageloadtest"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/run-pageloadtest (169041 => 169042)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,6 +1,7 @@
</span><span class="cx"> #!/usr/bin/perl
</span><span class="cx"> 
</span><span class="cx"> # Copyright (C) 2006 Eric Seidel (eric@webkit.org)
</span><ins>+# Copyright (C) 2014 Apple Inc. All rights reserved.
</ins><span class="cx"> #
</span><span class="cx"> # Redistribution and use in source and binary forms, with or without
</span><span class="cx"> # modification, are permitted provided that the following conditions
</span><span class="lines">@@ -47,9 +48,13 @@
</span><span class="cx"> 
</span><span class="cx"> my $usage =
</span><span class="cx">     &quot;Usage: &quot; . basename($0) . &quot;[options] testName\n&quot; .
</span><del>-    &quot;  --help                  Show this help message\n&quot;;
</del><ins>+    &quot;  --help                  Show this help message\n&quot; .
+    sharedCommandLineOptionsUsage(indent =&gt; 2, switchWidth =&gt; 23);
</ins><span class="cx"> 
</span><del>-my $getOptionsResult = GetOptions('help' =&gt; \$showHelp);
</del><ins>+my $getOptionsResult = GetOptions(
+    sharedCommandLineOptions(),
+   'help' =&gt; \$showHelp
+);
</ins><span class="cx"> 
</span><span class="cx"> if (!$getOptionsResult || $showHelp) {
</span><span class="cx">     print STDERR $usage;
</span><span class="lines">@@ -81,8 +86,7 @@
</span><span class="cx"> 
</span><span class="cx"> # Set up DYLD_FRAMEWORK_PATH to point to the product directory.
</span><span class="cx"> print &quot;Starting Safari with DYLD_FRAMEWORK_PATH set to point to built WebKit in $productDir.\n&quot;;
</span><del>-$ENV{DYLD_FRAMEWORK_PATH} = $productDir;
-$ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = &quot;YES&quot;;
</del><ins>+setupMacWebKitEnvironment($productDir);
</ins><span class="cx"> 
</span><span class="cx"> my @testCommands = ('activate');
</span><span class="cx"> # Autovicki would clear history, we skip that here as this is likely an active user account
</span></span></pre></div>
<a id="trunkToolsScriptswebkitdirspm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitdirs.pm (169041 => 169042)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,4 +1,4 @@
</span><del>-# Copyright (C) 2005, 2006, 2007, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
</del><ins>+# Copyright (C) 2005-2007, 2010-2014 Apple Inc. All rights reserved.
</ins><span class="cx"> # Copyright (C) 2009 Google Inc. All rights reserved.
</span><span class="cx"> # Copyright (C) 2011 Research In Motion Limited. All rights reserved.
</span><span class="cx"> # Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx"> use File::Path qw(mkpath rmtree);
</span><span class="cx"> use File::Spec;
</span><span class="cx"> use File::stat;
</span><ins>+use List::Util;
</ins><span class="cx"> use POSIX;
</span><span class="cx"> use VCSUtils;
</span><span class="cx"> 
</span><span class="lines">@@ -65,6 +66,9 @@
</span><span class="cx">        &amp;runMacWebKitApp
</span><span class="cx">        &amp;safariPath
</span><span class="cx">        &amp;setConfiguration
</span><ins>+       &amp;setupMacWebKitEnvironment
+       &amp;sharedCommandLineOptions
+       &amp;sharedCommandLineOptionsUsage
</ins><span class="cx">        USE_OPEN_COMMAND
</span><span class="cx">    );
</span><span class="cx">    %EXPORT_TAGS = ( );
</span><span class="lines">@@ -1287,6 +1291,34 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+sub sharedCommandLineOptions()
+{
+    return (
+        &quot;g|guard-malloc&quot; =&gt; \$shouldUseGuardMalloc,
+    );
+}
+
+sub sharedCommandLineOptionsUsage(+@)
+{
+    my %opts = @_;
+
+    my %switches = (
+        '-g|--guard-malloc' =&gt; 'Use guardmalloc when running executable',
+    );
+
+    my $indent = &quot; &quot; 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 = &quot;Common switches:\n&quot;;
+
+    for my $switch (keys %switches) {
+        my $switchName = $opts{brackets} ? &quot;[&quot; . $switch . &quot;]&quot; : $switch;
+        $result .= sprintf(&quot;%s%-&quot; . $switchWidth . &quot;s %s\n&quot;, $indent, $switchName, $switches{$switch});
+    }
+
+    return $result;
+}
+
</ins><span class="cx"> sub setUpGuardMallocIfNeeded
</span><span class="cx"> {
</span><span class="cx">     if (!isDarwin()) {
</span><span class="lines">@@ -1294,7 +1326,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (!defined($shouldUseGuardMalloc)) {
</span><del>-        $shouldUseGuardMalloc = checkForArgumentAndRemoveFromARGV(&quot;--guard-malloc&quot;);
</del><ins>+        $shouldUseGuardMalloc = checkForArgumentAndRemoveFromARGV(&quot;-g&quot;) || checkForArgumentAndRemoveFromARGV(&quot;--guard-malloc&quot;);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if ($shouldUseGuardMalloc) {
</span><span class="lines">@@ -1989,7 +2021,7 @@
</span><span class="cx"> Usage: @{[basename($0)]} [options] [args ...]
</span><span class="cx">   --help                            Show this help message
</span><span class="cx">   --no-saved-state                  Launch the application without state restoration (OS X 10.7 and later)
</span><del>-  --guard-malloc                    Enable Guard Malloc (OS X only)
</del><ins>+  -g|--guard-malloc                 Enable Guard Malloc (OS X only)
</ins><span class="cx">   --use-web-process-xpc-service     Launch the Web Process as an XPC Service (OS X only)
</span><span class="cx"> EOF
</span><span class="cx"> 
</span><span class="lines">@@ -2018,16 +2050,27 @@
</span><span class="cx">     return @args;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+sub setupMacWebKitEnvironment($)
+{
+    my ($dyldFrameworkPath) = @_;
+
+    $dyldFrameworkPath = File::Spec-&gt;rel2abs($dyldFrameworkPath);
+
+    $ENV{DYLD_FRAMEWORK_PATH} = $ENV{DYLD_FRAMEWORK_PATH} ? join(&quot;:&quot;, $dyldFrameworkPath, $ENV{DYLD_FRAMEWORK_PATH}) : $dyldFrameworkPath;
+    $ENV{__XPC_DYLD_FRAMEWORK_PATH} = $dyldFrameworkPath;
+    $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = &quot;YES&quot;;
+
+    setUpGuardMallocIfNeeded();
+}
+
</ins><span class="cx"> sub runMacWebKitApp($;$)
</span><span class="cx"> {
</span><span class="cx">     my ($appPath, $useOpenCommand) = @_;
</span><span class="cx">     my $productDir = productDir();
</span><span class="cx">     print &quot;Starting @{[basename($appPath)]} with DYLD_FRAMEWORK_PATH set to point to built WebKit in $productDir.\n&quot;;
</span><del>-    $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
-    $ENV{__XPC_DYLD_FRAMEWORK_PATH} = File::Spec-&gt;rel2abs($productDir);
-    $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = &quot;YES&quot;;
</del><span class="cx"> 
</span><del>-    setUpGuardMallocIfNeeded();
</del><ins>+    local %ENV = %ENV;
+    setupMacWebKitEnvironment($productDir);
</ins><span class="cx"> 
</span><span class="cx">     if (defined($useOpenCommand) &amp;&amp; $useOpenCommand == USE_OPEN_COMMAND) {
</span><span class="cx">         return system(&quot;open&quot;, &quot;-W&quot;, &quot;-a&quot;, $appPath, &quot;--args&quot;, argumentsForRunAndDebugMacWebKitApp());
</span><span class="lines">@@ -2059,12 +2102,8 @@
</span><span class="cx">     die &quot;Can't find the $debugger executable.\n&quot; unless -x $debuggerPath;
</span><span class="cx"> 
</span><span class="cx">     my $productDir = productDir();
</span><del>-    $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
-    $ENV{__XPC_DYLD_FRAMEWORK_PATH} = File::Spec-&gt;rel2abs($productDir);
-    $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = &quot;YES&quot;;
</del><ins>+    setupMacWebKitEnvironment($productDir);
</ins><span class="cx"> 
</span><del>-    setUpGuardMallocIfNeeded();
-
</del><span class="cx">     my @architectureFlags = ($architectureSwitch, architecture());
</span><span class="cx">     if (!shouldTargetWebProcess()) {
</span><span class="cx">         print &quot;Starting @{[basename($appPath)]} under $debugger with DYLD_FRAMEWORK_PATH set to point to built WebKit in $productDir.\n&quot;;
</span></span></pre>
</div>
</div>

</body>
</html>