Title: [190333] trunk/Tools
Revision
190333
Author
dba...@webkit.org
Date
2015-09-29 17:21:39 -0700 (Tue, 29 Sep 2015)

Log Message

configure-xcode-for-ios-development does not work with Xcode 7
https://bugs.webkit.org/show_bug.cgi?id=149640

Reviewed by Alexey Proskuryakov.

When Xcode 7 is installed, running configure-xcode-for-ios-development dies with an error
because it cannot find the Xcode specification files for iOS simulator and device. These
files have moved to a new location in Xcode 7 distribution. Moreover we must add the
relevant definitions to the Xcode 7 specification files directly as opposed to creating
new specification files with the added definitions (as we did in older versions of Xcode)
in order for Xcode 7 to honor these definitions.

* Scripts/configure-xcode-for-ios-development: Sorted forward declarations.
(updateXcodeSpecificationFilesForSDKIfNeeded): Added.
(updateXcode7SpecificationFile): Added.
(createLegacyXcodeSpecificationFilesForSDKIfNeeded): Formerly named createXcodeSpecificationFilesForSDKIfNeeded.
(writeXcodeSpecification): Moved congratulations line to caller so as to write out the
appropriate success message.
(mergeXcodeSpecificationWithSpecificationAndId): Formerly named createXcodeSpecificationFromSpecificationAndId.
(createXcodeSpecificationFilesForSDKIfNeeded): Deleted.
(createXcodeSpecificationFromSpecificationAndId): Deleted.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (190332 => 190333)


--- trunk/Tools/ChangeLog	2015-09-30 00:16:31 UTC (rev 190332)
+++ trunk/Tools/ChangeLog	2015-09-30 00:21:39 UTC (rev 190333)
@@ -1,3 +1,27 @@
+2015-09-29  Daniel Bates  <daba...@apple.com>
+
+        configure-xcode-for-ios-development does not work with Xcode 7
+        https://bugs.webkit.org/show_bug.cgi?id=149640
+
+        Reviewed by Alexey Proskuryakov.
+
+        When Xcode 7 is installed, running configure-xcode-for-ios-development dies with an error
+        because it cannot find the Xcode specification files for iOS simulator and device. These
+        files have moved to a new location in Xcode 7 distribution. Moreover we must add the
+        relevant definitions to the Xcode 7 specification files directly as opposed to creating
+        new specification files with the added definitions (as we did in older versions of Xcode)
+        in order for Xcode 7 to honor these definitions.
+
+        * Scripts/configure-xcode-for-ios-development: Sorted forward declarations.
+        (updateXcodeSpecificationFilesForSDKIfNeeded): Added.
+        (updateXcode7SpecificationFile): Added.
+        (createLegacyXcodeSpecificationFilesForSDKIfNeeded): Formerly named createXcodeSpecificationFilesForSDKIfNeeded.
+        (writeXcodeSpecification): Moved congratulations line to caller so as to write out the
+        appropriate success message.
+        (mergeXcodeSpecificationWithSpecificationAndId): Formerly named createXcodeSpecificationFromSpecificationAndId.
+        (createXcodeSpecificationFilesForSDKIfNeeded): Deleted.
+        (createXcodeSpecificationFromSpecificationAndId): Deleted.
+
 2015-09-29  Brent Fulgham  <bfulg...@apple.com>
 
         [Win] Allow 'prepare-ChangeLog' to be used without Cygwin

Modified: trunk/Tools/Scripts/configure-xcode-for-ios-development (190332 => 190333)


--- trunk/Tools/Scripts/configure-xcode-for-ios-development	2015-09-30 00:16:31 UTC (rev 190332)
+++ trunk/Tools/Scripts/configure-xcode-for-ios-development	2015-09-30 00:21:39 UTC (rev 190333)
@@ -23,13 +23,14 @@
 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 # Checks if Xcode supports building a command line tool for the iOS Simulator.
-# If not, then creates xcspec files in the iOS Simulator SDK for a command line
+# If not, then updates/creates xcspec files in the iOS SDK for a command line
 # tool product- and package- type using the definitions in the OS X SDK for the
 # same types.
 
 use strict;
 use warnings;
 
+use Cwd qw(realpath);
 use English;
 use File::Basename;
 use File::Find;
@@ -40,16 +41,19 @@
 use webkitdirs;
 
 sub copyMissingHeadersToIPhoneOSSDKIfNeeded();
-sub createXcodeSpecificationFilesForSDKIfNeeded($);
-sub createXcodeSpecificationFromSpecificationAndId($$$);
+sub createLegacyXcodeSpecificationFilesForSDKIfNeeded($);
+sub mergeXcodeSpecificationWithSpecificationAndId($$$);
+sub readXcodeSpecificationById($$);
 sub sdkDirectory($);
 sub sdkPlatformDirectory($);
-sub readXcodeSpecificationById($$);
+sub updateXcode7SpecificationFile($);
+sub updateXcodeSpecificationFilesForSDKIfNeeded($);
 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 " };
+use constant SDK_TO_PLUGIN_XCSPEC_NAME_MAP => +{ "iphoneos" => "Embedded-Device.xcspec", "iphonesimulator" => "Embedded-Simulator.xcspec" };
 
 # 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>.
