Title: [198761] branches/safari-601.1.46-branch/Tools
Revision
198761
Author
matthew_han...@apple.com
Date
2016-03-28 15:41:48 -0700 (Mon, 28 Mar 2016)

Log Message

Upstream webkitdirs.pm from trunk.
rdar://problem/25253479

Rubber-stamped by Dean Johnson.

* Scripts/webkitdirs.pm:

Modified Paths

Diff

Modified: branches/safari-601.1.46-branch/Tools/ChangeLog (198760 => 198761)


--- branches/safari-601.1.46-branch/Tools/ChangeLog	2016-03-28 22:34:44 UTC (rev 198760)
+++ branches/safari-601.1.46-branch/Tools/ChangeLog	2016-03-28 22:41:48 UTC (rev 198761)
@@ -1,3 +1,12 @@
+2016-03-28  Matthew Hanson  <matthew_han...@apple.com>
+
+        Upstream webkitdirs.pm from trunk.
+        rdar://problem/25253479
+
+        Rubber-stamped by Dean Johnson.
+
+        * Scripts/webkitdirs.pm:
+
 2016-03-15  Matthew Hanson  <matthew_han...@apple.com>
 
         Merge r194060. rdar://problem/24560757

Modified: branches/safari-601.1.46-branch/Tools/Scripts/webkitdirs.pm (198760 => 198761)


--- branches/safari-601.1.46-branch/Tools/Scripts/webkitdirs.pm	2016-03-28 22:34:44 UTC (rev 198760)
+++ branches/safari-601.1.46-branch/Tools/Scripts/webkitdirs.pm	2016-03-28 22:41:48 UTC (rev 198761)
@@ -1,4 +1,4 @@
-# Copyright (C) 2005-2007, 2010-2014 Apple Inc. All rights reserved.
+# Copyright (C) 2005-2007, 2010-2016 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).
@@ -58,39 +58,63 @@
        &XcodeOptions
        &XcodeStaticAnalyzerOption
        &appDisplayNameFromBundle
+       &appendToEnvironmentVariableList
        &baseProductDir
        &chdirWebKit
        &checkFrameworks
        &cmakeBasedPortArguments
-       &cmakeBasedPortName
        &currentSVNRevision
        &debugSafari
+       &executableProductDir
        &findOrCreateSimulatorForIOSDevice
        &iosSimulatorDeviceByName
        &nmPath
        &passedConfiguration
+       &prependToEnvironmentVariableList
        &printHelpAndExitForRunAndDebugWebKitAppIfNeeded
        &productDir
        &quitIOSSimulator
        &relaunchIOSSimulator
+       &restartIOSSimulatorDevice
        &runIOSWebKitApp
        &runMacWebKitApp
        &safariPath
+       &iosVersion
        &setConfiguration
        &setupMacWebKitEnvironment
        &sharedCommandLineOptions
        &sharedCommandLineOptionsUsage
+       &shutDownIOSSimulatorDevice
+       &willUseIOSDeviceSDK
+       &willUseIOSSimulatorSDK
+       SIMULATOR_DEVICE_SUFFIX_FOR_WEBKIT_DEVELOPMENT
        USE_OPEN_COMMAND
    );
    %EXPORT_TAGS = ( );
    @EXPORT_OK   = ();
 }
 
+# Ports
+use constant {
+    AppleWin => "AppleWin",
+    GTK      => "GTK",
+    Efl      => "Efl",
+    iOS      => "iOS",
+    Mac      => "Mac",
+    JSCOnly  => "JSCOnly",
+    WinCairo => "WinCairo",
+    Unknown  => "Unknown"
+};
+
 use constant USE_OPEN_COMMAND => 1; # Used in runMacWebKitApp().
 use constant INCLUDE_OPTIONS_FOR_DEBUGGING => 1;
 use constant SIMULATOR_DEVICE_STATE_SHUTDOWN => "1";
 use constant SIMULATOR_DEVICE_STATE_BOOTED => "3";
+use constant SIMULATOR_DEVICE_SUFFIX_FOR_WEBKIT_DEVELOPMENT  => "For WebKit Development";
 
+# See table "Certificate types and names" on <https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html#//apple_ref/doc/uid/TP40012582-CH31-SW41>.
+use constant IOS_DEVELOPMENT_CERTIFICATE_NAME_PREFIX => "iPhone Developer: ";
+
 our @EXPORT_OK;
 
 my $architecture;
@@ -109,17 +133,18 @@
 my $didLoadIPhoneSimulatorNotification;
 my $nmPath;
 my $osXVersion;
+my $iosVersion;
 my $generateDsym;
-my $isGtk;
-my $isWinCairo;
+my $isCMakeBuild;
 my $isWin64;
-my $isEfl;
 my $isInspectorFrontend;
-my $shouldTargetWebProcess;
-my $shouldUseXPCServiceForWebProcess;
+my $portName;
 my $shouldUseGuardMalloc;
+my $shouldNotUseNinja;
 my $xcodeVersion;
 
+my $unknownPortProhibited = 0;
+
 # Variables for Win32 support
 my $programFilesPath;
 my $vcBuildPath;
@@ -243,7 +268,7 @@
     }
 
     if (!defined($baseProductDir)) { # Port-specific checks failed, use default
-        $baseProductDir = "$sourceDir/WebKitBuild";
+        $baseProductDir = File::Spec->catdir($sourceDir, "WebKitBuild");
     }
 
     if (isGit() && isGitBranchBuild()) {
@@ -267,7 +292,7 @@
         $ENV{"WEBKIT_OUTPUTDIR"} = $dosBuildPath;
         my $unixBuildPath = `cygpath --unix \"$baseProductDir\"`;
         chomp $unixBuildPath;
-        $baseProductDir = $unixBuildPath;
+        $baseProductDir = $dosBuildPath;
     }
 }
 
