configure-xcode-for-ios-development needs to update iPhoneOS SDK
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Jan 2015 15:51:58 +0000 (15:51 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Jan 2015 15:51:58 +0000 (15:51 +0000)
<http://webkit.org/b/140661>

Reviewed by Daniel Bates.

* Scripts/configure-xcode-for-ios-development: Add for() loop to
run createXcodeSpecificationFilesForSDKIfNeeded() for both
"iphoneos" and "iphonesimulator" SDKs.
(createXcodeSpecificationFilesForSDKIfNeeded): Extracted from
the main body of the script.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178709 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/configure-xcode-for-ios-development

index 571c7a735e5055de64b5a6e6fd73029510ce6902..fafc39067fe5004ac4661f438a5678f8b8da5f62 100644 (file)
@@ -1,3 +1,16 @@
+2015-01-20  David Kilzer  <ddkilzer@apple.com>
+
+        configure-xcode-for-ios-development needs to update iPhoneOS SDK
+        <http://webkit.org/b/140661>
+
+        Reviewed by Daniel Bates.
+
+        * Scripts/configure-xcode-for-ios-development: Add for() loop to
+        run createXcodeSpecificationFilesForSDKIfNeeded() for both
+        "iphoneos" and "iphonesimulator" SDKs.
+        (createXcodeSpecificationFilesForSDKIfNeeded): Extracted from
+        the main body of the script.
+
 2015-01-20  Tomas Popela  <tpopela@redhat.com>
 
         [GTK] Add API to set the web view editable into WebKit2 GTK+ API
index 103c5f9a3d8dba63a2cbfccf5cca398d015cee3f..e1f93d6f9c6432677f89de11dc2954f37d278684 100755 (executable)
@@ -38,12 +38,14 @@ use File::Find;
 use File::Spec;
 use File::Temp qw(tempfile);
 
+sub createXcodeSpecificationFilesForSDKIfNeeded($);
 sub createXcodeSpecificationFromSpecificationAndId($$$);
 sub readXcodeSpecificationById($$);
 sub xcodeSDKSpecificationsPath($);
 
 use constant COMMAND_LINE_PACKAGE_TYPE => "com.apple.package-type.mach-o-executable";
 use constant COMMAND_LINE_PRODUCT_TYPE => "com.apple.product-type.tool";
+use constant SDK_TO_XCSPEC_NAME_MAP => +{ "iphoneos" => "iPhoneOS", "iphonesimulator" => "iPhone Simulator " };
 
 # FIXME: We should only require running as root if needed. It's not necessary to run as root if
 #        Xcode was installed by the user, say via a download from <http://developer.apple.com>.
@@ -52,61 +54,71 @@ if ($EFFECTIVE_USER_ID) {
     exit 1;
 }
 
-my $iosSimulatorSDKSpecificationsPath = xcodeSDKSpecificationsPath("iphonesimulator");
+for my $sdk (qw(iphoneos iphonesimulator)) {
+    createXcodeSpecificationFilesForSDKIfNeeded($sdk);
+}
+
+exit 0;
 
-my @xcodeSpecificationFiles;
-sub wanted
+sub createXcodeSpecificationFilesForSDKIfNeeded($)
 {
-    my $file = $_;
+    my ($sdk) = @_;
+    my $sdkSpecificationsPath = xcodeSDKSpecificationsPath($sdk);
+
+    local @::xcodeSpecificationFiles;
+    sub wanted
+    {
+        my $file = $_;
+
+        # Ignore hidden files/directories.
+        if ($file =~ /^\../) {
+            $File::Find::prune = 1;
+            return;
+        }
 
-    # Ignore hidden files/directories.
-    if ($file =~ /^\../) {
-        $File::Find::prune = 1;
-        return;
-    }
+        if (!-f $file || $file !~ /\.xcspec$/) {
+            return;
+        }
 
-    if (!-f $file || $file !~ /\.xcspec$/) {
-        return;
+        push @::xcodeSpecificationFiles, $File::Find::name;
     }
 
-    push @xcodeSpecificationFiles, $File::Find::name;
-}
-
-find(\&wanted, $iosSimulatorSDKSpecificationsPath);
+    find(\&wanted, $sdkSpecificationsPath);
 
-my $hasPackageTypeForCommandLineTool;
-my $hasProductTypeForCommandLineTool;
-foreach my $specificationFile (@xcodeSpecificationFiles) {
-    last if $hasPackageTypeForCommandLineTool && $hasProductTypeForCommandLineTool;
-    if (!$hasPackageTypeForCommandLineTool && readXcodeSpecificationById($specificationFile, COMMAND_LINE_PACKAGE_TYPE)) {
-        $hasPackageTypeForCommandLineTool = 1;
-        next;
+    my $hasPackageTypeForCommandLineTool;
+    my $hasProductTypeForCommandLineTool;
+    foreach my $specificationFile (@::xcodeSpecificationFiles) {
+        last if $hasPackageTypeForCommandLineTool && $hasProductTypeForCommandLineTool;
+        if (!$hasPackageTypeForCommandLineTool && readXcodeSpecificationById($specificationFile, COMMAND_LINE_PACKAGE_TYPE)) {
+            $hasPackageTypeForCommandLineTool = 1;
+            next;
+        }
+        if (!$hasProductTypeForCommandLineTool && readXcodeSpecificationById($specificationFile, COMMAND_LINE_PRODUCT_TYPE)) {
+            $hasProductTypeForCommandLineTool = 1;
+            next;
+        }
     }
-    if (!$hasProductTypeForCommandLineTool && readXcodeSpecificationById($specificationFile, COMMAND_LINE_PRODUCT_TYPE)) {
-        $hasProductTypeForCommandLineTool = 1;
-        next;
+
+    if ($hasPackageTypeForCommandLineTool && $hasProductTypeForCommandLineTool) {
+        return; # Xcode knows how to build a command line tool for $sdk.
     }
-}
 
-if ($hasPackageTypeForCommandLineTool && $hasProductTypeForCommandLineTool) {
-    exit 0; # Xcode knows how to build a command line tool for the iOS Simulator.
-}
+    my $fileNamePrefix = SDK_TO_XCSPEC_NAME_MAP->{$sdk};
 
-my $macosxSDKSpecificationsPath = xcodeSDKSpecificationsPath("macosx");
-if (!$hasPackageTypeForCommandLineTool) {
-    my $packageTypesForMacOSXPath = File::Spec->catfile($macosxSDKSpecificationsPath, "MacOSX Package Types.xcspec");
-    my $packageTypesForWebKitDevelopmentPath = File::Spec->catfile($iosSimulatorSDKSpecificationsPath, "iPhone Simulator PackageTypes For WebKit Development.xcspec");
-    createXcodeSpecificationFromSpecificationAndId($packageTypesForWebKitDevelopmentPath, $packageTypesForMacOSXPath, COMMAND_LINE_PACKAGE_TYPE);
-}
+    my $macosxSDKSpecificationsPath = xcodeSDKSpecificationsPath("macosx");
+    if (!$hasPackageTypeForCommandLineTool) {
+        my $packageTypesForMacOSXPath = File::Spec->catfile($macosxSDKSpecificationsPath, "MacOSX Package Types.xcspec");
+        my $packageTypesForWebKitDevelopmentPath = File::Spec->catfile($sdkSpecificationsPath, "${fileNamePrefix}PackageTypes For WebKit Development.xcspec");
+        createXcodeSpecificationFromSpecificationAndId($packageTypesForWebKitDevelopmentPath, $packageTypesForMacOSXPath, COMMAND_LINE_PACKAGE_TYPE);
+    }
 
-if (!$hasProductTypeForCommandLineTool) {
-    my $productTypesForMacOSXPath = File::Spec->catfile($macosxSDKSpecificationsPath, "MacOSX Product Types.xcspec");
-    my $productTypesForWebKitDevelopmentPath = File::Spec->catfile($iosSimulatorSDKSpecificationsPath, "iPhone Simulator ProductTypes For WebKit Development.xcspec");
-    createXcodeSpecificationFromSpecificationAndId($productTypesForWebKitDevelopmentPath, $productTypesForMacOSXPath, COMMAND_LINE_PRODUCT_TYPE);
+    if (!$hasProductTypeForCommandLineTool) {
+        my $productTypesForMacOSXPath = File::Spec->catfile($macosxSDKSpecificationsPath, "MacOSX Product Types.xcspec");
+        my $productTypesForWebKitDevelopmentPath = File::Spec->catfile($sdkSpecificationsPath, "${fileNamePrefix}ProductTypes For WebKit Development.xcspec");
+        createXcodeSpecificationFromSpecificationAndId($productTypesForWebKitDevelopmentPath, $productTypesForMacOSXPath, COMMAND_LINE_PRODUCT_TYPE);
+    }
 }
 
-exit 0;
-
 sub writeXcodeSpecification($$)
 {
     my ($xcodeSpecificationFile, $specification) = @_;