@@ -59,7 +63,7 @@
 }
 
 for my $sdk (qw(iphoneos iphonesimulator)) {
-    createXcodeSpecificationFilesForSDKIfNeeded($sdk);
+    updateXcodeSpecificationFilesForSDKIfNeeded($sdk);
 }
 
 copyMissingHeadersToIPhoneOSSDKIfNeeded();
@@ -96,8 +100,42 @@
     }
 }
 
-sub createXcodeSpecificationFilesForSDKIfNeeded($)
+sub updateXcodeSpecificationFilesForSDKIfNeeded($)
 {
+    my ($sdkName) = @_;
+    my $xcode7SpecificationFile = realpath(File::Spec->catfile(sdkPlatformDirectory($sdkName), "..", "..", "..", "PlugIns", "IDEiOSSupportCore.ideplugin", "Contents", "Resources", SDK_TO_PLUGIN_XCSPEC_NAME_MAP->{$sdkName}));
+    if (-f $xcode7SpecificationFile) {
+        updateXcode7SpecificationFile($xcode7SpecificationFile);
+    } else {
+        createLegacyXcodeSpecificationFilesForSDKIfNeeded($sdkName);
+    }
+}
+
+sub updateXcode7SpecificationFile($)
+{
+    my ($specificationFile) = @_;
+
+    my $hasPackageTypeForCommandLineTool = !!readXcodeSpecificationById($specificationFile, COMMAND_LINE_PACKAGE_TYPE);
+    my $hasProductTypeForCommandLineTool = !!readXcodeSpecificationById($specificationFile, COMMAND_LINE_PRODUCT_TYPE);
+    if ($hasPackageTypeForCommandLineTool && $hasProductTypeForCommandLineTool) {
+        return; # Xcode knows how to build a command line tool for $sdkName.
+    }
+
+    my $macosxSDKSpecificationsPath = xcodeSDKSpecificationsPath("macosx");
+    if (!$hasPackageTypeForCommandLineTool) {
+        my $packageTypesForMacOSXPath = File::Spec->catfile($macosxSDKSpecificationsPath, "MacOSX Package Types.xcspec");
+        mergeXcodeSpecificationWithSpecificationAndId($specificationFile, $packageTypesForMacOSXPath, COMMAND_LINE_PACKAGE_TYPE);
+    }
+
+    if (!$hasProductTypeForCommandLineTool) {
+        my $productTypesForMacOSXPath = File::Spec->catfile($macosxSDKSpecificationsPath, "MacOSX Product Types.xcspec");
+        mergeXcodeSpecificationWithSpecificationAndId($specificationFile, $productTypesForMacOSXPath, COMMAND_LINE_PRODUCT_TYPE);
+    }
+    print "Successfully updated '$specificationFile'.\n";
+}
+
+sub createLegacyXcodeSpecificationFilesForSDKIfNeeded($)
+{
     my ($sdk) = @_;
     my $sdkSpecificationsPath = xcodeSDKSpecificationsPath($sdk);
 
@@ -145,13 +183,15 @@
     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);
+        mergeXcodeSpecificationWithSpecificationAndId($packageTypesForWebKitDevelopmentPath, $packageTypesForMacOSXPath, COMMAND_LINE_PACKAGE_TYPE);
+        print "Successfully created '$packageTypesForWebKitDevelopmentPath'.\n";
     }
 
     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);
+        mergeXcodeSpecificationWithSpecificationAndId($productTypesForWebKitDevelopmentPath, $productTypesForMacOSXPath, COMMAND_LINE_PRODUCT_TYPE);
+        print "Successfully created '$productTypesForWebKitDevelopmentPath'.\n";
     }
 }
 
@@ -177,7 +217,9 @@
     my ($tempFileHandle, $tempFilename) = tempfile("webkit-xcspecXXXXXXX", UNLINK => 1);
     print $tempFileHandle $specification;
     close($tempFileHandle);
-    system("/usr/libexec/PlistBuddy -x -c 'clear array' '$xcodeSpecificationFile' > /dev/null") == 0 or die "PlistBuddy exited with $?: $!";
+    if (!-f $xcodeSpecificationFile) {
+        system("/usr/libexec/PlistBuddy -x -c 'clear array' '$xcodeSpecificationFile' > /dev/null") == 0 or die "PlistBuddy exited with $?: $!";
+    }
     system("/usr/libexec/PlistBuddy -x -c 'add 0 dict' '$xcodeSpecificationFile' > /dev/null") == 0 or die "PlistBuddy exited with $?: $!";
     system("/usr/libexec/PlistBuddy -x -c 'merge $tempFilename 0' '$xcodeSpecificationFile' > /dev/null") == 0 or die "PlistBuddy exited with $?: $!";
 }
@@ -233,7 +275,7 @@
     return File::Spec->catdir(sdkPlatformDirectory($sdkName), "Developer", "Library", "Xcode", "Specifications");
 }
 
-sub createXcodeSpecificationFromSpecificationAndId($$$)
+sub mergeXcodeSpecificationWithSpecificationAndId($$$)
 {
     my ($targetXcodeSpecificationFile, $sourceXcodeSpecificationFile, $id) = @_;
     my $specification = readXcodeSpecificationById($sourceXcodeSpecificationFile, $id);
@@ -241,5 +283,4 @@
         die "Failed to find '$id' in '$sourceXcodeSpecificationFile'.\n";
     }
     writeXcodeSpecification($targetXcodeSpecificationFile, $specification);
-    print "Successfully created '$targetXcodeSpecificationFile'.\n";
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to