diff options
author | Brad King <brad.king@kitware.com> | 2010-10-05 19:31:03 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2010-10-05 19:31:03 (GMT) |
commit | 51047564bfefc793677c2de2bfc53d018fc28096 (patch) | |
tree | 3309e293d486291c111328052c7b1faac8566018 /Source/cmVisualStudio10TargetGenerator.cxx | |
parent | cb314e250b7dc275847815952250dbf764778cf7 (diff) | |
parent | 2596e16c8f241b52add4d54108fd5df4269cb2fc (diff) | |
download | CMake-51047564bfefc793677c2de2bfc53d018fc28096.zip CMake-51047564bfefc793677c2de2bfc53d018fc28096.tar.gz CMake-51047564bfefc793677c2de2bfc53d018fc28096.tar.bz2 |
Merge topic 'vs10-custom-comments'
2596e16 VS10: Encode custom command comments for echo (#11283)
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index a92e56f..9c0364b 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -32,6 +32,30 @@ static std::string cmVS10EscapeXML(std::string arg) return arg; } +static std::string cmVS10EscapeComment(std::string comment) +{ + // MSBuild takes the CDATA of a <Message></Message> element and just + // does "echo $CDATA" with no escapes. We must encode the string. + // http://technet.microsoft.com/en-us/library/cc772462%28WS.10%29.aspx + std::string echoable; + for(std::string::iterator c = comment.begin(); c != comment.end(); ++c) + { + switch (*c) + { + case '\r': break; + case '\n': echoable += '\t'; break; + case '"': /* no break */ + case '|': /* no break */ + case '&': /* no break */ + case '<': /* no break */ + case '>': /* no break */ + case '^': echoable += '^'; /* no break */ + default: echoable += *c; break; + } + } + return echoable; +} + cmVisualStudio10TargetGenerator:: cmVisualStudio10TargetGenerator(cmTarget* target, cmGlobalVisualStudio10Generator* gg) @@ -328,6 +352,7 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, } cmLocalVisualStudio7Generator* lg = this->LocalGenerator; std::string comment = lg->ConstructComment(command); + comment = cmVS10EscapeComment(comment); std::vector<std::string> *configs = static_cast<cmGlobalVisualStudio7Generator *> (this->GlobalGenerator)->GetConfigurations(); @@ -350,7 +375,7 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, command.GetEscapeAllowMakeVars()) ); this->WritePlatformConfigTag("Message",i->c_str(), 3); - (*this->BuildFileStream ) << comment << "</Message>\n"; + (*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "</Message>\n"; this->WritePlatformConfigTag("Command", i->c_str(), 3); (*this->BuildFileStream ) << script << "</Command>\n"; this->WritePlatformConfigTag("AdditionalInputs", i->c_str(), 3); @@ -1441,8 +1466,9 @@ void cmVisualStudio10TargetGenerator::WriteEvent( command.GetEscapeAllowMakeVars()) ); } + comment = cmVS10EscapeComment(comment); this->WriteString("<Message>",3); - (*this->BuildFileStream ) << comment << "</Message>\n"; + (*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "</Message>\n"; this->WriteString("<Command>", 3); (*this->BuildFileStream ) << script; (*this->BuildFileStream ) << "</Command>" << "\n"; |