@@ -292,12 +317,6 @@
     } else {
         $configuration = "Release";
     }
-
-    if ($configuration && isWinCairo()) {
-        unless ($configuration =~ /_WinCairo$/) {
-            $configuration .= "_WinCairo";
-        }
-    }
 }
 
 sub determineArchitecture
@@ -324,29 +343,36 @@
             } elsif ($xcodeSDK =~ /^iphonesimulator/) {
                 $architecture = 'x86_64';
             } elsif ($xcodeSDK =~ /^iphoneos/) {
-                $architecture = 'armv7';
+                $architecture = 'arm64';
             }
         }
-    } elsif (isEfl() || isGtk()) {
+    } elsif (isCMakeBuild()) {
         my $host_processor = "";
-        $host_processor = `cmake --system-information | grep CMAKE_SYSTEM_PROCESSOR`;
-        if ($host_processor =~ m/^CMAKE_SYSTEM_PROCESSOR \"([^"]+)\"/) {
-            # We have a configured build tree; use it.
-            $architecture = $1;
-            $architecture = 'x86_64' if $architecture eq 'amd64';
+        if (open my $cmake_sysinfo, "cmake --system-information |") {
+            while (<$cmake_sysinfo>) {
+                next unless index($_, 'CMAKE_SYSTEM_PROCESSOR') == 0;
+                if (/^CMAKE_SYSTEM_PROCESSOR \"([^"]+)\"/) {
+                    $architecture = $1;
+                    $architecture = 'x86_64' if $architecture eq 'amd64';
+                    last;
+                }
+            }
+            close $cmake_sysinfo;
         }
     }
 
-    if (!$architecture && (isGtk() || isAppleMacWebKit() || isEfl())) {
-        # Fall back to output of `arch', if it is present.
-        $architecture = `arch`;
-        chomp $architecture;
-    }
+    if (!isAnyWindows()) {
+        if (!$architecture) {
+            # Fall back to output of `arch', if it is present.
+            $architecture = `arch`;
+            chomp $architecture;
+        }
 
-    if (!$architecture && (isGtk() || isAppleMacWebKit() || isEfl())) {
-        # Fall back to output of `uname -m', if it is present.
-        $architecture = `uname -m`;
-        chomp $architecture;
+        if (!$architecture) {
+            # Fall back to output of `uname -m', if it is present.
+            $architecture = `uname -m`;
+            chomp $architecture;
+        }
     }
 
     $architecture = 'x86_64' if ($architecture =~ /amd64/ && isBSD());
@@ -380,7 +406,7 @@
         if ($numberOfCPUs eq "") {
             $numberOfCPUs = (grep /processor/, `cat /proc/cpuinfo`);
         }
-    } elsif (isWindows() || isCygwin()) {
+    } elsif (isAnyWindows()) {
         # Assumes cygwin
         $numberOfCPUs = `ls /proc/registry/HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/System/CentralProcessor | wc -w`;
     } elsif (isDarwin() || isBSD()) {
@@ -401,7 +427,7 @@
     my ($productDir) = @_;
     my $jscName = "jsc";
     $jscName .= "_debug"  if configuration() eq "Debug_All";
-    $jscName .= ".exe" if (isWindows() || isCygwin());
+    $jscName .= ".exe" if (isAnyWindows());
     return "$productDir/$jscName" if -e "$productDir/$jscName";
     return "$productDir/_javascript_Core.framework/Resources/$jscName";
 }
@@ -423,6 +449,7 @@
     push(@args, '--64-bit') if (isWin64());
     push(@args, '--gtk') if isGtk();
     push(@args, '--efl') if isEfl();
+    push(@args, '--jsc-only') if isJSCOnly();
     push(@args, '--wincairo') if isWinCairo();
     push(@args, '--inspector-frontend') if isInspectorFrontend();
     return @args;
@@ -508,10 +535,11 @@
         $vsInstallDir = $ENV{'VSINSTALLDIR'};
         $vsInstallDir =~ s|[\\/]$||;
     } else {
-        $vsInstallDir = File::Spec->catdir(programFilesPath(), "Microsoft Visual Studio 12.0");
+        $vsInstallDir = File::Spec->catdir(programFilesPath(), "Microsoft Visual Studio 14.0");
     }
     chomp($vsInstallDir = `cygpath "$vsInstallDir"`) if isCygwin();
 
+    print "Using Visual Studio: $vsInstallDir\n";
     return $vsInstallDir;
 }
 
@@ -519,9 +547,11 @@
 {
     return $msBuildInstallDir if defined $msBuildInstallDir;
 
-    $msBuildInstallDir = File::Spec->catdir(programFilesPath(), "MSBuild", "12.0", "Bin");
+    $msBuildInstallDir = File::Spec->catdir(programFilesPath(), "MSBuild", "14.0", "Bin");
+   
     chomp($msBuildInstallDir = `cygpath "$msBuildInstallDir"`) if isCygwin();
 
+    print "Using MSBuild: $msBuildInstallDir\n";
     return $msBuildInstallDir;
 }
 
@@ -531,8 +561,9 @@
 
     my $installDir = visualStudioInstallDir();
 
-    $vsVersion = ($installDir =~ /Microsoft Visual Studio ([0-9]+\.[0-9]*)/) ? $1 : "12";
+    $vsVersion = ($installDir =~ /Microsoft Visual Studio ([0-9]+\.[0-9]*)/) ? $1 : "14";
 
