diff options
author | Brad King <brad.king@kitware.com> | 2018-05-25 13:25:12 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-05-25 13:25:17 (GMT) |
commit | 9b5161e24fd5f5bebf2fabc3170232f778501141 (patch) | |
tree | adbfd950da9a42fb7744bf18e434d01dabe5e6ba | |
parent | cf723c493ef38c58c80b8067ac4a1968bacf810d (diff) | |
parent | 45c4a75d271f25af1ff4083b02793b79e8e11eee (diff) | |
download | CMake-9b5161e24fd5f5bebf2fabc3170232f778501141.zip CMake-9b5161e24fd5f5bebf2fabc3170232f778501141.tar.gz CMake-9b5161e24fd5f5bebf2fabc3170232f778501141.tar.bz2 |
Merge topic 'vs-scope'
45c4a75d27 cmVisualStudio10TargetGenerator: make sure each Elem has right scope
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2096
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 99b8998..fa6c8ad 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -96,6 +96,11 @@ struct cmVisualStudio10TargetGenerator::Elem } void EndElement() { + // Do not emit element which has not been started + if (Tag.empty()) { + return; + } + if (HasElements) { this->WriteString("</") << this->Tag << ">"; if (this->Indent > 0) { @@ -1280,12 +1285,16 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( } cmLocalVisualStudio7Generator* lg = this->LocalGenerator; - Elem e1(e0, "ItemGroup"); - Elem e2(e1); + std::unique_ptr<Elem> spe1; + std::unique_ptr<Elem> spe2; if (this->ProjectType != csproj) { - this->WriteSource(e2, "CustomBuild", source); - e2.SetHasElements(); + spe1 = cm::make_unique<Elem>(e0, "ItemGroup"); + spe2 = cm::make_unique<Elem>(*spe1); + this->WriteSource(*spe2, "CustomBuild", source); + spe2->SetHasElements(); } else { + Elem e1(e0, "ItemGroup"); + Elem e2(e1); std::string link; this->GetCSharpSourceLink(source, link); this->WriteSource(e2, "None", source); @@ -1326,13 +1335,13 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( this->WriteCustomRuleCSharp(e0, c, name, script, inputs.str(), outputs.str(), comment); } else { - this->WriteCustomRuleCpp(e2, c, script, inputs.str(), outputs.str(), + this->WriteCustomRuleCpp(*spe2, c, script, inputs.str(), outputs.str(), comment); } } if (this->ProjectType != csproj) { - e2.EndElement(); - e1.EndElement(); + spe2->EndElement(); + spe1->EndElement(); } } @@ -3887,7 +3896,6 @@ void cmVisualStudio10TargetGenerator::WriteSDKReferences(Elem& e0) iotExtensionsVersion) { if (!hasWrittenItemGroup) { e1.StartElement("ItemGroup"); - hasWrittenItemGroup = true; } if (desktopExtensionsVersion) { this->WriteSingleSDKReference(e1, "WindowsDesktop", @@ -3903,9 +3911,7 @@ void cmVisualStudio10TargetGenerator::WriteSDKReferences(Elem& e0) } } - if (hasWrittenItemGroup) { - e1.EndElement(); - } + e1.EndElement(); } void cmVisualStudio10TargetGenerator::WriteSingleSDKReference( @@ -4207,10 +4213,12 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80(Elem& e1) std::string sourceFile = this->ConvertPath(manifestFile, false); ConvertToWindowsSlash(sourceFile); - Elem e2(e1, "Xml"); - e2.Attribute("Include", sourceFile); - e2.Element("SubType", "Designer"); - e2.EndElement(); + { + Elem e2(e1, "Xml"); + e2.Attribute("Include", sourceFile); + e2.Element("SubType", "Designer"); + e2.EndElement(); + } this->AddedFiles.push_back(sourceFile); std::string smallLogo = this->DefaultArtifactDir + "/SmallLogo.png"; @@ -4482,10 +4490,12 @@ void cmVisualStudio10TargetGenerator::WriteCommonMissingFiles( std::string sourceFile = this->ConvertPath(manifestFile, false); ConvertToWindowsSlash(sourceFile); - Elem e2(e1, "AppxManifest"); - e2.Attribute("Include", sourceFile); - e2.Element("SubType", "Designer"); - e2.EndElement(); + { + Elem e2(e1, "AppxManifest"); + e2.Attribute("Include", sourceFile); + e2.Element("SubType", "Designer"); + e2.EndElement(); + } this->AddedFiles.push_back(sourceFile); std::string smallLogo = this->DefaultArtifactDir + "/SmallLogo.png"; |