⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 275081 in webkit


Ignore:
Timestamp:
Mar 25, 2021, 11:57:35 PM (5 years ago)
Author:
Cameron McCormack
Message:

Avoid calling xcodebuild -showsdks where possible.
https://bugs.webkit.org/show_bug.cgi?id=223727

Reviewed by Sam Weinig.

run-minibrowser needs to know what port it's running on, since that
affects the build directory to look in to find the MiniBrowser binary.
On macOS, webkitdirs.pm's determinePortName ends up running
xcodebuild -showsdks to see if the current SDK has an internal
variant available, but this is slow. But we don't need to know the
exact SDK name here, just the SDK platform name, to determine the
port name.

So we shuffle some code around to avoid calling xcodebuild -showsdks
where we can. This reduces the time spent in run-minibrowser before
MiniBrowser is launched (crudely measured with `time run-minibrowser
--help`) from 2s to 0.6s on this machine.

  • Scripts/webkitdirs.pm:

(readXcodeUserDefault):
(determineArchitecture):
(argumentsForConfiguration):
(availableXcodeSDKs):
(isValidXcodeSDKPlatformName):
(determineXcodeSDKPlatformName):
(determineXcodeSDK):
(xcodeSDKPlatformName):
(determinePortName):

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r275078 r275081  
     12021-03-25  Cameron McCormack  <heycam@apple.com>
     2
     3        Avoid calling `xcodebuild -showsdks` where possible.
     4        https://bugs.webkit.org/show_bug.cgi?id=223727
     5
     6        Reviewed by Sam Weinig.
     7
     8        run-minibrowser needs to know what port it's running on, since that
     9        affects the build directory to look in to find the MiniBrowser binary.
     10        On macOS, webkitdirs.pm's determinePortName ends up running
     11        `xcodebuild -showsdks` to see if the current SDK has an internal
     12        variant available, but this is slow.  But we don't need to know the
     13        exact SDK name here, just the SDK platform name, to determine the
     14        port name.
     15
     16        So we shuffle some code around to avoid calling `xcodebuild -showsdks`
     17        where we can.  This reduces the time spent in run-minibrowser before
     18        MiniBrowser is launched (crudely measured with `time run-minibrowser
     19        --help`) from 2s to 0.6s on this machine.
     20
     21        * Scripts/webkitdirs.pm:
     22        (readXcodeUserDefault):
     23        (determineArchitecture):
     24        (argumentsForConfiguration):
     25        (availableXcodeSDKs):
     26        (isValidXcodeSDKPlatformName):
     27        (determineXcodeSDKPlatformName):
     28        (determineXcodeSDK):
     29        (xcodeSDKPlatformName):
     30        (determinePortName):
     31
    1322021-03-25  Alex Christensen  <achristensen@webkit.org>
    233
  • trunk/Tools/Scripts/webkitdirs.pm

    r271614 r275081  
    141141my $configuration;
    142142my $xcodeSDK;
     143my $xcodeSDKPlatformName;
    143144my $simulatorIdiom;
    144145my $configurationForVisualStudio;
     
    401402            chomp $architecture;
    402403        } else {
    403             if ($xcodeSDK =~ /^iphoneos/) {
     404            if ($xcodeSDK eq /iphoneos/) {
    404405                $architecture = 'arm64';
    405             } elsif ($xcodeSDK =~ /^watchsimulator/) {
     406            } elsif ($xcodeSDK eq /watchsimulator/) {
    406407                $architecture = 'i386';
    407             } elsif ($xcodeSDK =~ /^watchos/) {
     408            } elsif ($xcodeSDK eq /watchos/) {
    408409                $architecture = 'arm64_32 arm64e armv7k';
    409             } elsif ($xcodeSDK =~ /^appletvos/) {
     410            } elsif ($xcodeSDK eq /appletvos/) {
    410411                $architecture = 'arm64';
    411412            }
     
    550551    determineArchitecture();
    551552    if (isAppleCocoaWebKit()) {
    552         determineXcodeSDK();
     553        determineXcodeSDKPlatformName();
    553554    }
    554555
     
    558559    push(@args, '--debug') if ($configuration =~ "^Debug");
    559560    push(@args, '--release') if ($configuration =~ "^Release");
    560     push(@args, '--ios-device') if (defined $xcodeSDK && $xcodeSDK =~ /^iphoneos/);
    561     push(@args, '--ios-simulator') if (defined $xcodeSDK && $xcodeSDK =~ /^iphonesimulator/ && $simulatorIdiom eq "iPhone");
    562     push(@args, '--ipad-simulator') if (defined $xcodeSDK && $xcodeSDK =~ /^iphonesimulator/ && $simulatorIdiom eq "iPad");
    563     push(@args, '--tvos-device') if (defined $xcodeSDK && $xcodeSDK =~ /^appletvos/);
    564     push(@args, '--tvos-simulator') if (defined $xcodeSDK && $xcodeSDK =~ /^appletvsimulator/);
    565     push(@args, '--watchos-device') if (defined $xcodeSDK && $xcodeSDK =~ /^watchos/);
    566     push(@args, '--watchos-simulator') if (defined $xcodeSDK && $xcodeSDK =~ /^watchsimulator/);
    567     push(@args, '--maccatalyst') if (defined $xcodeSDK && $xcodeSDK =~ /^maccatalyst/);
     561    push(@args, '--ios-device') if (defined $xcodeSDKPlatformName && $xcodeSDKPlatformName eq /^iphoneos/);
     562    push(@args, '--ios-simulator') if (defined $xcodeSDKPlatformName && $xcodeSDKPlatformName eq /^iphonesimulator/ && $simulatorIdiom eq "iPhone");
     563    push(@args, '--ipad-simulator') if (defined $xcodeSDKPlatformName && $xcodeSDKPlatformName eq /^iphonesimulator/ && $simulatorIdiom eq "iPad");
     564    push(@args, '--tvos-device') if (defined $xcodeSDKPlatformName && $xcodeSDKPlatformName eq /^appletvos/);
     565    push(@args, '--tvos-simulator') if (defined $xcodeSDKPlatformName && $xcodeSDKPlatformName eq /^appletvsimulator/);
     566    push(@args, '--watchos-device') if (defined $xcodeSDKPlatformName && $xcodeSDKPlatformName eq /^watchos/);
     567    push(@args, '--watchos-simulator') if (defined $xcodeSDKPlatformName && $xcodeSDKPlatformName eq /^watchsimulator/);
     568    push(@args, '--maccatalyst') if (defined $xcodeSDKPlatformName && $xcodeSDKPlatformName eq /^maccatalyst/);
    568569    push(@args, '--32-bit') if ($architecture eq "x86" and !isWin64());
    569570    push(@args, '--64-bit') if (isWin64());
     
    623624}
    624625
    625 sub determineXcodeSDK
    626 {
    627     return if defined $xcodeSDK;
     626sub isValidXcodeSDKPlatformName($) {
     627    my $name = shift;
     628    my @platforms = qw(
     629        appletvos
     630        appletvsimulator
     631        iphoneos
     632        iphonesimulator
     633        macosx
     634        watchos
     635        watchsimulator
     636        maccatalyst
     637    );
     638    return grep { $_ eq $name } @platforms;
     639}
     640
     641sub determineXcodeSDKPlatformName {
     642    return if defined $xcodeSDKPlatformName;
    628643    my $sdk;
    629644   
    630645    # The user explicitly specified the sdk, don't assume anything
    631646    if (checkForArgumentAndRemoveFromARGVGettingValue("--sdk", \$sdk)) {
    632         $xcodeSDK = $sdk;
     647        $xcodeSDK = lc $sdk;
     648        $xcodeSDKPlatformName = $sdk;
     649        $xcodeSDKPlatformName =~ s/\.internal$//;
     650        die "Couldn't determine platform name from Xcode SDK" unless isValidXcodeSDKPlatformName($xcodeSDKPlatformName);
    633651        return;
    634652    }
    635653    if (checkForArgumentAndRemoveFromARGV("--device") || checkForArgumentAndRemoveFromARGV("--ios-device")) {
    636         $xcodeSDK ||= "iphoneos";
     654        $xcodeSDKPlatformName ||= "iphoneos";
    637655    }
    638656    if (checkForArgumentAndRemoveFromARGV("--simulator") || checkForArgumentAndRemoveFromARGV("--ios-simulator")) {
    639         $xcodeSDK ||= 'iphonesimulator';
     657        $xcodeSDKPlatformName ||= 'iphonesimulator';
    640658        $simulatorIdiom = 'iPhone';
    641659    }
    642660    if (checkForArgumentAndRemoveFromARGV("--ipad-simulator")) {
    643         $xcodeSDK ||= 'iphonesimulator';
     661        $xcodeSDKPlatformName ||= 'iphonesimulator';
    644662        $simulatorIdiom = 'iPad';
    645663    }
    646664    if (checkForArgumentAndRemoveFromARGV("--tvos-device")) {
    647         $xcodeSDK ||= "appletvos";
     665        $xcodeSDKPlatformName ||= "appletvos";
    648666    }
    649667    if (checkForArgumentAndRemoveFromARGV("--tvos-simulator")) {
    650         $xcodeSDK ||= "appletvsimulator";
     668        $xcodeSDKPlatformName ||= "appletvsimulator";
    651669    }
    652670    if (checkForArgumentAndRemoveFromARGV("--watchos-device")) {
    653         $xcodeSDK ||= "watchos";
     671        $xcodeSDKPlatformName ||= "watchos";
    654672    }
    655673    if (checkForArgumentAndRemoveFromARGV("--watchos-simulator")) {
    656         $xcodeSDK ||= "watchsimulator";
     674        $xcodeSDKPlatformName ||= "watchsimulator";
    657675    }
    658676    if (checkForArgumentAndRemoveFromARGV("--maccatalyst")) {
    659         $xcodeSDK ||= "maccatalyst";
     677        $xcodeSDKPlatformName ||= "maccatalyst";
    660678    }
    661679
    662680    # Finally, fall back to macOS if no platform is specified.
    663     if (!defined $xcodeSDK) {
    664         $xcodeSDK = "macosx";
    665     }
    666    
     681    $xcodeSDKPlatformName ||= "macosx";
     682}
     683
     684sub determineXcodeSDK
     685{
     686    determineXcodeSDKPlatformName();  # This can set $xcodeSDK if --sdk was used.
     687    return if defined $xcodeSDK;
     688
     689    $xcodeSDK = $xcodeSDKPlatformName;
     690
    667691    # Prefer the internal version of an sdk, if it exists.
    668692    my @availableSDKs = availableXcodeSDKs();
    669693
    670694    foreach my $sdk (@availableSDKs) {
    671         next if $sdk ne "$xcodeSDK.internal";
     695        next if $sdk ne "$xcodeSDKPlatformName.internal";
    672696        $xcodeSDK = $sdk;
    673697        last;
     
    686710}
    687711
    688 
    689 sub xcodeSDKPlatformName()
    690 {
    691     determineXcodeSDK();
    692     return "" if !defined $xcodeSDK;
    693     return "appletvos" if $xcodeSDK =~ /appletvos/i;
    694     return "appletvsimulator" if $xcodeSDK =~ /appletvsimulator/i;
    695     return "iphoneos" if $xcodeSDK =~ /iphoneos/i;
    696     return "iphonesimulator" if $xcodeSDK =~ /iphonesimulator/i;
    697     return "macosx" if $xcodeSDK =~ /macosx/i;
    698     return "watchos" if $xcodeSDK =~ /watchos/i;
    699     return "watchsimulator" if $xcodeSDK =~ /watchsimulator/i;
    700     return "maccatalyst" if $xcodeSDK =~ /maccatalyst/i;
    701     die "Couldn't determine platform name from Xcode SDK";
     712sub xcodeSDKPlatformName
     713{
     714    determineXcodeSDKPlatformName();
     715    return $xcodeSDKPlatformName;
    702716}
    703717
     
    13451359        $portName = AppleWin;
    13461360    } elsif (isDarwin()) {
    1347         determineXcodeSDK();
     1361        determineXcodeSDKPlatformName();
    13481362        if (willUseIOSDeviceSDK() || willUseIOSSimulatorSDK()) {
    13491363            $portName = iOS;
Note: See TracChangeset for help on using the changeset viewer.