+    print "Using Visual Studio $vsVersion\n";
     return $vsVersion;
 }
 
@@ -559,8 +590,7 @@
     determineBaseProductDir();
     determineConfiguration();
     if (isAppleWinWebKit() || isWinCairo()) {
-        my $binDir = isWin64() ? "bin64" : "bin32";
-        $configurationProductDir = File::Spec->catdir($baseProductDir, $configuration, $binDir);
+        $configurationProductDir = File::Spec->catdir($baseProductDir, $configuration);
     } else {
         if (usesPerConfigurationBuildDirectory()) {
             $configurationProductDir = "$baseProductDir";
@@ -611,14 +641,27 @@
     return $configurationProductDir;
 }
 
-sub jscProductDir
+sub executableProductDir
 {
-    my $productDir = productDir();
-    $productDir .= "/bin" if (isEfl() || isGtk());
+    my $productDirectory = productDir();
 
-    return $productDir;
+    my $binaryDirectory;
+    if (isEfl() || isGtk() || isJSCOnly()) {
+        $binaryDirectory = "bin";
+    } elsif (isAnyWindows()) {
+        $binaryDirectory = isWin64() ? "bin64" : "bin32";
+    } else {
+        return $productDirectory;
+    }
+
+    return File::Spec->catdir($productDirectory, $binaryDirectory);
 }
 
+sub jscProductDir
+{
+    return executableProductDir();
+}
+
 sub configuration()
 {
     determineConfiguration();
@@ -655,6 +698,11 @@
     $generateDsym = checkForArgumentAndRemoveFromARGV("--dsym");
 }
 
+sub hasIOSDevelopmentCertificate()
+{
+    return !exitStatus(system("security find-identity -p codesigning | grep '" . IOS_DEVELOPMENT_CERTIFICATE_NAME_PREFIX . "' > /dev/null 2>&1"));
+}
+
 sub argumentsForXcode()
 {
     my @args = ();
@@ -670,11 +718,25 @@
     determineASanIsEnabled();
     determineXcodeSDK();
 
-    my @sdkOption = ($xcodeSDK ? "SDKROOT=$xcodeSDK" : ());
-    my @architectureOption = ($architecture ? "ARCHS=$architecture" : ());
-    my @asanOption = ($asanIsEnabled ? ("-xcconfig", sourceDir() . "/Tools/asan/asan.xcconfig", "ASAN_IGNORE=" . sourceDir() . "/Tools/asan/webkit-asan-ignore.txt") : ());
-
-    return ("-UseSanitizedBuildSystemEnvironment=YES", @baseProductDirOption, "-configuration", $configuration, @architectureOption, @sdkOption, @asanOption, argumentsForXcode());
+    my @options;
+    push @options, "-UseSanitizedBuildSystemEnvironment=YES";
+    push @options, ("-configuration", $configuration);
+    push @options, ("-xcconfig", sourceDir() . "/Tools/asan/asan.xcconfig", "ASAN_IGNORE=" . sourceDir() . "/Tools/asan/webkit-asan-ignore.txt") if $asanIsEnabled;
+    push @options, @baseProductDirOption;
+    push @options, "ARCHS=$architecture" if $architecture;
+    push @options, "SDKROOT=$xcodeSDK" if $xcodeSDK;
+    if (willUseIOSDeviceSDK()) {
+        push @options, "ENABLE_BITCODE=NO";
+        if (hasIOSDevelopmentCertificate()) {
+            # FIXME: May match more than one installed development certificate.
+            push @options, "CODE_SIGN_IDENTITY=" . IOS_DEVELOPMENT_CERTIFICATE_NAME_PREFIX;
+        } else {
+            push @options, "CODE_SIGN_IDENTITY="; # No identity
+            push @options, "CODE_SIGNING_REQUIRED=NO";
+        }
+    }
+    push @options, argumentsForXcode();
+    return @options;
 }
 
 sub XcodeOptionString
@@ -715,8 +777,6 @@
     } elsif (checkForArgumentAndRemoveFromARGV("--profile") || checkForArgumentAndRemoveFromARGV("--profiling")) {
         $passedConfiguration = "Profiling";
     }
-
-    $passedConfiguration .= "_WinCairo" if (defined($passedConfiguration) && isWinCairo());
 }
 
 sub passedConfiguration
@@ -880,7 +940,7 @@
 # Check to see that all the frameworks are built.
 sub checkFrameworks # FIXME: This is a poor name since only the Mac calls built WebCore a Framework.
 {
-    return if isCygwin() || isWindows();
+    return if isAnyWindows();
     my @frameworks = ("_javascript_Core", "WebCore");
     push(@frameworks, "WebKit") if isAppleMacWebKit(); # FIXME: This seems wrong, all ports should have a WebKit these days.
     for my $framework (@frameworks) {
@@ -975,30 +1035,82 @@
     return scalar @indicesToRemove > 0;
 }
 
-sub determineIsEfl()
+sub prohibitUnknownPort()
 {
-    return if defined($isEfl);
-    $isEfl = checkForArgumentAndRemoveFromARGV("--efl");
+    $unknownPortProhibited = 1;
 }
 
-sub isEfl()
+sub determinePortName()
 {
-    determineIsEfl();
-    return $isEfl;
+    return if defined $portName;
+
+    my %argToPortName = (
+        efl => Efl,
+        gtk => GTK,
+        'jsc-only' => JSCOnly,
+        wincairo => WinCairo
+    );
+
+    for my $arg (sort keys %argToPortName) {
+        if (checkForArgumentAndRemoveFromARGV("--$arg")) {
+            die "Argument '--$arg' conflicts with selected port '$portName'\n"
+                if defined $portName;
+
+            $portName = $argToPortName{$arg};
+        }
+    }
+
+    return if defined $portName;
+
+    # Port was not selected via command line, use appropriate default value
+
+    if (isAnyWindows()) {
+        $portName = AppleWin;
+    } elsif (isDarwin()) {
+        determineXcodeSDK();
+        if (willUseIOSDeviceSDK() || willUseIOSSimulatorSDK()) {
+            $portName = iOS;
+        } else {
+            $portName = Mac;
+        }
+    } else {
+        if ($unknownPortProhibited) {
+            my $portsChoice = join "\n\t", qw(
+                --efl
+                --gtk
+                --jsc-only
+            );
+            die "Please specify which WebKit port to build using one of the following options:"
+                . "\n\t$portsChoice\n";
+        }
+
+        # If script is run without arguments we cannot determine port
+        # TODO: This state should be outlawed
+        $portName = Unknown;
+    }
 }
 
-sub determineIsGtk()
+sub portName()
 {
-    return if defined($isGtk);
-    $isGtk = checkForArgumentAndRemoveFromARGV("--gtk");
+    determinePortName();
+    return $portName;
 }
 
+sub isEfl()
+{
+    return portName() eq Efl;
+}
+
 sub isGtk()
 {
-    determineIsGtk();
-    return $isGtk;
+    return portName() eq GTK;
 }
 
+sub isJSCOnly()
+{
+    return portName() eq JSCOnly;
+}
+
 # Determine if this is debian, ubuntu, linspire, or something similar.
 sub isDebianBased()
 {
@@ -1012,16 +1124,9 @@
 
 sub isWinCairo()
 {
-    determineIsWinCairo();
-    return $isWinCairo;
+    return portName() eq WinCairo;
 }
 
-sub determineIsWinCairo()
-{
-    return if defined($isWinCairo);
-    $isWinCairo = checkForArgumentAndRemoveFromARGV("--wincairo");
-}
-
 sub isWin64()
 {
     determineIsWin64();
@@ -1034,6 +1139,13 @@
     $isWin64 = checkForArgumentAndRemoveFromARGV("--64-bit");
 }
 
+sub determineIsWin64FromArchitecture($)
+{
+    my $arch = shift;
+    $isWin64 = ($arch eq "x86_64");
+    return $isWin64;
+}
+
 sub isCygwin()
 {
     return ($^O eq "cygwin") || 0;
@@ -1109,6 +1221,11 @@
     return ($Config{archname} =~ /^arm[v\-]/) || ($Config{archname} =~ /^aarch64[v\-]/);
 }
 
+sub isX86_64()
+{
+    return (architecture() eq "x86_64") || 0;
+}
+
 sub isCrossCompilation()
 {
   my $compiler = "";
@@ -1130,12 +1247,12 @@
 
 sub isAppleMacWebKit()
 {
-    return isDarwin() && !isGtk();
+    return (portName() eq Mac) || isIOSWebKit();
 }
 
 sub isAppleWinWebKit()
 {
-    return (isCygwin() || isWindows()) && !isWinCairo() && !isGtk();
+    return portName() eq AppleWin;
 }
 
 sub iOSSimulatorDevicesPath
@@ -1186,20 +1303,19 @@
     die "Device $name $deviceTypeId $runtimeId wasn't found in " . iOSSimulatorDevicesPath();
 }
 
-sub willUseIOSDeviceSDKWhenBuilding()
+sub willUseIOSDeviceSDK()
 {
     return xcodeSDKPlatformName() eq "iphoneos";
 }
 
-sub willUseIOSSimulatorSDKWhenBuilding()
+sub willUseIOSSimulatorSDK()
 {
     return xcodeSDKPlatformName() eq "iphonesimulator";
 }
 
 sub isIOSWebKit()
 {
-    determineXcodeSDK();
-    return isAppleMacWebKit() && (willUseIOSDeviceSDKWhenBuilding() || willUseIOSSimulatorSDKWhenBuilding());
+    return portName() eq iOS;
 }
 
 sub determineNmPath()
@@ -1219,6 +1335,18 @@
     return $nmPath;
 }
 
+sub splitVersionString
+{
+    my $versionString = shift;
+    my @splitVersion = split(/\./, $versionString);
+    @splitVersion >= 2 or die "Invalid version $versionString";
+    $osXVersion = {
+            "major" => $splitVersion[0],
+            "minor" => $splitVersion[1],
+            "subminor" => (defined($splitVersion[2]) ? $splitVersion[2] : 0),
+    };
+}
+
 sub determineOSXVersion()
 {
     return if $osXVersion;
@@ -1228,14 +1356,8 @@
         return;
     }
 
-    my $version = `sw_vers -productVersion`;
-    my @splitVersion = split(/\./, $version);
-    @splitVersion >= 2 or die "Invalid version $version";
-    $osXVersion = {
-            "major" => $splitVersion[0],
-            "minor" => $splitVersion[1],
-            "subminor" => (defined($splitVersion[2]) ? $splitVersion[2] : 0),
-    };
+    my $versionString = `sw_vers -productVersion`;
+    $osXVersion = splitVersionString($versionString);
 }
 
 sub osXVersion()
@@ -1244,33 +1366,28 @@
     return $osXVersion;
 }
 
-sub isWindowsNT()
+sub determineIOSVersion()
 {
-    return $ENV{'OS'} eq 'Windows_NT';
-}
+    return if $iosVersion;
 
-sub shouldTargetWebProcess
-{
-    determineShouldTargetWebProcess();
-    return $shouldTargetWebProcess;
-}
+    if (!isIOSWebKit()) {
+        $iosVersion = -1;
+        return;
+    }
 
-sub determineShouldTargetWebProcess
-{
-    return if defined($shouldTargetWebProcess);
-    $shouldTargetWebProcess = checkForArgumentAndRemoveFromARGV("--target-web-process");
+    my $versionString = xcodeSDKVersion();
+    $iosVersion = splitVersionString($versionString);
 }
 
-sub shouldUseXPCServiceForWebProcess
+sub iosVersion()
 {
-    determineShouldUseXPCServiceForWebProcess();
-    return $shouldUseXPCServiceForWebProcess;
+    determineIOSVersion();
+    return $iosVersion;
 }
 
-sub determineShouldUseXPCServiceForWebProcess
+sub isWindowsNT()
 {
-    return if defined($shouldUseXPCServiceForWebProcess);
-    $shouldUseXPCServiceForWebProcess = checkForArgumentAndRemoveFromARGV("--use-web-process-xpc-service");
+    return $ENV{'OS'} eq 'Windows_NT';
 }
 
 sub debugger
@@ -1299,17 +1416,28 @@
     }
 }
 
-sub appendToEnvironmentVariableList
+sub appendToEnvironmentVariableList($$)
 {
-    my ($environmentVariableName, $value) = @_;
+    my ($name, $value) = @_;
 
-    if (defined($ENV{$environmentVariableName})) {
-        $ENV{$environmentVariableName} .= ":" . $value;
+    if (defined($ENV{$name})) {
+        $ENV{$name} .= $Config{path_sep} . $value;
     } else {
-        $ENV{$environmentVariableName} = $value;
+        $ENV{$name} = $value;
     }
 }
 
+sub prependToEnvironmentVariableList($$)
+{
+    my ($name, $value) = @_;
+
+    if (defined($ENV{$name})) {
+        $ENV{$name} = $value . $Config{path_sep} . $ENV{$name};
+    } else {
+        $ENV{$name} = $value;
+    }
+}
+
 sub sharedCommandLineOptions()
 {
     return (
@@ -1350,6 +1478,7 @@
 
     if ($shouldUseGuardMalloc) {
         appendToEnvironmentVariableList("DYLD_INSERT_LIBRARIES", "/usr/lib/libgmalloc.dylib");
+        appendToEnvironmentVariableList("__XPC_DYLD_INSERT_LIBRARIES", "/usr/lib/libgmalloc.dylib");
     }
 }
 
@@ -1379,7 +1508,7 @@
     } elsif (isAppleMacWebKit()) {
         return "Safari";
     } elsif (isAppleWinWebKit()) {
-        return "WinLauncher";
+        return "MiniBrowser";
     }
 }
 
@@ -1402,20 +1531,7 @@
             print "most likely fail. The latest Xcode is available from the App Store.\n";
             print "*************************************************************\n";
         }
-    } elsif (isGtk() or isEfl() or isWindows()) {
-        my @cmds = qw(bison gperf flex);
-        my @missing = ();
-        my $oldPath = $ENV{PATH};
-        foreach my $cmd (@cmds) {
-            push @missing, $cmd if not commandExists($cmd);
-        }
-
-        if (@missing) {
-            my $list = join ", ", @missing;
-            die "ERROR: $list missing but required to build WebKit.\n";
-        }
     }
-    # Win32 and other platforms may want to check for minimum config
 }
 
 sub determineWindowsSourceDir()
@@ -1517,6 +1633,8 @@
         $variablesToSet{WEBKIT_LIBRARIES} = windowsLibrariesDir() unless $ENV{WEBKIT_LIBRARIES};
         $variablesToSet{WEBKIT_OUTPUTDIR} = windowsOutputDir() unless $ENV{WEBKIT_OUTPUTDIR};
         $variablesToSet{MSBUILDDISABLENODEREUSE} = "1" unless $ENV{MSBUILDDISABLENODEREUSE};
+        $variablesToSet{_IsNativeEnvironment} = "true" unless $ENV{_IsNativeEnvironment};
+        $variablesToSet{PreferredToolArchitecture} = "x64" unless $ENV{PreferredToolArchitecture};
 
         foreach my $variable (keys %variablesToSet) {
             print "Setting the Environment Variable '" . $variable . "' to '" . $variablesToSet{$variable} . "'\n\n";
@@ -1555,7 +1673,7 @@
 
 sub setupCygwinEnv()
 {
-    return if !isCygwin() && !isWindows();
+    return if !isAnyWindows();
     return if $vcBuildPath;
 
     my $programFilesPath = programFilesPath();
@@ -1572,7 +1690,7 @@
             print "*************************************************************\n";
             print "Cannot find '$visualStudioPath'\n";
             print "Please execute the file 'vcvars32.bat' from\n";
-            print "'$programFilesPath\\Microsoft Visual Studio 12.0\\VC\\bin\\'\n";
+            print "'$programFilesPath\\Microsoft Visual Studio 14.0\\VC\\bin\\'\n";
             print "to setup the necessary environment variables.\n";
             print "*************************************************************\n";
             die;
@@ -1639,8 +1757,6 @@
         push(@extraOptions, "clean");
     }
 
-    push(@extraOptions, ("-sdk", xcodeSDK())) if isIOSWebKit();
-
     chomp($ENV{DSYMUTIL_NUM_THREADS} = `sysctl -n hw.activecpu`);
     return system "xcodebuild", "-project", "$project.xcodeproj", @extraOptions;
 }
