Changeset 169042 in webkit


Ignore:
Timestamp:
May 19, 2014 2:17:53 AM (10 years ago)
Author:
ddkilzer@apple.com
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 -gguard-malloc.
Scripts/bisect-builds: Add -gguard-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 -gguard-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 -gguard-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().

Location:
trunk/Tools
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r169017 r169042  
     12014-05-19  David Kilzer  <ddkilzer@apple.com>
     2
     3        webkitdirs.pm: Add setupMacWebKitEnvironment() to set __XPC_DYLD_FRAMEWORK_PATH consistently
     4        <http://webkit.org/b/132954>
     5
     6        Reviewed by Darin Adler.
     7
     8        Extract code into setupMacWebKitEnvironment() for setting up
     9        common environment variables so it may be shared.  Sets
     10        __XPC_DYLD_FRAMEWORK_PATH consistently and adds support for
     11        using guardmalloc to some scripts.
     12
     13        Also adds support for parsing shared (common) command-line
     14        switches, initially just -g|--guard-malloc.
     15
     16        * Scripts/bisect-builds: Add -g|--guard-malloc support by using
     17        sharedCommandLineOptions() and sharedCommandLineOptionsUsage().
     18        (mountAndRunNightly): Call setupMacWebKitEnvironment().  Use a
     19        local copy of %ENV when launching Safari so we don't have to
     20        restore variables.
     21
     22        * Scripts/run-api-tests: Add -g|--guard-malloc support by using
     23        sharedCommandLineOptions() and sharedCommandLineOptionsUsage().
     24        Check result of GetOptions() to catch invalid command-line
     25        switches.
     26        (runTest): Use a local copy of %ENV when running tests so we
     27        don't have to restore variables.
     28        (prepareEnvironmentForRunningTestTool): Call
     29        setupMacWebKitEnvironment().
     30
     31        * Scripts/run-pageloadtest: Add -g|--guard-malloc support by
     32        using sharedCommandLineOptions() and
     33        sharedCommandLineOptionsUsage().  Call
     34        setupMacWebKitEnvironment().
     35
     36        * Scripts/webkitdirs.pm:
     37        (sharedCommandLineOptions): Return array of common switches to
     38        pass to Getopt::Long::GetOptions().
     39        (sharedCommandLineOptionsUsage): Return formatted string of
     40        common switches for printing usage help text.
     41        (setUpGuardMallocIfNeeded): Support using '-g' for enabling
     42        guardmalloc.
     43        (printHelpAndExitForRunAndDebugWebKitAppIfNeeded): Ditto.
     44        (setupMacWebKitEnvironment): Extracted from runMacWebKitApp()
     45        and changed not to clobber DYLD_FRAMEWORK_PATH if already set.
     46        (runMacWebKitApp): Call setupMacWebKitEnvironment().  Use a
     47        local copy of %ENV when launching Safari so we don't have to
     48        restore variables.
     49        (execMacWebKitAppForDebugging): Call
     50        setupMacWebKitEnvironment().
     51
    1522014-05-18  Rik Cabanier  <cabanier@adobe.com>
    253
  • trunk/Tools/Scripts/bisect-builds

    r166419 r169042  
    11#!/usr/bin/perl -w
    22
    3 # Copyright (C) 2007, 2008, 2009, 2011, 2012, 2013 Apple Inc.  All rights reserved.
     3# Copyright (C) 2007-2009, 2011-2014 Apple Inc.  All rights reserved.
    44#
    55# Redistribution and use in source and binary forms, with or without
     
    8585
    8686my $result = GetOptions(
     87    sharedCommandLineOptions(),
    8788    "b|branch=s"             => \$branch,
    8889    "d|download-directory=s" => \$nightlyDownloadDirectory,
     
    115116  [-s|--sanity-check]            verify both starting and ending revisions before bisecting
    116117END
     118    print STDERR sharedCommandLineOptionsUsage(brackets => 1, indent => 2, switchWidth => 30);
    117119    exit 1;
    118120}
     
    406408
    407409    $tempFile ||= "";
    408     `DYLD_FRAMEWORK_PATH=$frameworkPath WEBKIT_UNSET_DYLD_FRAMEWORK_PATH=YES $safari $tempFile`;
     410
     411    {
     412        local %ENV = %ENV;
     413        setupMacWebKitEnvironment($frameworkPath);
     414
     415        `$safari $tempFile`;
     416    }
    409417
    410418    `hdiutil detach '$mountPath' 2> $devNull`;
  • trunk/Tools/Scripts/run-api-tests

    r168910 r169042  
    11#!/usr/bin/perl -w
    22
    3 # Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
     3# Copyright (C) 2010-2012, 2014 Apple Inc. All rights reserved.
    44#
    55# Redistribution and use in source and binary forms, with or without
     
    6666  --[no-]build          Build (or do not build) unit tests prior to running (default: $buildDefault)
    6767  --root=               Path to the pre-built root containing TestWebKitAPI
    68 
     68@{[ sharedCommandLineOptionsUsage(indent => 2, switchWidth => 21) ]}
    6969Examples
    7070
     
    7777EOF
    7878
    79 GetOptions(
     79my $getOptionsResult = GetOptions(
     80    sharedCommandLineOptions(),
    8081    'help' => \$showHelp,
    8182    'verbose|v' => \$verbose,
     
    8586);
    8687
    87 if ($showHelp) {
     88if (!$getOptionsResult || $showHelp) {
    8889   print STDERR $usage;
    8990   exit 1;
     
    175176    die "run-api-tests is not supported on this platform.\n" unless isSupportedPlatform();
    176177
     178    local %ENV = %ENV;
    177179    prepareEnvironmentForRunningTestTool();
    178180
     
    336338    return unless isAppleMacWebKit();
    337339
    338     $ENV{DYLD_FRAMEWORK_PATH} = productDir();
    339     $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES";
     340    setupMacWebKitEnvironment(productDir());
    340341}
    341342
  • trunk/Tools/Scripts/run-pageloadtest

    r165676 r169042  
    22
    33# Copyright (C) 2006 Eric Seidel (eric@webkit.org)
     4# Copyright (C) 2014 Apple Inc. All rights reserved.
    45#
    56# Redistribution and use in source and binary forms, with or without
     
    4849my $usage =
    4950    "Usage: " . basename($0) . "[options] testName\n" .
    50     "  --help                  Show this help message\n";
     51    "  --help                  Show this help message\n" .
     52    sharedCommandLineOptionsUsage(indent => 2, switchWidth => 23);
    5153
    52 my $getOptionsResult = GetOptions('help' => \$showHelp);
     54my $getOptionsResult = GetOptions(
     55    sharedCommandLineOptions(),
     56   'help' => \$showHelp
     57);
    5358
    5459if (!$getOptionsResult || $showHelp) {
     
    8287# Set up DYLD_FRAMEWORK_PATH to point to the product directory.
    8388print "Starting Safari with DYLD_FRAMEWORK_PATH set to point to built WebKit in $productDir.\n";
    84 $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
    85 $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES";
     89setupMacWebKitEnvironment($productDir);
    8690
    8791my @testCommands = ('activate');
  • trunk/Tools/Scripts/webkitdirs.pm

    r168910 r169042  
    1 # Copyright (C) 2005, 2006, 2007, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
     1# Copyright (C) 2005-2007, 2010-2014 Apple Inc. All rights reserved.
    22# Copyright (C) 2009 Google Inc. All rights reserved.
    33# Copyright (C) 2011 Research In Motion Limited. All rights reserved.
     
    4040use File::Spec;
    4141use File::stat;
     42use List::Util;
    4243use POSIX;
    4344use VCSUtils;
     
    6667       &safariPath
    6768       &setConfiguration
     69       &setupMacWebKitEnvironment
     70       &sharedCommandLineOptions
     71       &sharedCommandLineOptionsUsage
    6872       USE_OPEN_COMMAND
    6973   );
     
    12881292}
    12891293
     1294sub sharedCommandLineOptions()
     1295{
     1296    return (
     1297        "g|guard-malloc" => \$shouldUseGuardMalloc,
     1298    );
     1299}
     1300
     1301sub sharedCommandLineOptionsUsage(+@)
     1302{
     1303    my %opts = @_;
     1304
     1305    my %switches = (
     1306        '-g|--guard-malloc' => 'Use guardmalloc when running executable',
     1307    );
     1308
     1309    my $indent = " " x ($opts{indent} || 2);
     1310    my $switchWidth = List::Util::max(int($opts{switchWidth}), List::Util::max(map { length($_) } keys %switches) + ($opts{brackets} ? 2 : 0));
     1311
     1312    my $result = "Common switches:\n";
     1313
     1314    for my $switch (keys %switches) {
     1315        my $switchName = $opts{brackets} ? "[" . $switch . "]" : $switch;
     1316        $result .= sprintf("%s%-" . $switchWidth . "s %s\n", $indent, $switchName, $switches{$switch});
     1317    }
     1318
     1319    return $result;
     1320}
     1321
    12901322sub setUpGuardMallocIfNeeded
    12911323{
     
    12951327
    12961328    if (!defined($shouldUseGuardMalloc)) {
    1297         $shouldUseGuardMalloc = checkForArgumentAndRemoveFromARGV("--guard-malloc");
     1329        $shouldUseGuardMalloc = checkForArgumentAndRemoveFromARGV("-g") || checkForArgumentAndRemoveFromARGV("--guard-malloc");
    12981330    }
    12991331
     
    19902022  --help                            Show this help message
    19912023  --no-saved-state                  Launch the application without state restoration (OS X 10.7 and later)
    1992   --guard-malloc                    Enable Guard Malloc (OS X only)
     2024  -g|--guard-malloc                 Enable Guard Malloc (OS X only)
    19932025  --use-web-process-xpc-service     Launch the Web Process as an XPC Service (OS X only)
    19942026EOF
     
    20192051}
    20202052
     2053sub setupMacWebKitEnvironment($)
     2054{
     2055    my ($dyldFrameworkPath) = @_;
     2056
     2057    $dyldFrameworkPath = File::Spec->rel2abs($dyldFrameworkPath);
     2058
     2059    $ENV{DYLD_FRAMEWORK_PATH} = $ENV{DYLD_FRAMEWORK_PATH} ? join(":", $dyldFrameworkPath, $ENV{DYLD_FRAMEWORK_PATH}) : $dyldFrameworkPath;
     2060    $ENV{__XPC_DYLD_FRAMEWORK_PATH} = $dyldFrameworkPath;
     2061    $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES";
     2062
     2063    setUpGuardMallocIfNeeded();
     2064}
     2065
    20212066sub runMacWebKitApp($;$)
    20222067{
     
    20242069    my $productDir = productDir();
    20252070    print "Starting @{[basename($appPath)]} with DYLD_FRAMEWORK_PATH set to point to built WebKit in $productDir.\n";
    2026     $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
    2027     $ENV{__XPC_DYLD_FRAMEWORK_PATH} = File::Spec->rel2abs($productDir);
    2028     $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES";
    2029 
    2030     setUpGuardMallocIfNeeded();
     2071
     2072    local %ENV = %ENV;
     2073    setupMacWebKitEnvironment($productDir);
    20312074
    20322075    if (defined($useOpenCommand) && $useOpenCommand == USE_OPEN_COMMAND) {
     
    20602103
    20612104    my $productDir = productDir();
    2062     $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
    2063     $ENV{__XPC_DYLD_FRAMEWORK_PATH} = File::Spec->rel2abs($productDir);
    2064     $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES";
    2065 
    2066     setUpGuardMallocIfNeeded();
     2105    setupMacWebKitEnvironment($productDir);
    20672106
    20682107    my @architectureFlags = ($architectureSwitch, architecture());
Note: See TracChangeset for help on using the changeset viewer.