From 6a54d28e44c3e539a0f6b45a5bdd748df5ef29ca Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Fri, 24 Feb 2017 13:04:21 +0100 Subject: Xcode: Use proper indentation for schemes --- Source/cmXCodeScheme.cxx | 1 + Source/cmXMLWriter.cxx | 11 ++++++++++- Source/cmXMLWriter.h | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx index 3c8c0b7..c2d49d8 100644 --- a/Source/cmXCodeScheme.cxx +++ b/Source/cmXCodeScheme.cxx @@ -47,6 +47,7 @@ void cmXCodeScheme::WriteXCodeXCScheme(std::ostream& fout, const std::string& xcProjDir) { cmXMLWriter xout(fout); + xout.SetIndentationElement(std::string(3, ' ')); xout.StartDocument(); xout.StartElement("Scheme"); diff --git a/Source/cmXMLWriter.cxx b/Source/cmXMLWriter.cxx index 2f50fe9..541cb3d 100644 --- a/Source/cmXMLWriter.cxx +++ b/Source/cmXMLWriter.cxx @@ -7,6 +7,7 @@ cmXMLWriter::cmXMLWriter(std::ostream& output, std::size_t level) : Output(output) + , IndentationElement(1, '\t') , Level(level) , ElementOpen(false) , BreakAttrib(false) @@ -100,10 +101,18 @@ void cmXMLWriter::FragmentFile(const char* fname) this->Output << fin.rdbuf(); } +void cmXMLWriter::SetIndentationElement(std::string const& element) +{ + this->IndentationElement = element; +} + void cmXMLWriter::ConditionalLineBreak(bool condition, std::size_t indent) { if (condition) { - this->Output << '\n' << std::string(indent + this->Level, '\t'); + this->Output << '\n'; + for (std::size_t i = 0; i < indent + this->Level; ++i) { + this->Output << this->IndentationElement; + } } } diff --git a/Source/cmXMLWriter.h b/Source/cmXMLWriter.h index 904f73b..6d1e6b4 100644 --- a/Source/cmXMLWriter.h +++ b/Source/cmXMLWriter.h @@ -60,6 +60,8 @@ public: void FragmentFile(const char* fname); + void SetIndentationElement(std::string const& element); + private: cmXMLWriter(const cmXMLWriter&); cmXMLWriter& operator=(const cmXMLWriter&); @@ -107,6 +109,7 @@ private: private: std::ostream& Output; std::stack > Elements; + std::string IndentationElement; std::size_t Level; bool ElementOpen; bool BreakAttrib; -- cgit v0.12 From 5995082101a1959f303f9f3d6c0a1e483630749e Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Fri, 24 Feb 2017 16:19:14 +0100 Subject: Xcode: Do not autocreate schemes --- Source/cmGlobalXCodeGenerator.cxx | 31 +++++++++++++++++++++++++++++++ Source/cmGlobalXCodeGenerator.h | 1 + 2 files changed, 32 insertions(+) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d1b6130..f0ebf88 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3345,6 +3345,7 @@ void cmGlobalXCodeGenerator::OutputXCodeProject( "XCODE_GENERATE_SCHEME") && this->XcodeVersion >= 70) { this->OutputXCodeSharedSchemes(xcodeDir, root); + this->OutputXCodeWorkspaceSettings(xcodeDir); } this->ClearXCodeObjects(); @@ -3373,6 +3374,36 @@ void cmGlobalXCodeGenerator::OutputXCodeSharedSchemes( } } +void cmGlobalXCodeGenerator::OutputXCodeWorkspaceSettings( + const std::string& xcProjDir) +{ + std::string xcodeSharedDataDir = xcProjDir; + xcodeSharedDataDir += "/project.xcworkspace/xcshareddata"; + cmSystemTools::MakeDirectory(xcodeSharedDataDir); + + std::string workspaceSettingsFile = xcodeSharedDataDir; + workspaceSettingsFile += "/WorkspaceSettings.xcsettings"; + + cmGeneratedFileStream fout(workspaceSettingsFile.c_str()); + fout.SetCopyIfDifferent(true); + if (!fout) { + return; + } + + cmXMLWriter xout(fout); + xout.StartDocument(); + xout.Doctype("plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\"" + "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\""); + xout.StartElement("plist"); + xout.Attribute("version", "1.0"); + xout.StartElement("dict"); + xout.Element("key", "IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded"); + xout.Element("false"); + xout.EndElement(); // dict + xout.EndElement(); // plist + xout.EndDocument(); +} + void cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout, cmLocalGenerator*, std::vector&) diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index c9157b0..dcbc77a 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -168,6 +168,7 @@ private: // Write shared scheme files for all the native targets void OutputXCodeSharedSchemes(const std::string& xcProjDir, cmLocalGenerator* root); + void OutputXCodeWorkspaceSettings(const std::string& xcProjDir); void WriteXCodePBXProj(std::ostream& fout, cmLocalGenerator* root, std::vector& generators); cmXCodeObject* CreateXCodeFileReferenceFromPath(const std::string& fullpath, -- cgit v0.12 From 7202db5db46bfe7499244af315249820e883c8cf Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Fri, 24 Feb 2017 17:31:24 +0100 Subject: Xcode: Fix schema container location calculation --- Source/cmGlobalXCodeGenerator.cxx | 6 +++--- Source/cmGlobalXCodeGenerator.h | 3 +-- Source/cmXCodeScheme.cxx | 20 ++++++++++---------- Source/cmXCodeScheme.h | 8 ++++---- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index f0ebf88..b023d5c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3344,7 +3344,7 @@ void cmGlobalXCodeGenerator::OutputXCodeProject( if (this->GetCMakeInstance()->GetState()->GetGlobalPropertyAsBool( "XCODE_GENERATE_SCHEME") && this->XcodeVersion >= 70) { - this->OutputXCodeSharedSchemes(xcodeDir, root); + this->OutputXCodeSharedSchemes(xcodeDir); this->OutputXCodeWorkspaceSettings(xcodeDir); } @@ -3357,7 +3357,7 @@ void cmGlobalXCodeGenerator::OutputXCodeProject( } void cmGlobalXCodeGenerator::OutputXCodeSharedSchemes( - const std::string& xcProjDir, cmLocalGenerator* root) + const std::string& xcProjDir) { for (std::vector::const_iterator i = this->XCodeObjects.begin(); @@ -3369,7 +3369,7 @@ void cmGlobalXCodeGenerator::OutputXCodeSharedSchemes( cmXCodeScheme schm(obj, this->CurrentConfigurationTypes, this->XcodeVersion); schm.WriteXCodeSharedScheme(xcProjDir, - root->GetCurrentSourceDirectory()); + this->RelativeToSource(xcProjDir.c_str())); } } } diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index dcbc77a..9eacdef 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -166,8 +166,7 @@ private: void OutputXCodeProject(cmLocalGenerator* root, std::vector& generators); // Write shared scheme files for all the native targets - void OutputXCodeSharedSchemes(const std::string& xcProjDir, - cmLocalGenerator* root); + void OutputXCodeSharedSchemes(const std::string& xcProjDir); void OutputXCodeWorkspaceSettings(const std::string& xcProjDir); void WriteXCodePBXProj(std::ostream& fout, cmLocalGenerator* root, std::vector& generators); diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx index c2d49d8..e5031fd 100644 --- a/Source/cmXCodeScheme.cxx +++ b/Source/cmXCodeScheme.cxx @@ -3,6 +3,7 @@ #include "cmXCodeScheme.h" #include +#include #include #include "cmGeneratedFileStream.h" @@ -20,7 +21,7 @@ cmXCodeScheme::cmXCodeScheme(cmXCodeObject* xcObj, } void cmXCodeScheme::WriteXCodeSharedScheme(const std::string& xcProjDir, - const std::string sourceRoot) + const std::string& container) { // Create shared scheme sub-directory tree // @@ -39,12 +40,11 @@ void cmXCodeScheme::WriteXCodeSharedScheme(const std::string& xcProjDir, return; } - std::string xcProjRelDir = xcProjDir.substr(sourceRoot.size() + 1); - WriteXCodeXCScheme(fout, xcProjRelDir); + WriteXCodeXCScheme(fout, container); } void cmXCodeScheme::WriteXCodeXCScheme(std::ostream& fout, - const std::string& xcProjDir) + const std::string& container) { cmXMLWriter xout(fout); xout.SetIndentationElement(std::string(3, ' ')); @@ -55,9 +55,9 @@ void cmXCodeScheme::WriteXCodeXCScheme(std::ostream& fout, xout.Attribute("LastUpgradeVersion", WriteVersionString()); xout.Attribute("version", "1.3"); - WriteBuildAction(xout, xcProjDir); + WriteBuildAction(xout, container); WriteTestAction(xout, FindConfiguration("Debug")); - WriteLaunchAction(xout, FindConfiguration("Debug"), xcProjDir); + WriteLaunchAction(xout, FindConfiguration("Debug"), container); WriteProfileAction(xout, FindConfiguration("Release")); WriteAnalyzeAction(xout, FindConfiguration("Debug")); WriteArchiveAction(xout, FindConfiguration("Release")); @@ -66,7 +66,7 @@ void cmXCodeScheme::WriteXCodeXCScheme(std::ostream& fout, } void cmXCodeScheme::WriteBuildAction(cmXMLWriter& xout, - const std::string& xcProjDir) + const std::string& container) { xout.StartElement("BuildAction"); xout.BreakAttributes(); @@ -88,7 +88,7 @@ void cmXCodeScheme::WriteBuildAction(cmXMLWriter& xout, xout.Attribute("BlueprintIdentifier", this->TargetId); xout.Attribute("BuildableName", this->TargetName); xout.Attribute("BlueprintName", this->TargetName); - xout.Attribute("ReferencedContainer", "container:" + xcProjDir); + xout.Attribute("ReferencedContainer", "container:" + container); xout.EndElement(); xout.EndElement(); // BuildActionEntry @@ -119,7 +119,7 @@ void cmXCodeScheme::WriteTestAction(cmXMLWriter& xout, void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout, std::string configuration, - const std::string& xcProjDir) + const std::string& container) { xout.StartElement("LaunchAction"); xout.BreakAttributes(); @@ -143,7 +143,7 @@ void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout, xout.Attribute("BlueprintIdentifier", this->TargetId); xout.Attribute("BuildableName", this->TargetName); xout.Attribute("BlueprintName", this->TargetName); - xout.Attribute("ReferencedContainer", "container:" + xcProjDir); + xout.Attribute("ReferencedContainer", "container:" + container); xout.EndElement(); xout.EndElement(); // MacroExpansion diff --git a/Source/cmXCodeScheme.h b/Source/cmXCodeScheme.h index b174c51..7a7d930 100644 --- a/Source/cmXCodeScheme.h +++ b/Source/cmXCodeScheme.h @@ -21,7 +21,7 @@ public: unsigned int xcVersion); void WriteXCodeSharedScheme(const std::string& xcProjDir, - const std::string sourceRoot); + const std::string& container); private: const std::string& TargetName; @@ -29,12 +29,12 @@ private: const std::vector& ConfigList; const unsigned int XcodeVersion; - void WriteXCodeXCScheme(std::ostream& fout, const std::string& xcProjDir); + void WriteXCodeXCScheme(std::ostream& fout, const std::string& container); - void WriteBuildAction(cmXMLWriter& xout, const std::string& xcProjDir); + void WriteBuildAction(cmXMLWriter& xout, const std::string& container); void WriteTestAction(cmXMLWriter& xout, std::string configuration); void WriteLaunchAction(cmXMLWriter& xout, std::string configuration, - const std::string& xcProjDir); + const std::string& container); void WriteProfileAction(cmXMLWriter& xout, std::string configuration); void WriteAnalyzeAction(cmXMLWriter& xout, std::string configuration); void WriteArchiveAction(cmXMLWriter& xout, std::string configuration); -- cgit v0.12 From f4977d056b2295679ce723c639f16823cfe489d5 Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Fri, 24 Feb 2017 18:47:58 +0100 Subject: Xcode: Select executable target for execution in schema --- Source/cmXCodeScheme.cxx | 23 +++++++++++++++++++++-- Source/cmXCodeScheme.h | 3 +++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx index e5031fd..1596e5c 100644 --- a/Source/cmXCodeScheme.cxx +++ b/Source/cmXCodeScheme.cxx @@ -13,7 +13,8 @@ cmXCodeScheme::cmXCodeScheme(cmXCodeObject* xcObj, const std::vector& configList, unsigned int xcVersion) - : TargetName(xcObj->GetTarget()->GetName()) + : Target(xcObj) + , TargetName(xcObj->GetTarget()->GetName()) , TargetId(xcObj->GetId()) , ConfigList(configList) , XcodeVersion(xcVersion) @@ -135,7 +136,14 @@ void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout, xout.Attribute("debugServiceExtension", "internal"); xout.Attribute("allowLocationSimulation", "YES"); - xout.StartElement("MacroExpansion"); + if (IsExecutable(this->Target)) { + xout.StartElement("BuildableProductRunnable"); + xout.BreakAttributes(); + xout.Attribute("runnableDebuggingMode", "0"); + + } else { + xout.StartElement("MacroExpansion"); + } xout.StartElement("BuildableReference"); xout.BreakAttributes(); @@ -205,3 +213,14 @@ std::string cmXCodeScheme::FindConfiguration(const std::string& name) return name; } + +bool cmXCodeScheme::IsExecutable(const cmXCodeObject* target) +{ + cmGeneratorTarget* gt = target->GetTarget(); + if (!gt) { + cmSystemTools::Error("Error no target on xobject\n"); + return false; + } + + return gt->GetType() == cmStateEnums::EXECUTABLE; +} diff --git a/Source/cmXCodeScheme.h b/Source/cmXCodeScheme.h index 7a7d930..470b5fd 100644 --- a/Source/cmXCodeScheme.h +++ b/Source/cmXCodeScheme.h @@ -24,6 +24,7 @@ public: const std::string& container); private: + const cmXCodeObject* const Target; const std::string& TargetName; const std::string& TargetId; const std::vector& ConfigList; @@ -41,6 +42,8 @@ private: std::string WriteVersionString(); std::string FindConfiguration(const std::string& name); + + static bool IsExecutable(const cmXCodeObject* target); }; #endif -- cgit v0.12 From 54a48c6781dd02f2ebbdb19a77c9a4fb59e67735 Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Sat, 25 Feb 2017 21:26:17 +0100 Subject: Xcode: Use proper buildable name for schema --- Source/cmXCodeScheme.cxx | 5 +++-- Source/cmXCodeScheme.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx index 1596e5c..5c22531 100644 --- a/Source/cmXCodeScheme.cxx +++ b/Source/cmXCodeScheme.cxx @@ -15,6 +15,7 @@ cmXCodeScheme::cmXCodeScheme(cmXCodeObject* xcObj, unsigned int xcVersion) : Target(xcObj) , TargetName(xcObj->GetTarget()->GetName()) + , BuildableName(xcObj->GetTarget()->GetFullName()) , TargetId(xcObj->GetId()) , ConfigList(configList) , XcodeVersion(xcVersion) @@ -87,7 +88,7 @@ void cmXCodeScheme::WriteBuildAction(cmXMLWriter& xout, xout.BreakAttributes(); xout.Attribute("BuildableIdentifier", "primary"); xout.Attribute("BlueprintIdentifier", this->TargetId); - xout.Attribute("BuildableName", this->TargetName); + xout.Attribute("BuildableName", this->BuildableName); xout.Attribute("BlueprintName", this->TargetName); xout.Attribute("ReferencedContainer", "container:" + container); xout.EndElement(); @@ -149,7 +150,7 @@ void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout, xout.BreakAttributes(); xout.Attribute("BuildableIdentifier", "primary"); xout.Attribute("BlueprintIdentifier", this->TargetId); - xout.Attribute("BuildableName", this->TargetName); + xout.Attribute("BuildableName", this->BuildableName); xout.Attribute("BlueprintName", this->TargetName); xout.Attribute("ReferencedContainer", "container:" + container); xout.EndElement(); diff --git a/Source/cmXCodeScheme.h b/Source/cmXCodeScheme.h index 470b5fd..0a8e737 100644 --- a/Source/cmXCodeScheme.h +++ b/Source/cmXCodeScheme.h @@ -26,6 +26,7 @@ public: private: const cmXCodeObject* const Target; const std::string& TargetName; + const std::string BuildableName; const std::string& TargetId; const std::vector& ConfigList; const unsigned int XcodeVersion; -- cgit v0.12