@@ -1680,7 +1796,6 @@
     my $warningLogging = "/flp1:LogFile=" . $warningLogFile . ";WarningsOnly";
 
     my @command = ($vcBuildPath, "/verbosity:minimal", $project, $action, $config, $platform, "/fl", $errorLogging, "/fl1", $warningLogging);
-
     print join(" ", @command), "\n";
     return system @command;
 }
@@ -1723,8 +1838,14 @@
     return 0;
 }
 
-sub jhbuildWrapperPrefixIfNeeded()
+sub wrapperPrefixIfNeeded()
 {
+    if (isAnyWindows() || isJSCOnly()) {
+        return ();
+    }
+    if (isAppleMacWebKit()) {
+        return ("xcrun");
+    }
     if (-e getJhbuildPath()) {
         my @prefix = (File::Spec->catfile(sourceDir(), "Tools", "jhbuild", "jhbuild-wrapper"));
         if (isEfl()) {
@@ -1797,20 +1918,39 @@
 
 sub canUseNinja(@)
 {
+    if (!defined($shouldNotUseNinja)) {
+        $shouldNotUseNinja = checkForArgumentAndRemoveFromARGV("--no-ninja");
+    }
+
+    if ($shouldNotUseNinja) {
+        return 0;
+    }
+
     # Test both ninja and ninja-build. Fedora uses ninja-build and has patched CMake to also call ninja-build.
     return commandExists("ninja") || commandExists("ninja-build");
 }
 
-sub canUseEclipse(@)
+sub canUseNinjaGenerator(@)
 {
-    return commandExists("eclipse");
+    # Check that a Ninja generator is installed
+    my $devnull = File::Spec->devnull();
+    return exitStatus(system("cmake -N -G Ninja >$devnull 2>&1")) == 0;
 }
 
+sub canUseEclipseNinjaGenerator(@)
+{
+    # Check that eclipse and eclipse Ninja generator is installed
+    my $devnull = File::Spec->devnull();
+    return commandExists("eclipse") && exitStatus(system("cmake -N -G 'Eclipse CDT4 - Ninja' >$devnull 2>&1")) == 0;
+}
+
 sub cmakeGeneratedBuildfile(@)
 {
     my ($willUseNinja) = @_;
     if ($willUseNinja) {
         return File::Spec->catfile(baseProductDir(), configuration(), "build.ninja")
+    } elsif (isAnyWindows()) {
+        return File::Spec->catfile(baseProductDir(), configuration(), "WebKit.sln")
     } else {
         return File::Spec->catfile(baseProductDir(), configuration(), "Makefile")
     }
@@ -1818,15 +1958,16 @@
 
 sub generateBuildSystemFromCMakeProject
 {
-    my ($port, $prefixPath, @cmakeArgs, $additionalCMakeArgs) = @_;
+    my ($prefixPath, @cmakeArgs) = @_;
     my $config = configuration();
+    my $port = cmakeBasedPortName();
     my $buildPath = File::Spec->catdir(baseProductDir(), $config);
     File::Path::mkpath($buildPath) unless -d $buildPath;
     my $originalWorkingDirectory = getcwd();
     chdir($buildPath) or die;
 
     # We try to be smart about when to rerun cmake, so that we can have faster incremental builds.
-    my $willUseNinja = canUseNinja();
+    my $willUseNinja = canUseNinja() && canUseNinjaGenerator();
     if (-e cmakeCachePath() && -e cmakeGeneratedBuildfile($willUseNinja)) {
         return 0;
     }
@@ -1843,33 +1984,35 @@
 
     if ($willUseNinja) {
         push @args, "-G";
-        if (canUseEclipse()) {
+        if (canUseEclipseNinjaGenerator()) {
             push @args, "'Eclipse CDT4 - Ninja'";
         } else {
             push @args, "Ninja";
         }
+    } elsif (isAnyWindows() && isWin64()) {
+        push @args, '-G "Visual Studio 14 2015 Win64"';
     }
 
-    # GTK+ has a production mode, but build-webkit should always use developer mode.
-    push @args, "-DDEVELOPER_MODE=ON" if isEfl() || isGtk();
+    # Some ports have production mode, but build-webkit should always use developer mode.
+    push @args, "-DDEVELOPER_MODE=ON" if isEfl() || isGtk() || isJSCOnly();
 
     # Don't warn variables which aren't used by cmake ports.
     push @args, "--no-warn-unused-cli";
     push @args, @cmakeArgs if @cmakeArgs;
-    push @args, $additionalCMakeArgs if $additionalCMakeArgs;
 
-    push @args, '"' . sourceDir() . '"';
+    my $cmakeSourceDir = isCygwin() ? windowsSourceDir() : sourceDir();
+    push @args, '"' . $cmakeSourceDir . '"';
 
     # Compiler options to keep floating point values consistent
     # between 32-bit and 64-bit architectures.
     determineArchitecture();
-    if ($architecture ne "x86_64" && !isARM() && !isCrossCompilation()) {
+    if ($architecture ne "x86_64" && !isARM() && !isCrossCompilation() && !isAnyWindows()) {
         $ENV{'CXXFLAGS'} = "-march=pentium4 -msse2 -mfpmath=sse " . ($ENV{'CXXFLAGS'} || "");
     }
 
     # We call system("cmake @args") instead of system("cmake", @args) so that @args is
     # parsed for shell metacharacters.
-    my $wrapper = join(" ", jhbuildWrapperPrefixIfNeeded()) . " ";
+    my $wrapper = join(" ", wrapperPrefixIfNeeded()) . " ";
     my $returnCode = system($wrapper . "cmake @args");
 
     chdir($originalWorkingDirectory);
@@ -1889,8 +2032,8 @@
     my @args = ("--build", $buildPath, "--config", $config);
     push @args, ("--", $makeArgs) if $makeArgs;
 
-    # GTK can use a build script to preserve colors and pretty-printing.
-    if (isGtk() && -e "$buildPath/build.sh") {
+    # GTK and JSCOnly can use a build script to preserve colors and pretty-printing.
+    if ((isGtk() || isJSCOnly()) && -e "$buildPath/build.sh") {
         chdir "$buildPath" or die;
         $command = "$buildPath/build.sh";
         @args = ($makeArgs);
@@ -1903,9 +2046,8 @@
 
     # We call system("cmake @args") instead of system("cmake", @args) so that @args is
     # parsed for shell metacharacters. In particular, $makeArgs may contain such metacharacters.
-    my $wrapper = join(" ", jhbuildWrapperPrefixIfNeeded()) . " ";
+    my $wrapper = join(" ", wrapperPrefixIfNeeded()) . " ";
     return system($wrapper . "$command @args");
-
 }
 
 sub cleanCMakeGeneratedProject()
@@ -1918,9 +2060,9 @@
     return 0;
 }
 
-sub buildCMakeProjectOrExit($$$$@)
+sub buildCMakeProjectOrExit($$$@)
 {
-    my ($clean, $port, $prefixPath, $makeArgs, @cmakeArgs) = @_;
+    my ($clean, $prefixPath, $makeArgs, @cmakeArgs) = @_;
     my $returnCode;
 
     exit(exitStatus(cleanCMakeGeneratedProject())) if $clean;
@@ -1933,7 +2075,7 @@
         system("perl", "$sourceDir/Tools/Scripts/update-webkitgtk-libs") == 0 or die $!;
     }
 
-    $returnCode = exitStatus(generateBuildSystemFromCMakeProject($port, $prefixPath, @cmakeArgs));
+    $returnCode = exitStatus(generateBuildSystemFromCMakeProject($prefixPath, @cmakeArgs));
     exit($returnCode) if $returnCode;
 
     $returnCode = exitStatus(buildCMakeGeneratedProject($makeArgs));
@@ -1948,14 +2090,20 @@
 
 sub cmakeBasedPortName()
 {
-    return "Efl" if isEfl();
-    return "GTK" if isGtk();
-    return "";
+    return ucfirst portName();
 }
 
+sub determineIsCMakeBuild()
+{
+    return if defined($isCMakeBuild);
+    $isCMakeBuild = checkForArgumentAndRemoveFromARGV("--cmake");
+}
+
 sub isCMakeBuild()
 {
-    return isEfl() || isGtk();
+    return 1 unless isAppleMacWebKit();
+    determineIsCMakeBuild();
+    return $isCMakeBuild;
 }
 
 sub promptUser
@@ -1983,12 +2131,15 @@
 {
     my ($env) = @_;
 
-    if (isAppleWinWebKit()) {
-        $env->{PATH} = join(':', productDir(), appleApplicationSupportPath(), $env->{PATH} || "");
-    } elsif (isWinCairo()) {
-        my $winCairoBin = sourceDir() . "/WebKitLibraries/win/" . (isWin64() ? "bin64/" : "bin32/");
-        my $gstreamerBin = isWin64() ? $ENV{"GSTREAMER_1_0_ROOT_X86_64"} . "bin" : $ENV{"GSTREAMER_1_0_ROOT_X86"} . "bin";
-        $env->{PATH} = join(':', productDir(), $winCairoBin, $gstreamerBin, $env->{PATH} || "");
+    if (isAnyWindows()) {
+        my $productBinaryDir = executableProductDir();
+        if (isAppleWinWebKit()) {
+            $env->{PATH} = join(':', $productBinaryDir, appleApplicationSupportPath(), $env->{PATH} || "");
+        } elsif (isWinCairo()) {
+            my $winCairoBin = sourceDir() . "/WebKitLibraries/win/" . (isWin64() ? "bin64/" : "bin32/");
+            my $gstreamerBin = isWin64() ? $ENV{"GSTREAMER_1_0_ROOT_X86_64"} . "bin" : $ENV{"GSTREAMER_1_0_ROOT_X86"} . "bin";
+            $env->{PATH} = join(':', $productBinaryDir, $winCairoBin, $gstreamerBin, $env->{PATH} || "");
+        }
     }
 }
 
@@ -2003,12 +2154,10 @@
   --help                            Show this help message
   --no-saved-state                  Launch the application without state restoration (OS X 10.7 and later)
   -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
 
     if ($includeOptionsForDebugging) {
         print STDERR <<EOF;
-  --target-web-process              Debug the web process
   --use-gdb                         Use GDB (this is the default when using Xcode 4.4 or earlier)
   --use-lldb                        Use LLDB (this is the default when using Xcode 4.5 or later)
 EOF
@@ -2025,7 +2174,6 @@
         # FIXME: Don't set ApplePersistenceIgnoreState once all supported OS versions respect ApplePersistenceIgnoreStateQuietly (rdar://15032886).
         push @args, ("-ApplePersistenceIgnoreState", "YES");
     }
-    push @args, ("-WebKit2UseXPCServiceForWebProcess", "YES") if shouldUseXPCServiceForWebProcess();
     unshift @args, @ARGV;
 
     return @args;
@@ -2037,8 +2185,8 @@
 
     $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;
+    prependToEnvironmentVariableList("DYLD_FRAMEWORK_PATH", $dyldFrameworkPath);
+    prependToEnvironmentVariableList("__XPC_DYLD_FRAMEWORK_PATH", $dyldFrameworkPath);
     $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES";
 
     setUpGuardMallocIfNeeded();
@@ -2049,8 +2197,8 @@
     my ($dyldFrameworkPath) = @_;
     $dyldFrameworkPath = File::Spec->rel2abs($dyldFrameworkPath);
 
-    $ENV{DYLD_FRAMEWORK_PATH} = $dyldFrameworkPath;
-    $ENV{DYLD_LIBRARY_PATH} = $dyldFrameworkPath;
+    prependToEnvironmentVariableList("DYLD_FRAMEWORK_PATH", $dyldFrameworkPath);
+    prependToEnvironmentVariableList("DYLD_LIBRARY_PATH", $dyldFrameworkPath);
 
     setUpGuardMallocIfNeeded();
 }
@@ -2110,6 +2258,20 @@
     }
 }
 
+sub shutDownIOSSimulatorDevice($)
+{
+    my ($simulatorDevice) = @_;
+    system("xcrun --sdk iphonesimulator simctl shutdown $simulatorDevice->{UDID} > /dev/null 2>&1");
+}
+
+sub restartIOSSimulatorDevice($)
+{
+    my ($simulatorDevice) = @_;
+    shutDownIOSSimulatorDevice($simulatorDevice);
+
+    exitStatus(system("xcrun", "--sdk", "iphonesimulator", "simctl", "boot", $simulatorDevice->{UDID})) == 0 or die "Failed to boot simulator device $simulatorDevice->{UDID}";
+}
+
 sub relaunchIOSSimulator($)
 {
     my ($simulatedDevice) = @_;
@@ -2238,7 +2400,7 @@
     my $productDir = productDir();
     my $appDisplayName = appDisplayNameFromBundle($appBundle);
     my $appIdentifier = appIdentifierFromBundle($appBundle);
-    my $simulatedDevice = findOrCreateSimulatorForIOSDevice("For WebKit Development");
+    my $simulatedDevice = findOrCreateSimulatorForIOSDevice(SIMULATOR_DEVICE_SUFFIX_FOR_WEBKIT_DEVELOPMENT);
     my $simulatedDeviceUDID = $simulatedDevice->{UDID};
 
     my $willUseSystemInstalledApp = isIOSSimulatorSystemInstalledApp($appBundle);
@@ -2296,10 +2458,10 @@
 sub runIOSWebKitApp($)
 {
     my ($appBundle) = @_;
-    if (willUseIOSDeviceSDKWhenBuilding()) {
+    if (willUseIOSDeviceSDK()) {
         die "Only running Safari in iOS Simulator is supported now.";
     }
-    if (willUseIOSSimulatorSDKWhenBuilding()) {
+    if (willUseIOSSimulatorSDK()) {
         return runIOSWebKitAppInSimulator($appBundle);
     }
     die "Not using an iOS SDK."
@@ -2347,23 +2509,8 @@
     setupMacWebKitEnvironment($productDir);
 
     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";
-        exec { $debuggerPath } $debuggerPath, @architectureFlags, $argumentsSeparator, $appPath, argumentsForRunAndDebugMacWebKitApp() or die;
-    } else {
-        if (shouldUseXPCServiceForWebProcess()) {
-            die "Targeting the Web Process is not compatible with using an XPC Service for the Web Process at this time.";
-        }
-        
-        my $webProcessShimPath = File::Spec->catfile($productDir, "SecItemShim.dylib");
-        my $webProcessPath = File::Spec->catdir($productDir, "WebProcess.app");
-        my $webKit2ExecutablePath = File::Spec->catfile($productDir, "WebKit2.framework", "WebKit2");
-
-        appendToEnvironmentVariableList("DYLD_INSERT_LIBRARIES", $webProcessShimPath);
-
-        print "Starting WebProcess under $debugger with DYLD_FRAMEWORK_PATH set to point to built WebKit in $productDir.\n";
-        exec { $debuggerPath } $debuggerPath, @architectureFlags, $argumentsSeparator, $webProcessPath, $webKit2ExecutablePath, "-type", "webprocess", "-client-executable", $appPath or die;
-    }
+    print "Starting @{[basename($appPath)]} under $debugger with DYLD_FRAMEWORK_PATH set to point to built WebKit in $productDir.\n";
+    exec { $debuggerPath } $debuggerPath, @architectureFlags, $argumentsSeparator, $appPath, argumentsForRunAndDebugMacWebKitApp() or die;
 }
 
 sub debugSafari
@@ -2388,8 +2535,7 @@
 
     if (isAppleWinWebKit()) {
         my $result;
-        my $productDir = productDir();
-        my $webKitLauncherPath = File::Spec->catfile(productDir(), "WinLauncher.exe");
+        my $webKitLauncherPath = File::Spec->catfile(executableProductDir(), "MiniBrowser.exe");
         return system { $webKitLauncherPath } $webKitLauncherPath, @ARGV;
     }
 
@@ -2400,6 +2546,10 @@
 {
     if (isAppleMacWebKit()) {
         return runMacWebKitApp(File::Spec->catfile(productDir(), "MiniBrowser.app", "Contents", "MacOS", "MiniBrowser"));
+    } elsif (isAppleWinWebKit()) {
+        my $result;
+        my $webKitLauncherPath = File::Spec->catfile(executableProductDir(), "MiniBrowser.exe");
+        return system { $webKitLauncherPath } $webKitLauncherPath, @ARGV;
     }
 
     return 1;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to