Commit 894a41fc authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'vs-simplify'

80767dd5

 VS: Simplify XML code
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !1895
parents 3272677e 80767dd5
Pipeline #96796 passed with stage
in 0 seconds
......@@ -792,10 +792,9 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
<< "\\$(ConfigurationName)\"\n";
}
targetOptions.OutputAdditionalIncludeDirectories(
fout, "\t\t\t\t", "\n",
this->FortranProject ? "Fortran" : langForClCompile);
fout, "\t\t\t\t", this->FortranProject ? "Fortran" : langForClCompile);
targetOptions.OutputFlagMap(fout, "\t\t\t\t");
targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n",
targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t",
langForClCompile);
fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n";
if (target->GetType() <= cmStateEnums::OBJECT_LIBRARY) {
......@@ -815,11 +814,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
"\t\t\t\tName=\"MASM\"\n"
;
/* clang-format on */
targetOptions.OutputAdditionalIncludeDirectories(fout, "\t\t\t\t", "\n",
targetOptions.OutputAdditionalIncludeDirectories(fout, "\t\t\t\t",
"ASM_MASM");
// Use same preprocessor definitions as VCCLCompilerTool.
targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n",
"ASM_MASM");
targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "ASM_MASM");
masmOptions.OutputFlagMap(fout, "\t\t\t\t");
/* clang-format off */
fout <<
......@@ -837,18 +835,16 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
tool = "VFResourceCompilerTool";
}
fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n";
targetOptions.OutputAdditionalIncludeDirectories(fout, "\n\t\t\t\t", "",
"RC");
targetOptions.OutputAdditionalIncludeDirectories(fout, "\t\t\t\t", "RC");
// add the -D flags to the RC tool
targetOptions.OutputPreprocessorDefinitions(fout, "\n\t\t\t\t", "", "RC");
fout << "/>\n";
targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "RC");
fout << "\t\t\t/>\n";
tool = "VCMIDLTool";
if (this->FortranProject) {
tool = "VFMIDLTool";
}
fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n";
targetOptions.OutputAdditionalIncludeDirectories(fout, "\n\t\t\t\t", "",
"MIDL");
targetOptions.OutputAdditionalIncludeDirectories(fout, "\t\t\t\t", "MIDL");
fout << "\t\t\t\tMkTypLibCompatible=\"false\"\n";
if (gg->GetPlatformName() == "x64") {
fout << "\t\t\t\tTargetEnvironment=\"3\"\n";
......@@ -1686,9 +1682,9 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
fileOptions.AddIncludes(includes);
fileOptions.OutputFlagMap(fout, "\t\t\t\t\t");
fileOptions.OutputAdditionalIncludeDirectories(
fout, "\t\t\t\t\t", "\n",
fout, "\t\t\t\t\t",
ppLang == "CXX" && this->FortranProject ? "Fortran" : ppLang);
fileOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t\t", "\n",
fileOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t\t",
ppLang);
}
if (!fc.AdditionalDeps.empty()) {
......@@ -2071,7 +2067,7 @@ void cmVS7GeneratorOptions::OutputFlag(std::ostream& fout, const char* indent,
{
fout << indent << tag << "=\"";
fout << cmLocalVisualStudio7GeneratorEscapeForXML(content);
fout << "\"";
fout << "\"\n";
}
// This class is used to parse an existing vs 7 project
......
......@@ -86,12 +86,12 @@ public:
// use the configuration specific tag for PreprocessorDefinitions
fout << indent;
this->TargetGenerator->WritePlatformConfigTag(
tag, this->GetConfiguration(), 0, 0, 0, &fout);
tag, this->GetConfiguration(), 0);
} else {
fout << indent << "<" << tag << ">";
}
fout << cmVS10EscapeXML(content);
fout << "</" << tag << ">";
fout << "</" << tag << ">\n";
}
private:
......@@ -218,12 +218,10 @@ cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator()
void cmVisualStudio10TargetGenerator::WritePlatformConfigTag(
const char* tag, const std::string& config, int indentLevel,
const char* attribute, const char* end, std::ostream* stream)
const char* attribute)
{
if (!stream) {
stream = this->BuildFileStream;
}
std::ostream* stream = this->BuildFileStream;
stream->fill(' ');
stream->width(indentLevel * 2);
(*stream) << ""; // applies indentation
......@@ -244,8 +242,8 @@ void cmVisualStudio10TargetGenerator::WritePlatformConfigTag(
}
// close the tag
(*stream) << ">";
if (end) {
(*stream) << end;
if (attribute) {
(*stream) << "\n";
}
}
......@@ -972,7 +970,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
{
for (std::string const& c : this->Configurations) {
this->WritePlatformConfigTag("PropertyGroup", c, 1,
" Label=\"Configuration\"", "\n");
" Label=\"Configuration\"");
if (this->ProjectType != csproj) {
std::string configType = "<ConfigurationType>";
......@@ -1312,8 +1310,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomRuleCSharp(
attributes << "\n Name=\"" << name << "\"";
attributes << "\n Inputs=\"" << inputs << "\"";
attributes << "\n Outputs=\"" << outputs << "\"";
this->WritePlatformConfigTag("Target", config, 1, attributes.str().c_str(),
"\n");
this->WritePlatformConfigTag("Target", config, 1, attributes.str().c_str());
if (!comment.empty()) {
this->WriteString("<Exec Command=\"", 2);
(*this->BuildFileStream) << "echo " << cmVS10EscapeXML(comment)
......@@ -2127,10 +2124,10 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
clOptions.SetConfiguration(config);
clOptions.PrependInheritedString("AdditionalOptions");
clOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream,
" ", "\n", lang);
" ", lang);
clOptions.OutputFlagMap(*this->BuildFileStream, " ");
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
"\n", lang);
lang);
}
}
if (this->IsXamlSource(source->GetFullPath())) {
......@@ -2486,10 +2483,10 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
this->WriteString("<ClCompile>\n", 2);
clOptions.PrependInheritedString("AdditionalOptions");
clOptions.OutputAdditionalIncludeDirectories(
*this->BuildFileStream, " ", "\n", this->LangForClCompile);
*this->BuildFileStream, " ", this->LangForClCompile);
clOptions.OutputFlagMap(*this->BuildFileStream, " ");
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
"\n", this->LangForClCompile);
this->LangForClCompile);
if (this->NsightTegra) {
if (const char* processMax =
......@@ -2575,9 +2572,9 @@ void cmVisualStudio10TargetGenerator::WriteRCOptions(
Options& rcOptions = *(this->RcOptions[configName]);
rcOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
"\n", "RC");
"RC");
rcOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream,
" ", "\n", "RC");
" ", "RC");
rcOptions.PrependInheritedString("AdditionalOptions");
rcOptions.OutputFlagMap(*this->BuildFileStream, " ");
......@@ -2711,9 +2708,9 @@ void cmVisualStudio10TargetGenerator::WriteCudaOptions(
Options& cudaOptions = *(this->CudaOptions[configName]);
cudaOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream,
" ", "\n", "CUDA");
" ", "CUDA");
cudaOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
"\n", "CUDA");
"CUDA");
cudaOptions.PrependInheritedString("AdditionalOptions");
cudaOptions.OutputFlagMap(*this->BuildFileStream, " ");
......@@ -2836,11 +2833,11 @@ void cmVisualStudio10TargetGenerator::WriteMasmOptions(
// Preprocessor definitions and includes are shared with clOptions.
Options& clOptions = *(this->ClOptions[configName]);
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
"\n", "ASM_MASM");
"ASM_MASM");
Options& masmOptions = *(this->MasmOptions[configName]);
masmOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream,
" ", "\n", "ASM_MASM");
" ", "ASM_MASM");
masmOptions.PrependInheritedString("AdditionalOptions");
masmOptions.OutputFlagMap(*this->BuildFileStream, " ");
......@@ -2897,16 +2894,16 @@ void cmVisualStudio10TargetGenerator::WriteNasmOptions(
this->GetIncludes(configName, "ASM_NASM");
Options& nasmOptions = *(this->NasmOptions[configName]);
nasmOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream,
" ", "\n", "ASM_NASM");
" ", "ASM_NASM");
nasmOptions.OutputFlagMap(*this->BuildFileStream, " ");
nasmOptions.PrependInheritedString("AdditionalOptions");
nasmOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
"\n", "ASM_NASM");
"ASM_NASM");
// Preprocessor definitions and includes are shared with clOptions.
Options& clOptions = *(this->ClOptions[configName]);
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
"\n", "ASM_NASM");
"ASM_NASM");
this->WriteString("</NASM>\n", 2);
}
......
......@@ -34,8 +34,7 @@ public:
void Generate();
// used by cmVisualStudioGeneratorOptions
void WritePlatformConfigTag(const char* tag, const std::string& config,
int indentLevel, const char* attribute = 0,
const char* end = 0, std::ostream* strm = 0);
int indentLevel, const char* attribute = 0);
private:
struct ToolSource
......
......@@ -422,8 +422,7 @@ const std::string& cmVisualStudioGeneratorOptions::GetConfiguration() const
}
void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions(
std::ostream& fout, const char* prefix, const char* suffix,
const std::string& lang)
std::ostream& fout, const char* prefix, const std::string& lang)
{
if (this->Defines.empty()) {
return;
......@@ -462,12 +461,10 @@ void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions(
}
this->OutputFlag(fout, prefix, tag, oss.str());
fout << suffix;
}
void cmVisualStudioGeneratorOptions::OutputAdditionalIncludeDirectories(
std::ostream& fout, const char* prefix, const char* suffix,
const std::string& lang)
std::ostream& fout, const char* prefix, const std::string& lang)
{
if (this->Includes.empty()) {
return;
......@@ -512,7 +509,6 @@ void cmVisualStudioGeneratorOptions::OutputAdditionalIncludeDirectories(
}
this->OutputFlag(fout, prefix, tag, oss.str());
fout << suffix;
}
void cmVisualStudioGeneratorOptions::OutputFlagMap(std::ostream& fout,
......@@ -530,6 +526,5 @@ void cmVisualStudioGeneratorOptions::OutputFlagMap(std::ostream& fout,
}
this->OutputFlag(fout, indent, m.first.c_str(), oss.str());
fout << "\n";
}
}
......@@ -78,11 +78,9 @@ public:
bool IsManaged() const;
// Write options to output.
void OutputPreprocessorDefinitions(std::ostream& fout, const char* prefix,
const char* suffix,
const std::string& lang);
void OutputAdditionalIncludeDirectories(std::ostream& fout,
const char* prefix,
const char* suffix,
const std::string& lang);
void OutputFlagMap(std::ostream& fout, const char* indent);
void SetConfiguration(const std::string& config);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment