[Cmake-commits] CMake branch, master, updated. v3.11.1-626-g5858267

Kitware Robot kwrobot at kitware.com
Thu Apr 26 08:45:03 EDT 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, master has been updated
       via  5858267df6a1538ae0af8d503cd7f20b69c3f503 (commit)
       via  dfff12c808e969b18a8fc642786a77f9fd4feb3e (commit)
       via  1f29777798895d1e190b56ab439b429770c2daec (commit)
      from  caf6d93acd499aaa200f0b1338c334048f7f35f7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5858267df6a1538ae0af8d503cd7f20b69c3f503
commit 5858267df6a1538ae0af8d503cd7f20b69c3f503
Merge: caf6d93 dfff12c
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Apr 26 12:36:40 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Thu Apr 26 08:36:44 2018 -0400

    Merge topic 'vs-refactor-xml'
    
    dfff12c808 VS: Add Elem::Content() helper and usage demo
    1f29777798 cmVisualStudio10TargetGenerator: refactoring (continued)
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2005


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dfff12c808e969b18a8fc642786a77f9fd4feb3e
commit dfff12c808e969b18a8fc642786a77f9fd4feb3e
Author:     Vitaly Stakhovsky <vvs31415 at gitlab.org>
AuthorDate: Tue Apr 24 18:46:56 2018 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Apr 26 08:35:43 2018 -0400

    VS: Add Elem::Content() helper and usage demo

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index b6ba814..d3f5f22 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -71,10 +71,11 @@ struct cmVisualStudio10TargetGenerator::Elem
     }
   }
   std::ostream& WriteString(const char* line);
-  void StartElement(const char* tag)
+  Elem& StartElement(const char* tag)
   {
     this->Tag = tag;
     this->WriteString("<") << tag;
+    return *this;
   }
   template <typename T>
   void WriteElem(const char* tag, const T& val)
@@ -95,6 +96,13 @@ struct cmVisualStudio10TargetGenerator::Elem
     Attr(an, cmVS10EscapeAttr(av));
     return *this;
   }
+  // This method for now assumes that this->Tag has been set, e.g. by calling
+  // StartElement(). Also, it finishes the element so it should be the last
+  // one called
+  void Content(const std::string& val)
+  {
+    S << ">" << cmVS10EscapeXML(val) << "</" << this->Tag << ">\n";
+  }
   void WriteEndTag(const char* tag)
   {
     if (HasElements) {
@@ -1311,7 +1319,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
       this->WriteCustomRuleCSharp(c, name, script, inputs.str(), outputs.str(),
                                   comment);
     } else {
-      this->WriteCustomRuleCpp(c, script, inputs.str(), outputs.str(),
+      this->WriteCustomRuleCpp(e2, c, script, inputs.str(), outputs.str(),
                                comment);
     }
   }
@@ -1321,26 +1329,21 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
 }
 
 void cmVisualStudio10TargetGenerator::WriteCustomRuleCpp(
-  std::string const& config, std::string const& script,
+  Elem& e2, std::string const& config, std::string const& script,
   std::string const& inputs, std::string const& outputs,
   std::string const& comment)
 {
-  this->WritePlatformConfigTag("Message", config, 3);
-  (*this->BuildFileStream) << cmVS10EscapeXML(comment) << "</Message>\n";
-  this->WritePlatformConfigTag("Command", config, 3);
-  (*this->BuildFileStream) << cmVS10EscapeXML(script) << "</Command>\n";
-  this->WritePlatformConfigTag("AdditionalInputs", config, 3);
-  (*this->BuildFileStream) << cmVS10EscapeXML(inputs);
-  (*this->BuildFileStream) << ";%(AdditionalInputs)"
-                              "</AdditionalInputs>\n";
-  this->WritePlatformConfigTag("Outputs", config, 3);
-  (*this->BuildFileStream) << cmVS10EscapeXML(outputs) << "</Outputs>\n";
+  const std::string cond = this->CalcCondition(config);
+  Elem(e2, "Message").Attribute("Condition", cond).Content(comment);
+  Elem(e2, "Command").Attribute("Condition", cond).Content(script);
+  Elem(e2, "AdditionalInputs")
+    .Attribute("Condition", cond)
+    .Content(inputs + ";%(AdditionalInputs)");
+  Elem(e2, "Outputs").Attribute("Condition", cond).Content(outputs);
   if (this->LocalGenerator->GetVersion() >
       cmGlobalVisualStudioGenerator::VS10) {
     // VS >= 11 let us turn off linking of custom command outputs.
-    this->WritePlatformConfigTag("LinkObjects", config, 3);
-    (*this->BuildFileStream) << "false"
-                                "</LinkObjects>\n";
+    Elem(e2, "LinkObjects").Attribute("Condition", cond).Content("false");
   }
 }
 
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 02939ac..7fce66a 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -132,8 +132,8 @@ private:
   void OutputLinkIncremental(std::string const& configName);
   void WriteCustomRule(cmSourceFile const* source,
                        cmCustomCommand const& command);
