<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[190333] trunk/Tools</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/190333">190333</a></dd>
<dt>Author</dt> <dd>dbates@webkit.org</dd>
<dt>Date</dt> <dd>2015-09-29 17:21:39 -0700 (Tue, 29 Sep 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptsconfigurexcodeforiosdevelopment">trunk/Tools/Scripts/configure-xcode-for-ios-development</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (190332 => 190333)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-09-30 00:16:31 UTC (rev 190332)
+++ trunk/Tools/ChangeLog        2015-09-30 00:21:39 UTC (rev 190333)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2015-09-29  Daniel Bates  &lt;dabates@apple.com&gt;
+
+        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.
+
</ins><span class="cx"> 2015-09-29  Brent Fulgham  &lt;bfulgham@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Win] Allow 'prepare-ChangeLog' to be used without Cygwin
</span></span></pre></div>
<a id="trunkToolsScriptsconfigurexcodeforiosdevelopment"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/configure-xcode-for-ios-development (190332 => 190333)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -23,13 +23,14 @@
</span><span class="cx"> # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> 
</span><span class="cx"> # Checks if Xcode supports building a command line tool for the iOS Simulator.
</span><del>-# If not, then creates xcspec files in the iOS Simulator SDK for a command line
</del><ins>+# If not, then updates/creates xcspec files in the iOS SDK for a command line
</ins><span class="cx"> # tool product- and package- type using the definitions in the OS X SDK for the
</span><span class="cx"> # same types.
</span><span class="cx"> 
</span><span class="cx"> use strict;
</span><span class="cx"> use warnings;
</span><span class="cx"> 
</span><ins>+use Cwd qw(realpath);
</ins><span class="cx"> use English;
</span><span class="cx"> use File::Basename;
</span><span class="cx"> use File::Find;
</span><span class="lines">@@ -40,16 +41,19 @@
</span><span class="cx"> use webkitdirs;
</span><span class="cx"> 
</span><span class="cx"> sub copyMissingHeadersToIPhoneOSSDKIfNeeded();
</span><del>-sub createXcodeSpecificationFilesForSDKIfNeeded($);
-sub createXcodeSpecificationFromSpecificationAndId($$$);
</del><ins>+sub createLegacyXcodeSpecificationFilesForSDKIfNeeded($);
+sub mergeXcodeSpecificationWithSpecificationAndId($$$);
+sub readXcodeSpecificationById($$);
</ins><span class="cx"> sub sdkDirectory($);
</span><span class="cx"> sub sdkPlatformDirectory($);
</span><del>-sub readXcodeSpecificationById($$);
</del><ins>+sub updateXcode7SpecificationFile($);
+sub updateXcodeSpecificationFilesForSDKIfNeeded($);
</ins><span class="cx"> sub xcodeSDKSpecificationsPath($);
</span><span class="cx"> 
</span><span class="cx"> use constant COMMAND_LINE_PACKAGE_TYPE =&gt; &quot;com.apple.package-type.mach-o-executable&quot;;
</span><span class="cx"> use constant COMMAND_LINE_PRODUCT_TYPE =&gt; &quot;com.apple.product-type.tool&quot;;
</span><span class="cx"> use constant SDK_TO_XCSPEC_NAME_MAP =&gt; +{ &quot;iphoneos&quot; =&gt; &quot;iPhoneOS&quot;, &quot;iphonesimulator&quot; =&gt; &quot;iPhone Simulator &quot; };
</span><ins>+use constant SDK_TO_PLUGIN_XCSPEC_NAME_MAP =&gt; +{ &quot;iphoneos&quot; =&gt; &quot;Embedded-Device.xcspec&quot;, &quot;iphonesimulator&quot; =&gt; &quot;Embedded-Simulator.xcspec&quot; };
</ins><span class="cx"> 
</span><span class="cx"> # FIXME: We should only require running as root if needed. It's not necessary to run as root if
</span><span class="cx"> #        Xcode was installed by the user, say via a download from &lt;http://developer.apple.com&gt;.
</span><span class="lines">@@ -59,7 +63,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> for my $sdk (qw(iphoneos iphonesimulator)) {
</span><del>-    createXcodeSpecificationFilesForSDKIfNeeded($sdk);
</del><ins>+    updateXcodeSpecificationFilesForSDKIfNeeded($sdk);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> copyMissingHeadersToIPhoneOSSDKIfNeeded();
</span><span class="lines">@@ -96,8 +100,42 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-sub createXcodeSpecificationFilesForSDKIfNeeded($)
</del><ins>+sub updateXcodeSpecificationFilesForSDKIfNeeded($)
</ins><span class="cx"> {
</span><ins>+    my ($sdkName) = @_;
+    my $xcode7SpecificationFile = realpath(File::Spec-&gt;catfile(sdkPlatformDirectory($sdkName), &quot;..&quot;, &quot;..&quot;, &quot;..&quot;, &quot;PlugIns&quot;, &quot;IDEiOSSupportCore.ideplugin&quot;, &quot;Contents&quot;, &quot;Resources&quot;, SDK_TO_PLUGIN_XCSPEC_NAME_MAP-&gt;{$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 &amp;&amp; $hasProductTypeForCommandLineTool) {
+        return; # Xcode knows how to build a command line tool for $sdkName.
+    }
+
+    my $macosxSDKSpecificationsPath = xcodeSDKSpecificationsPath(&quot;macosx&quot;);
+    if (!$hasPackageTypeForCommandLineTool) {
+        my $packageTypesForMacOSXPath = File::Spec-&gt;catfile($macosxSDKSpecificationsPath, &quot;MacOSX Package Types.xcspec&quot;);
+        mergeXcodeSpecificationWithSpecificationAndId($specificationFile, $packageTypesForMacOSXPath, COMMAND_LINE_PACKAGE_TYPE);
+    }
+
+    if (!$hasProductTypeForCommandLineTool) {
+        my $productTypesForMacOSXPath = File::Spec-&gt;catfile($macosxSDKSpecificationsPath, &quot;MacOSX Product Types.xcspec&quot;);
+        mergeXcodeSpecificationWithSpecificationAndId($specificationFile, $productTypesForMacOSXPath, COMMAND_LINE_PRODUCT_TYPE);
+    }
+    print &quot;Successfully updated '$specificationFile'.\n&quot;;
+}
+
+sub createLegacyXcodeSpecificationFilesForSDKIfNeeded($)
+{
</ins><span class="cx">     my ($sdk) = @_;
</span><span class="cx">     my $sdkSpecificationsPath = xcodeSDKSpecificationsPath($sdk);
</span><span class="cx"> 
</span><span class="lines">@@ -145,13 +183,15 @@
</span><span class="cx">     if (!$hasPackageTypeForCommandLineTool) {
</span><span class="cx">         my $packageTypesForMacOSXPath = File::Spec-&gt;catfile($macosxSDKSpecificationsPath, &quot;MacOSX Package Types.xcspec&quot;);
</span><span class="cx">         my $packageTypesForWebKitDevelopmentPath = File::Spec-&gt;catfile($sdkSpecificationsPath, &quot;${fileNamePrefix}PackageTypes For WebKit Development.xcspec&quot;);
</span><del>-        createXcodeSpecificationFromSpecificationAndId($packageTypesForWebKitDevelopmentPath, $packageTypesForMacOSXPath, COMMAND_LINE_PACKAGE_TYPE);
</del><ins>+        mergeXcodeSpecificationWithSpecificationAndId($packageTypesForWebKitDevelopmentPath, $packageTypesForMacOSXPath, COMMAND_LINE_PACKAGE_TYPE);
+        print &quot;Successfully created '$packageTypesForWebKitDevelopmentPath'.\n&quot;;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (!$hasProductTypeForCommandLineTool) {
</span><span class="cx">         my $productTypesForMacOSXPath = File::Spec-&gt;catfile($macosxSDKSpecificationsPath, &quot;MacOSX Product Types.xcspec&quot;);
</span><span class="cx">         my $productTypesForWebKitDevelopmentPath = File::Spec-&gt;catfile($sdkSpecificationsPath, &quot;${fileNamePrefix}ProductTypes For WebKit Development.xcspec&quot;);
</span><del>-        createXcodeSpecificationFromSpecificationAndId($productTypesForWebKitDevelopmentPath, $productTypesForMacOSXPath, COMMAND_LINE_PRODUCT_TYPE);
</del><ins>+        mergeXcodeSpecificationWithSpecificationAndId($productTypesForWebKitDevelopmentPath, $productTypesForMacOSXPath, COMMAND_LINE_PRODUCT_TYPE);
+        print &quot;Successfully created '$productTypesForWebKitDevelopmentPath'.\n&quot;;
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -177,7 +217,9 @@
</span><span class="cx">     my ($tempFileHandle, $tempFilename) = tempfile(&quot;webkit-xcspecXXXXXXX&quot;, UNLINK =&gt; 1);
</span><span class="cx">     print $tempFileHandle $specification;
</span><span class="cx">     close($tempFileHandle);
</span><del>-    system(&quot;/usr/libexec/PlistBuddy -x -c 'clear array' '$xcodeSpecificationFile' &gt; /dev/null&quot;) == 0 or die &quot;PlistBuddy exited with $?: $!&quot;;
</del><ins>+    if (!-f $xcodeSpecificationFile) {
+        system(&quot;/usr/libexec/PlistBuddy -x -c 'clear array' '$xcodeSpecificationFile' &gt; /dev/null&quot;) == 0 or die &quot;PlistBuddy exited with $?: $!&quot;;
+    }
</ins><span class="cx">     system(&quot;/usr/libexec/PlistBuddy -x -c 'add 0 dict' '$xcodeSpecificationFile' &gt; /dev/null&quot;) == 0 or die &quot;PlistBuddy exited with $?: $!&quot;;
</span><span class="cx">     system(&quot;/usr/libexec/PlistBuddy -x -c 'merge $tempFilename 0' '$xcodeSpecificationFile' &gt; /dev/null&quot;) == 0 or die &quot;PlistBuddy exited with $?: $!&quot;;
</span><span class="cx"> }
</span><span class="lines">@@ -233,7 +275,7 @@
</span><span class="cx">     return File::Spec-&gt;catdir(sdkPlatformDirectory($sdkName), &quot;Developer&quot;, &quot;Library&quot;, &quot;Xcode&quot;, &quot;Specifications&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-sub createXcodeSpecificationFromSpecificationAndId($$$)
</del><ins>+sub mergeXcodeSpecificationWithSpecificationAndId($$$)
</ins><span class="cx"> {
</span><span class="cx">     my ($targetXcodeSpecificationFile, $sourceXcodeSpecificationFile, $id) = @_;
</span><span class="cx">     my $specification = readXcodeSpecificationById($sourceXcodeSpecificationFile, $id);
</span><span class="lines">@@ -241,5 +283,4 @@
</span><span class="cx">         die &quot;Failed to find '$id' in '$sourceXcodeSpecificationFile'.\n&quot;;
</span><span class="cx">     }
</span><span class="cx">     writeXcodeSpecification($targetXcodeSpecificationFile, $specification);
</span><del>-    print &quot;Successfully created '$targetXcodeSpecificationFile'.\n&quot;;
</del><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>