Просмотр исходного кода

Xcode: Generate BuildableProductRunnable for ProfileAction

Similarly to the LaunchAction we need to associate a runnable
executable with the launch action.
Tor Arne Vestbø 1 год назад
Родитель
Сommit
021492038e

+ 22 - 10
Source/cmXCodeScheme.cxx

@@ -77,7 +77,7 @@ void cmXCodeScheme::WriteXCodeXCScheme(std::ostream& fout,
   WriteBuildAction(xout, container);
   WriteTestAction(xout, FindConfiguration("Debug"), container);
   WriteLaunchAction(xout, FindConfiguration(launchConfiguration), container);
-  WriteProfileAction(xout, FindConfiguration("Release"));
+  WriteProfileAction(xout, FindConfiguration("Release"), container);
   WriteAnalyzeAction(xout, FindConfiguration("Debug"));
   WriteArchiveAction(xout, FindConfiguration("Release"));
 
@@ -240,18 +240,13 @@ void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout,
   // Diagnostics tab end
 
   if (IsExecutable(this->Target)) {
-    xout.StartElement("BuildableProductRunnable");
-    xout.BreakAttributes();
-    xout.Attribute("runnableDebuggingMode", "0");
-
+    WriteBuildableProductRunnable(xout, this->Target, container);
   } else {
     xout.StartElement("MacroExpansion");
+    WriteBuildableReference(xout, this->Target, container);
+    xout.EndElement();
   }
 
-  WriteBuildableReference(xout, this->Target, container);
-
-  xout.EndElement(); // MacroExpansion
-
   // Info tab begin
 
   if (cmValue exe =
@@ -404,7 +399,8 @@ bool cmXCodeScheme::WriteLaunchActionAdditionalOption(
 }
 
 void cmXCodeScheme::WriteProfileAction(cmXMLWriter& xout,
-                                       const std::string& configuration)
+                                       const std::string& configuration,
+                                       const std::string& container)
 {
   xout.StartElement("ProfileAction");
   xout.BreakAttributes();
@@ -415,6 +411,11 @@ void cmXCodeScheme::WriteProfileAction(cmXMLWriter& xout,
   WriteLaunchActionBooleanAttribute(xout, "debugDocumentVersioning",
                                     "XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING",
                                     true);
+
+  if (IsExecutable(this->Target)) {
+    WriteBuildableProductRunnable(xout, this->Target, container);
+  }
+
   xout.EndElement();
 }
 
@@ -437,6 +438,17 @@ void cmXCodeScheme::WriteArchiveAction(cmXMLWriter& xout,
   xout.EndElement();
 }
 
+void cmXCodeScheme::WriteBuildableProductRunnable(cmXMLWriter& xout,
+                                                  const cmXCodeObject* xcObj,
+                                                  const std::string& container)
+{
+  xout.StartElement("BuildableProductRunnable");
+  xout.BreakAttributes();
+  xout.Attribute("runnableDebuggingMode", "0");
+  WriteBuildableReference(xout, xcObj, container);
+  xout.EndElement();
+}
+
 void cmXCodeScheme::WriteBuildableReference(cmXMLWriter& xout,
                                             const cmXCodeObject* xcObj,
                                             const std::string& container)

+ 5 - 1
Source/cmXCodeScheme.h

@@ -57,10 +57,14 @@ private:
                                          const std::string& value,
                                          const std::string& varName);
 
-  void WriteProfileAction(cmXMLWriter& xout, const std::string& configuration);
+  void WriteProfileAction(cmXMLWriter& xout, const std::string& configuration,
+                          const std::string& container);
   void WriteAnalyzeAction(cmXMLWriter& xout, const std::string& configuration);
   void WriteArchiveAction(cmXMLWriter& xout, const std::string& configuration);
 
+  void WriteBuildableProductRunnable(cmXMLWriter& xout,
+                                     const cmXCodeObject* xcObj,
+                                     const std::string& container);
   void WriteBuildableReference(cmXMLWriter& xout, const cmXCodeObject* xcObj,
                                const std::string& container);
 

+ 19 - 0
Tests/RunCMake/XcodeProject/XcodeSchemaGeneration-check.cmake

@@ -0,0 +1,19 @@
+
+set(schema "${RunCMake_TEST_BINARY_DIR}/XcodeSchemaGeneration.xcodeproj/xcshareddata/xcschemes/foo.xcscheme")
+
+if(NOT EXISTS "${schema}")
+  set(RunCMake_TEST_FAILED "Generated schema ${schema} does not exist.")
+  return()
+endif()
+
+execute_process(COMMAND
+  /usr/bin/xmllint --xpath "//Scheme/ProfileAction/BuildableProductRunnable" ${schema}
+  OUTPUT_VARIABLE stdout
+  ERROR_VARIABLE stderr
+  RESULT_VARIABLE exit_code
+  ERROR_STRIP_TRAILING_WHITESPACE
+)
+if(exit_code)
+  set(RunCMake_TEST_FAILED "Failed to find BuildableProductRunnable for profile action: ${stderr}")
+  return()
+endif()