Changeset 260758 in webkit
- Timestamp:
- Apr 27, 2020, 9:04:30 AM (6 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
Scripts/webkitdirs.pm (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r260756 r260758 1 2020-04-27 Alexey Proskuryakov <ap@apple.com> 2 3 Make run-safari --ios-simulator work again 4 https://bugs.webkit.org/show_bug.cgi?id=211008 5 6 Reviewed by Darin Adler. 7 8 While at it, removed all direct uses of device.plist, and all use of Foundation. 9 10 * Scripts/webkitdirs.pm: Stopped exporting unused simulator related functions. New 11 code should be using webkitpy. 12 (simulatorDeviceFromJSON): Helper function for parsing simctl output. 13 (iOSSimulatorDevices): Use simctl instead of reading device.plist. 14 (createiOSSimulatorDevice): Device creation appears to be synchronous, I couldn't 15 find any reason for waiting and retrying. 16 (iosSimulatorApplicationsPath): This is part of the actual fix - runtime path built 17 here was incorrect; switched to one provided by simctl. 18 (shutDownIOSSimulatorDevice): Added an early return to avoid stderr spew. 19 (relaunchIOSSimulator): Another part of the actual fix: open Simulator.app before booting the 20 simulator to have it visible; CurrentDeviceUDID doesn't work. 21 (iosSimulatorDeviceByUDID): Stop using device.plist. 22 (runIOSWebKitAppInSimulator): Stop quitting Simulator.app, we only needed to shut down 23 the device. 24 (iOSSimulatorDevicesPath): Deleted. 25 (quitIOSSimulator): Deleted. 26 1 27 2020-04-27 Daniel Bates <dabates@apple.com> 2 28 -
trunk/Tools/Scripts/webkitdirs.pm
r260240 r260758 43 43 use File::Temp qw(tempdir); 44 44 use File::stat; 45 use JSON::PP; 45 46 use List::Util; 46 47 use POSIX; … … 71 72 &executableProductDir 72 73 &extractNonHostConfiguration 73 &findOrCreateSimulatorForIOSDevice74 &iosSimulatorDeviceByName75 74 &iosVersion 76 75 &nmPath … … 79 78 &printHelpAndExitForRunAndDebugWebKitAppIfNeeded 80 79 &productDir 81 &quitIOSSimulator82 &relaunchIOSSimulator83 &restartIOSSimulatorDevice84 80 &runIOSWebKitApp 85 81 &runMacWebKitApp … … 94 90 &shouldUseFlatpak 95 91 &runInFlatpak 96 &shutDownIOSSimulatorDevice97 92 &sourceDir 98 93 &willUseIOSDeviceSDK 99 94 &willUseIOSSimulatorSDK 100 95 DO_NOT_USE_OPEN_COMMAND 101 SIMULATOR_DEVICE_SUFFIX_FOR_WEBKIT_DEVELOPMENT102 96 USE_OPEN_COMMAND 103 97 ); … … 125 119 use constant USE_OPEN_COMMAND => 1; # Used in runMacWebKitApp(). 126 120 use constant DO_NOT_USE_OPEN_COMMAND => 2; 127 use constant SIMULATOR_DEVICE_STATE_SHUTDOWN => " 1";128 use constant SIMULATOR_DEVICE_STATE_BOOTED => " 3";121 use constant SIMULATOR_DEVICE_STATE_SHUTDOWN => "Shutdown"; 122 use constant SIMULATOR_DEVICE_STATE_BOOTED => "Booted"; 129 123 use constant SIMULATOR_DEVICE_SUFFIX_FOR_WEBKIT_DEVELOPMENT => "For WebKit Development"; 130 124 … … 1512 1506 } 1513 1507 1514 sub iOSSimulatorDevicesPath 1515 { 1516 return "$ENV{HOME}/Library/Developer/CoreSimulator/Devices"; 1508 sub simulatorDeviceFromJSON 1509 { 1510 my $runtime = shift; 1511 my $jsonDevice = shift; 1512 1513 return { 1514 "UDID" => $jsonDevice->{udid}, 1515 "name" => $jsonDevice->{name}, 1516 "runtime" => $runtime, 1517 "state" => $jsonDevice->{state}, 1518 "deviceType" => $jsonDevice->{deviceTypeIdentifier} 1519 }; 1517 1520 } 1518 1521 1519 1522 sub iOSSimulatorDevices 1520 1523 { 1521 eval "require Foundation"; 1522 my $devicesPath = iOSSimulatorDevicesPath(); 1523 opendir(DEVICES, $devicesPath); 1524 my @udids = grep { 1525 $_ =~ m/^[0-9A-F]{8}-([0-9A-F]{4}-){3}[0-9A-F]{12}$/; 1526 } readdir(DEVICES); 1527 close(DEVICES); 1528 1529 # FIXME: We should parse the device.plist file ourself and map the dictionary keys in it to known 1530 # dictionary keys so as to decouple our representation of the plist from the actual structure 1531 # of the plist, which may change. 1532 my @devices = map { 1533 Foundation::perlRefFromObjectRef(NSDictionary->dictionaryWithContentsOfFile_("$devicesPath/$_/device.plist")); 1534 } @udids; 1524 my $output = `xcrun simctl list devices --json`; 1525 my $runtimes = decode_json($output)->{devices}; 1526 if (!$runtimes) { 1527 die "No simulator devices found"; 1528 } 1529 1530 my @devices = (); 1531 while ((my $runtime, my $devicesForRuntime) = each %$runtimes) { 1532 foreach my $jsonDevice (@$devicesForRuntime) { 1533 next if $jsonDevice->{availabilityError}; 1534 push @devices, simulatorDeviceFromJSON($runtime, $jsonDevice); 1535 } 1536 } 1535 1537 1536 1538 return @devices; … … 1546 1548 die "Couldn't create simulator device: $name $deviceTypeId $runtimeId" if not $created; 1547 1549 1548 system("xcrun", "--sdk", "iphonesimulator", "simctl", "list"); 1549 1550 print "Waiting for device to be created ...\n"; 1551 sleep 5; 1552 for (my $tries = 0; $tries < 5; $tries++){ 1553 my @devices = iOSSimulatorDevices(); 1554 foreach my $device (@devices) { 1555 return $device if $device->{name} eq $name and $device->{deviceType} eq $deviceTypeId and $device->{runtime} eq $runtimeId; 1556 } 1557 sleep 5; 1558 } 1559 die "Device $name $deviceTypeId $runtimeId wasn't found in " . iOSSimulatorDevicesPath(); 1550 my @devices = iOSSimulatorDevices(); 1551 foreach my $device (@devices) { 1552 return $device if $device->{name} eq $name and $device->{deviceType} eq $deviceTypeId and $device->{runtime} eq $runtimeId; 1553 } 1554 1555 die "Device $name $deviceTypeId $runtimeId wasn't found"; 1560 1556 } 1561 1557 … … 2643 2639 sub iosSimulatorApplicationsPath() 2644 2640 { 2645 # FIXME: We should ask simctl for this information, instead of guessing from available runtimes.2646 my $runtime Path = File::Spec->catdir(sdkPlatformDirectory("iphoneos"), "Library", "Developer", "CoreSimulator", "Profiles", "Runtimes");2647 opendir(RUNTIMES, $runtimePath);2648 my @runtimes = grep {/.*\.simruntime/} readdir(RUNTIMES);2649 close(RUNTIMES);2650 my $ sult = File::Spec->catdir($runtimePath, @runtimes ? $runtimes[0] : "iOS.simruntime", "Contents", "Resources", "RuntimeRoot", "Applications");2651 return $sult;2641 my $output = `xcrun simctl list runtimes iOS --json`; 2642 my $runtimes = decode_json($output)->{runtimes}; 2643 if (!$runtimes) { 2644 die "No iOS simulator runtimes found"; 2645 } 2646 my $runtimePath = @$runtimes[0]->{runtimeRoot}; 2647 return File::Spec->catdir($runtimePath, "Applications"); 2652 2648 } 2653 2649 … … 2714 2710 { 2715 2711 my ($simulatorDevice) = @_; 2712 2713 return if $simulatorDevice->{state} eq SIMULATOR_DEVICE_STATE_SHUTDOWN; 2716 2714 system("xcrun --sdk iphonesimulator simctl shutdown $simulatorDevice->{UDID} > /dev/null 2>&1"); 2717 2715 } … … 2728 2726 { 2729 2727 my ($simulatedDevice) = @_; 2730 quitIOSSimulator($simulatedDevice->{UDID}); 2731 2732 # FIXME: <rdar://problem/20916140> Switch to using CoreSimulator.framework for launching and quitting iOS Simulator 2728 shutDownIOSSimulatorDevice($simulatedDevice); 2729 2733 2730 chomp(my $developerDirectory = $ENV{DEVELOPER_DIR} || `xcode-select --print-path`); 2734 my $iosSimulatorPath = File::Spec->catfile($developerDirectory, "Applications", "Simulator.app"); 2731 my $iosSimulatorPath = File::Spec->catfile($developerDirectory, "Applications", "Simulator.app"); 2732 # Simulator.app needs to be running before the simulator is booted to have it visible. 2735 2733 system("open", "-a", $iosSimulatorPath, "--args", "-CurrentDeviceUDID", $simulatedDevice->{UDID}) == 0 or die "Failed to open $iosSimulatorPath: $!"; 2734 system("xcrun", "simctl", "boot", $simulatedDevice->{UDID}) == 0 or die "Failed to boot simulator $simulatedDevice->{UDID}: $!"; 2736 2735 2737 2736 waitUntilIOSSimulatorDeviceIsInState($simulatedDevice->{UDID}, SIMULATOR_DEVICE_STATE_BOOTED); 2738 2737 waitUntilProcessNotRunning("com.apple.datamigrator"); 2739 }2740 2741 sub quitIOSSimulator(;$)2742 {2743 my ($waitForShutdownOfSimulatedDeviceUDID) = @_;2744 # FIXME: <rdar://problem/20916140> Switch to using CoreSimulator.framework for launching and quitting iOS Simulator2745 if (exitStatus(system {"osascript"} "osascript", "-e", 'tell application id "com.apple.iphonesimulator" to quit')) {2746 # osascript returns a non-zero exit status if Simulator.app is not registered in LaunchServices.2747 return;2748 }2749 2750 if (!defined($waitForShutdownOfSimulatedDeviceUDID)) {2751 return;2752 }2753 # FIXME: We assume that $waitForShutdownOfSimulatedDeviceUDID was not booted using the simctl command line tool.2754 # Otherwise we will spin indefinitely since quiting the iOS Simulator will not shutdown this device. We2755 # should add a maximum time limit to wait for a device to shutdown and either return an error or die()2756 # on expiration of the time limit.2757 waitUntilIOSSimulatorDeviceIsInState($waitForShutdownOfSimulatedDeviceUDID, SIMULATOR_DEVICE_STATE_SHUTDOWN);2758 2738 } 2759 2739 … … 2774 2754 { 2775 2755 my ($simulatedDeviceUDID) = @_; 2776 my $devicePlistPath = File::Spec->catfile(iOSSimulatorDevicesPath(), $simulatedDeviceUDID, "device.plist"); 2777 if (!-f $devicePlistPath) { 2778 return; 2779 } 2780 # FIXME: We should parse the device.plist file ourself and map the dictionary keys in it to known 2781 # dictionary keys so as to decouple our representation of the plist from the actual structure 2782 # of the plist, which may change. 2783 eval "require Foundation"; 2784 return Foundation::perlRefFromObjectRef(NSDictionary->dictionaryWithContentsOfFile_($devicePlistPath)); 2756 2757 my $output = `xcrun simctl list devices $simulatedDeviceUDID --json`; 2758 my $runtimes = decode_json($output)->{devices}; 2759 2760 while ((my $runtime, my $devicesForRuntime) = each %$runtimes) { 2761 next if not @$devicesForRuntime; 2762 die "Multiple devices found for UDID $simulatedDeviceUDID: $output" if scalar(@$devicesForRuntime) > 1; 2763 return simulatorDeviceFromJSON($runtime, @$devicesForRuntime[0]); 2764 } 2765 return undef; 2785 2766 } 2786 2767 … … 2872 2853 # FIXME: Only restore the system-installed version of the app instead of erasing all contents and settings. 2873 2854 print "Quitting iOS Simulator...\n"; 2874 quitIOSSimulator($simulatedDeviceUDID);2855 shutDownIOSSimulatorDevice($simulatedDevice); 2875 2856 print "Erasing contents and settings for simulator device \"$simulatedDevice->{name}\".\n"; 2876 2857 exitStatus(system("xcrun", "--sdk", "iphonesimulator", "simctl", "erase", $simulatedDeviceUDID)) == 0 or die;
Note:
See TracChangeset
for help on using the changeset viewer.