-  void WriteCustomRuleCpp(std::string const& config, std::string const& script,
-                          std::string const& inputs,
+  void WriteCustomRuleCpp(Elem& e2, std::string const& config,
+                          std::string const& script, std::string const& inputs,
                           std::string const& outputs,
                           std::string const& comment);
   void WriteCustomRuleCSharp(std::string const& config,

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1f29777798895d1e190b56ab439b429770c2daec
commit 1f29777798895d1e190b56ab439b429770c2daec
Author:     Vitaly Stakhovsky <vvs31415 at gitlab.org>
AuthorDate: Tue Apr 24 12:01:19 2018 -0400
Commit:     Vitaly Stakhovsky <vvs31415 at gitlab.org>
CommitDate: Tue Apr 24 12:01:19 2018 -0400

    cmVisualStudio10TargetGenerator: refactoring (continued)

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index b56104e..b6ba814 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -28,14 +28,23 @@ static std::string cmVS10EscapeXML(std::string arg)
   return arg;
 }
 
+static std::string cmVS10EscapeAttr(std::string arg)
+{
+  cmSystemTools::ReplaceString(arg, "&", "&");
+  cmSystemTools::ReplaceString(arg, "<", "<");
+  cmSystemTools::ReplaceString(arg, ">", ">");
+  cmSystemTools::ReplaceString(arg, "\"", """);
+  return arg;
+}
+
 struct cmVisualStudio10TargetGenerator::Elem
 {
-  cmGeneratedFileStream& S;
+  std::ostream& S;
   int Indent;
   bool HasElements = false;
   const char* Tag = nullptr;
 
-  Elem(cmGeneratedFileStream& s, int i)
+  Elem(std::ostream& s, int i)
     : S(s)
     , Indent(i)
   {
@@ -61,7 +70,7 @@ struct cmVisualStudio10TargetGenerator::Elem
       HasElements = true;
     }
   }
-  cmGeneratedFileStream& WriteString(const char* line);
+  std::ostream& WriteString(const char* line);
   void StartElement(const char* tag)
   {
     this->Tag = tag;
@@ -72,11 +81,20 @@ struct cmVisualStudio10TargetGenerator::Elem
   {
     this->WriteString("<") << tag << ">" << val << "</" << tag << ">\n";
   }
+  void Element(const char* tag, const std::string& val)
+  {
+    Elem(*this).WriteElem(tag, cmVS10EscapeXML(val));
+  }
   template <typename T>
   void Attr(const char* an, const T& av)
   {
     this->S << " " << an << "=\"" << av << "\"";
   }
+  Elem& Attribute(const char* an, const std::string& av)
+  {
+    Attr(an, cmVS10EscapeAttr(av));
+    return *this;
+  }
   void WriteEndTag(const char* tag)
   {
     if (HasElements) {
@@ -139,15 +157,6 @@ inline void cmVisualStudio10TargetGenerator::WriteElemEscapeXML(
   this->WriteElem(tag, cmVS10EscapeXML(val), indentLevel);
 }
 
-static std::string cmVS10EscapeAttr(std::string arg)
-{
-  cmSystemTools::ReplaceString(arg, "&", "&");
-  cmSystemTools::ReplaceString(arg, "<", "<");
-  cmSystemTools::ReplaceString(arg, ">", ">");
-  cmSystemTools::ReplaceString(arg, "\"", """);
-  return arg;
-}
-
 static std::string cmVS10EscapeComment(std::string comment)
 {
   // MSBuild takes the CDATA of a <Message></Message> element and just
@@ -238,38 +247,46 @@ cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator()
   delete this->BuildFileStream;
 }
 
+std::string cmVisualStudio10TargetGenerator::CalcCondition(
+  const std::string& config) const
+{
+  std::ostringstream oss;
+  oss << "'$(Configuration)|$(Platform)'=='";
+  oss << config << "|" << this->Platform;
+  oss << "'";
+  // handle special case for 32 bit C# targets
+  if (this->ProjectType == csproj && this->Platform == "Win32") {
+    oss << " Or ";
+    oss << "'$(Configuration)|$(Platform)'=='";
+    oss << config << "|x86";
+    oss << "'";
+  }
+  return oss.str();
+}
+
 void cmVisualStudio10TargetGenerator::WritePlatformConfigTag(
   const char* tag, const std::string& config, int indentLevel,
   const char* attribute)
 
 {
-  std::ostream* stream = this->BuildFileStream;
-  stream->fill(' ');
-  stream->width(indentLevel * 2);
-  (*stream) << ""; // applies indentation
-  (*stream) << "<" << tag << " Condition=\"";
-  (*stream) << "'$(Configuration)|$(Platform)'=='";
-  (*stream) << config << "|" << this->Platform;
-  (*stream) << "'";
-  // handle special case for 32 bit C# targets
-  if (this->ProjectType == csproj && this->Platform == "Win32") {
-    (*stream) << " Or ";
-    (*stream) << "'$(Configuration)|$(Platform)'=='";
-    (*stream) << config << "|x86";
-    (*stream) << "'";
-  }
-  (*stream) << "\"";
+  std::ostream& stream = *this->BuildFileStream;
+  stream.fill(' ');
+  stream.width(indentLevel * 2);
+  stream << ""; // applies indentation
+  stream << "<" << tag << " Condition=\"";
+  stream << this->CalcCondition(config);
+  stream << "\"";
   if (attribute) {
-    (*stream) << attribute;
+    stream << attribute;
   }
   // close the tag
-  (*stream) << ">";
+  stream << ">";
   if (attribute) {
-    (*stream) << "\n";
+    stream << "\n";
   }
 }
 
-cmGeneratedFileStream& cmVisualStudio10TargetGenerator::Elem::WriteString(
+std::ostream& cmVisualStudio10TargetGenerator::Elem::WriteString(
   const char* line)
 {
   this->S.fill(' ');
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 3c53d1b..02939ac 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -33,6 +33,7 @@ public:
   ~cmVisualStudio10TargetGenerator();
   void Generate();
   // used by cmVisualStudioGeneratorOptions
+  std::string CalcCondition(const std::string& config) const;
   void WritePlatformConfigTag(const char* tag, const std::string& config,
                               int indentLevel, const char* attribute = 0);
 

-----------------------------------------------------------------------

Summary of changes:
 Source/cmVisualStudio10TargetGenerator.cxx |  116 ++++++++++++++++------------
 Source/cmVisualStudio10TargetGenerator.h   |    5 +-
 2 files changed, 71 insertions(+), 50 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list