summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudio10TargetGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx206
1 files changed, 118 insertions, 88 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 9a015cf..5c3b134 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -8,7 +8,7 @@
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalVisualStudio10Generator.h"
-#include "cmLocalVisualStudio7Generator.h"
+#include "cmLocalVisualStudio10Generator.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
#include "cmSystemTools.h"
@@ -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, "<", "&lt;");
+ cmSystemTools::ReplaceString(arg, ">", "&gt;");
+ cmSystemTools::ReplaceString(arg, "\"", "&quot;");
+ 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,22 +70,39 @@ struct cmVisualStudio10TargetGenerator::Elem
HasElements = true;
}
}
- cmGeneratedFileStream& WriteString(const char* line);
- void StartElement(const char* tag)
+ std::ostream& WriteString(const char* line);
+ Elem& StartElement(const char* tag)
{
this->Tag = tag;
this->WriteString("<") << tag;
+ return *this;
}
template <typename T>
void WriteElem(const char* tag, const T& val)
{
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;
+ }
+ // 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) {
@@ -99,17 +125,20 @@ public:
{
}
- void OutputFlag(std::ostream& fout, const char* indent, const char* tag,
+ void OutputFlag(std::ostream& fout, int indent, const char* tag,
const std::string& content) override
{
if (!this->GetConfiguration().empty()) {
// if there are configuration specific flags, then
// use the configuration specific tag for PreprocessorDefinitions
- fout << indent;
this->TargetGenerator->WritePlatformConfigTag(
- tag, this->GetConfiguration(), 0);
+ tag, this->GetConfiguration(), indent);
} else {
- fout << indent << "<" << tag << ">";
+ fout.fill(' ');
+ fout.width(indent * 2);
+ // write an empty string to get the fill level indent to print
+ fout << "";
+ fout << "<" << tag << ">";
}
fout << cmVS10EscapeXML(content);
fout << "</" << tag << ">\n";
@@ -139,15 +168,6 @@ inline void cmVisualStudio10TargetGenerator::WriteElemEscapeXML(
this->WriteElem(tag, cmVS10EscapeXML(val), indentLevel);
}
-static std::string cmVS10EscapeAttr(std::string arg)
-{
- cmSystemTools::ReplaceString(arg, "&", "&amp;");
- cmSystemTools::ReplaceString(arg, "<", "&lt;");
- cmSystemTools::ReplaceString(arg, ">", "&gt;");
- cmSystemTools::ReplaceString(arg, "\"", "&quot;");
- return arg;
-}
-
static std::string cmVS10EscapeComment(std::string comment)
{
// MSBuild takes the CDATA of a <Message></Message> element and just
@@ -202,7 +222,8 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator(
, Name(target->GetName())
, GUID(gg->GetGUID(this->Name))
, GlobalGenerator(gg)
- , LocalGenerator((cmLocalVisualStudio7Generator*)target->GetLocalGenerator())
+ , LocalGenerator(
+ (cmLocalVisualStudio10Generator*)target->GetLocalGenerator())
{
this->Makefile->GetConfigurations(this->Configurations);
this->NsightTegra = gg->IsNsightTegra();
@@ -236,38 +257,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(' ');
@@ -1155,7 +1184,7 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged(
<< ".exe</StartProgram>\n";
}
- o.OutputFlagMap(*this->BuildFileStream, " ");
+ o.OutputFlagMap(*this->BuildFileStream, 2);
}
//----------------------------------------------------------------------------
@@ -1189,7 +1218,6 @@ void cmVisualStudio10TargetGenerator::WriteNsightTegraConfigurationValues(
void cmVisualStudio10TargetGenerator::WriteCustomCommands()
{
- this->SourcesVisited.clear();
this->CSharpCustomCommandNames.clear();
std::vector<cmSourceFile const*> customCommands;
this->GeneratorTarget->GetCustomCommands(customCommands, "");
@@ -1210,7 +1238,9 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommands()
void cmVisualStudio10TargetGenerator::WriteCustomCommand(
cmSourceFile const* sf)
{
- if (this->SourcesVisited.insert(sf).second) {
+ if (this->LocalGenerator->GetSourcesVisited(this->GeneratorTarget)
+ .insert(sf)
+ .second) {
if (std::vector<cmSourceFile*> const* depends =
this->GeneratorTarget->GetSourceDepends(sf)) {
for (cmSourceFile const* di : *depends) {
@@ -1306,7 +1336,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);
}
}
@@ -1316,26 +1346,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");
}
}
@@ -1602,6 +1627,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
std::string shaderAdditionalFlags;
std::string shaderDisableOptimizations;
std::string shaderEnableDebug;
+ std::string shaderObjectFileName;
std::string outputHeaderFile;
std::string variableName;
std::string settingsGenerator;
@@ -1678,6 +1704,10 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
shaderDisableOptimizations = cmSystemTools::IsOn(sdo) ? "true" : "false";
toolHasSettings = true;
}
+ if (const char* sofn = sf->GetProperty("VS_SHADER_OBJECT_FILE_NAME")) {
+ shaderObjectFileName = sofn;
+ toolHasSettings = true;
+ }
} else if (ext == "jpg" || ext == "png") {
tool = "Image";
} else if (ext == "resw") {
@@ -1820,6 +1850,9 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
this->WriteElemEscapeXML("DisableOptimizations",
shaderDisableOptimizations, 3);
}
+ if (!shaderObjectFileName.empty()) {
+ this->WriteElemEscapeXML("ObjectFileOutput", shaderObjectFileName, 3);
+ }
if (!shaderAdditionalFlags.empty()) {
this->WriteElemEscapeXML("AdditionalOptions", shaderAdditionalFlags, 3);
}
@@ -2165,11 +2198,10 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
clOptions.AddIncludes(includeList);
clOptions.SetConfiguration(config);
clOptions.PrependInheritedString("AdditionalOptions");
- clOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream,
- " ", lang);
- clOptions.OutputFlagMap(*this->BuildFileStream, " ");
- clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
- lang);
+ clOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, 3,
+ lang);
+ clOptions.OutputFlagMap(*this->BuildFileStream, 3);
+ clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, 3, lang);
}
}
if (this->IsXamlSource(source->GetFullPath())) {
@@ -2606,10 +2638,10 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
}
this->WriteString("<ClCompile>\n", 2);
clOptions.PrependInheritedString("AdditionalOptions");
- clOptions.OutputAdditionalIncludeDirectories(
- *this->BuildFileStream, " ", this->LangForClCompile);
- clOptions.OutputFlagMap(*this->BuildFileStream, " ");
- clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
+ clOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, 3,
+ this->LangForClCompile);
+ clOptions.OutputFlagMap(*this->BuildFileStream, 3);
+ clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, 3,
this->LangForClCompile);
if (this->NsightTegra) {
@@ -2707,12 +2739,11 @@ void cmVisualStudio10TargetGenerator::WriteRCOptions(
this->WriteString("<ResourceCompile>\n", 2);
Options& rcOptions = *(this->RcOptions[configName]);
- rcOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
- "RC");
- rcOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream,
- " ", "RC");
+ rcOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, 3, "RC");
+ rcOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, 3,
+ "RC");
rcOptions.PrependInheritedString("AdditionalOptions");
- rcOptions.OutputFlagMap(*this->BuildFileStream, " ");
+ rcOptions.OutputFlagMap(*this->BuildFileStream, 3);
this->WriteString("</ResourceCompile>\n", 2);
}
@@ -2857,12 +2888,11 @@ void cmVisualStudio10TargetGenerator::WriteCudaOptions(
this->WriteString("<CudaCompile>\n", 2);
Options& cudaOptions = *(this->CudaOptions[configName]);
- cudaOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream,
- " ", "CUDA");
- cudaOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
- "CUDA");
+ cudaOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, 3,
+ "CUDA");
+ cudaOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, 3, "CUDA");
cudaOptions.PrependInheritedString("AdditionalOptions");
- cudaOptions.OutputFlagMap(*this->BuildFileStream, " ");
+ cudaOptions.OutputFlagMap(*this->BuildFileStream, 3);
this->WriteString("</CudaCompile>\n", 2);
}
@@ -2931,7 +2961,7 @@ void cmVisualStudio10TargetGenerator::WriteCudaLinkOptions(
this->WriteString("<CudaLink>\n", 2);
Options& cudaLinkOptions = *(this->CudaLinkOptions[configName]);
- cudaLinkOptions.OutputFlagMap(*this->BuildFileStream, " ");
+ cudaLinkOptions.OutputFlagMap(*this->BuildFileStream, 3);
this->WriteString("</CudaLink>\n", 2);
}
@@ -2982,14 +3012,14 @@ void cmVisualStudio10TargetGenerator::WriteMasmOptions(
// Preprocessor definitions and includes are shared with clOptions.
Options& clOptions = *(this->ClOptions[configName]);
- clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
+ clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, 3,
"ASM_MASM");
Options& masmOptions = *(this->MasmOptions[configName]);
- masmOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream,
- " ", "ASM_MASM");
+ masmOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, 3,
+ "ASM_MASM");
masmOptions.PrependInheritedString("AdditionalOptions");
- masmOptions.OutputFlagMap(*this->BuildFileStream, " ");
+ masmOptions.OutputFlagMap(*this->BuildFileStream, 3);
this->WriteString("</MASM>\n", 2);
}
@@ -3043,16 +3073,16 @@ void cmVisualStudio10TargetGenerator::WriteNasmOptions(
std::vector<std::string> includes =
this->GetIncludes(configName, "ASM_NASM");
Options& nasmOptions = *(this->NasmOptions[configName]);
- nasmOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream,
- " ", "ASM_NASM");
- nasmOptions.OutputFlagMap(*this->BuildFileStream, " ");
+ nasmOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, 3,
+ "ASM_NASM");
+ nasmOptions.OutputFlagMap(*this->BuildFileStream, 3);
nasmOptions.PrependInheritedString("AdditionalOptions");
- nasmOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
+ nasmOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, 3,
"ASM_NASM");
// Preprocessor definitions and includes are shared with clOptions.
Options& clOptions = *(this->ClOptions[configName]);
- clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
+ clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, 3,
"ASM_NASM");
this->WriteString("</NASM>\n", 2);
@@ -3076,7 +3106,7 @@ void cmVisualStudio10TargetGenerator::WriteLibOptions(
gg->GetLibFlagTable(), this);
libOptions.Parse(libflags.c_str());
libOptions.PrependInheritedString("AdditionalOptions");
- libOptions.OutputFlagMap(*this->BuildFileStream, " ");
+ libOptions.OutputFlagMap(*this->BuildFileStream, 3);
this->WriteString("</Lib>\n", 2);
}
@@ -3504,7 +3534,7 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(
this->WriteString("<Link>\n", 2);
linkOptions.PrependInheritedString("AdditionalOptions");
- linkOptions.OutputFlagMap(*this->BuildFileStream, " ");
+ linkOptions.OutputFlagMap(*this->BuildFileStream, 3);
this->WriteString("</Link>\n", 2);
if (!this->GlobalGenerator->NeedLinkLibraryDependencies(