diff options
author | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2018-04-24 22:46:56 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-04-26 12:35:43 (GMT) |
commit | dfff12c808e969b18a8fc642786a77f9fd4feb3e (patch) | |
tree | cd5fba18ec96fa404319c7d78751736c479944af /Source/cmVisualStudio10TargetGenerator.cxx | |
parent | 1f29777798895d1e190b56ab439b429770c2daec (diff) | |
download | CMake-dfff12c808e969b18a8fc642786a77f9fd4feb3e.zip CMake-dfff12c808e969b18a8fc642786a77f9fd4feb3e.tar.gz CMake-dfff12c808e969b18a8fc642786a77f9fd4feb3e.tar.bz2 |
VS: Add Elem::Content() helper and usage demo
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 35 |
1 files changed, 19 insertions, 16 deletions
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"); } } |