cmVisualStudio10TargetGenerator: Use helpers for XML tags

Make the XML generating code smaller, more structured, and less
error-prone.  This is a step towards future XML refactoring.
This commit is contained in:
Vitaly Stakhovsky
2018-03-05 19:21:57 -05:00
committed by Brad King
parent e02f4f0660
commit 59d8cfb85e
2 changed files with 166 additions and 312 deletions

View File

@@ -18,6 +18,22 @@
#include <iterator> #include <iterator>
#include <memory> // IWYU pragma: keep #include <memory> // IWYU pragma: keep
inline void cmVisualStudio10TargetGenerator::WriteElem(const char* tag,
const char* val,
int indentLevel)
{
this->WriteString("<", indentLevel);
(*this->BuildFileStream) << tag << ">" << val << "</" << tag << ">\n";
}
inline void cmVisualStudio10TargetGenerator::WriteElem(const char* tag,
std::string const& val,
int indentLevel)
{
this->WriteString("<", indentLevel);
(*this->BuildFileStream) << tag << ">" << val << "</" << tag << ">\n";
}
static void ConvertToWindowsSlash(std::string& s); static void ConvertToWindowsSlash(std::string& s);
static std::string cmVS10EscapeXML(std::string arg) static std::string cmVS10EscapeXML(std::string arg)
@@ -28,6 +44,12 @@ static std::string cmVS10EscapeXML(std::string arg)
return arg; return arg;
} }
inline void cmVisualStudio10TargetGenerator::WriteElemEscapeXML(
const char* tag, std::string const& val, int indentLevel)
{
this->WriteElem(tag, cmVS10EscapeXML(val), indentLevel);
}
static std::string cmVS10EscapeQuotes(std::string arg) static std::string cmVS10EscapeQuotes(std::string arg)
{ {
cmSystemTools::ReplaceString(arg, "\"", "&quot;"); cmSystemTools::ReplaceString(arg, "\"", "&quot;");
@@ -265,16 +287,10 @@ void cmVisualStudio10TargetGenerator::Generate()
} }
(*this->BuildFileStream) << "</NsightTegraProjectRevisionNumber>\n"; (*this->BuildFileStream) << "</NsightTegraProjectRevisionNumber>\n";
// Tell newer versions to upgrade silently when loading. // Tell newer versions to upgrade silently when loading.
this->WriteString("<NsightTegraUpgradeOnceWithoutPrompt>" this->WriteElem("NsightTegraUpgradeOnceWithoutPrompt", "true", 2);
"true"
"</NsightTegraUpgradeOnceWithoutPrompt>\n",
2);
} else { } else {
// Require Nsight Tegra 1.6 for JCompile support. // Require Nsight Tegra 1.6 for JCompile support.
this->WriteString("<NsightTegraProjectRevisionNumber>" this->WriteElem("NsightTegraProjectRevisionNumber", "7", 2);
"7"
"</NsightTegraProjectRevisionNumber>\n",
2);
} }
this->WriteString("</PropertyGroup>\n", 1); this->WriteString("</PropertyGroup>\n", 1);
} }
@@ -282,9 +298,7 @@ void cmVisualStudio10TargetGenerator::Generate()
if (const char* hostArch = if (const char* hostArch =
this->GlobalGenerator->GetPlatformToolsetHostArchitecture()) { this->GlobalGenerator->GetPlatformToolsetHostArchitecture()) {
this->WriteString("<PropertyGroup>\n", 1); this->WriteString("<PropertyGroup>\n", 1);
this->WriteString("<PreferredToolArchitecture>", 2); this->WriteElemEscapeXML("PreferredToolArchitecture", hostArch, 2);
(*this->BuildFileStream) << cmVS10EscapeXML(hostArch)
<< "</PreferredToolArchitecture>\n";
this->WriteString("</PropertyGroup>\n", 1); this->WriteString("</PropertyGroup>\n", 1);
} }
@@ -292,8 +306,7 @@ void cmVisualStudio10TargetGenerator::Generate()
this->WriteProjectConfigurations(); this->WriteProjectConfigurations();
} }
this->WriteString("<PropertyGroup Label=\"Globals\">\n", 1); this->WriteString("<PropertyGroup Label=\"Globals\">\n", 1);
this->WriteString("<ProjectGuid>", 2); this->WriteElem("ProjectGuid", "{" + this->GUID + "}", 2);
(*this->BuildFileStream) << "{" << this->GUID << "}</ProjectGuid>\n";
if (this->MSTools && if (this->MSTools &&
this->GeneratorTarget->GetType() <= cmStateEnums::GLOBAL_TARGET) { this->GeneratorTarget->GetType() <= cmStateEnums::GLOBAL_TARGET) {
@@ -322,61 +335,45 @@ void cmVisualStudio10TargetGenerator::Generate()
this->GeneratorTarget->GetProperty("VS_SCC_PROVIDER"); this->GeneratorTarget->GetProperty("VS_SCC_PROVIDER");
if (vsProjectName && vsLocalPath && vsProvider) { if (vsProjectName && vsLocalPath && vsProvider) {
this->WriteString("<SccProjectName>", 2); this->WriteElemEscapeXML("SccProjectName", vsProjectName, 2);
(*this->BuildFileStream) << cmVS10EscapeXML(vsProjectName) this->WriteElemEscapeXML("SccLocalPath", vsLocalPath, 2);
<< "</SccProjectName>\n"; this->WriteElemEscapeXML("SccProvider", vsProvider, 2);
this->WriteString("<SccLocalPath>", 2);
(*this->BuildFileStream) << cmVS10EscapeXML(vsLocalPath)
<< "</SccLocalPath>\n";
this->WriteString("<SccProvider>", 2);
(*this->BuildFileStream) << cmVS10EscapeXML(vsProvider)
<< "</SccProvider>\n";
const char* vsAuxPath = const char* vsAuxPath =
this->GeneratorTarget->GetProperty("VS_SCC_AUXPATH"); this->GeneratorTarget->GetProperty("VS_SCC_AUXPATH");
if (vsAuxPath) { if (vsAuxPath) {
this->WriteString("<SccAuxPath>", 2); this->WriteElemEscapeXML("SccAuxPath", vsAuxPath, 2);
(*this->BuildFileStream) << cmVS10EscapeXML(vsAuxPath)
<< "</SccAuxPath>\n";
} }
} }
if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT")) { if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT")) {
this->WriteString("<WinMDAssembly>true</WinMDAssembly>\n", 2); this->WriteElem("WinMDAssembly", "true", 2);
} }
const char* vsGlobalKeyword = const char* vsGlobalKeyword =
this->GeneratorTarget->GetProperty("VS_GLOBAL_KEYWORD"); this->GeneratorTarget->GetProperty("VS_GLOBAL_KEYWORD");
if (!vsGlobalKeyword) { if (!vsGlobalKeyword) {
this->WriteString("<Keyword>Win32Proj</Keyword>\n", 2); this->WriteElem("Keyword", "Win32Proj", 2);
} else { } else {
this->WriteString("<Keyword>", 2); this->WriteElemEscapeXML("Keyword", vsGlobalKeyword, 2);
(*this->BuildFileStream) << cmVS10EscapeXML(vsGlobalKeyword)
<< "</Keyword>\n";
} }
const char* vsGlobalRootNamespace = const char* vsGlobalRootNamespace =
this->GeneratorTarget->GetProperty("VS_GLOBAL_ROOTNAMESPACE"); this->GeneratorTarget->GetProperty("VS_GLOBAL_ROOTNAMESPACE");
if (vsGlobalRootNamespace) { if (vsGlobalRootNamespace) {
this->WriteString("<RootNamespace>", 2); this->WriteElemEscapeXML("RootNamespace", vsGlobalRootNamespace, 2);
(*this->BuildFileStream) << cmVS10EscapeXML(vsGlobalRootNamespace)
<< "</RootNamespace>\n";
} }
this->WriteString("<Platform>", 2); this->WriteElemEscapeXML("Platform", this->Platform, 2);
(*this->BuildFileStream) << cmVS10EscapeXML(this->Platform)
<< "</Platform>\n";
const char* projLabel = this->GeneratorTarget->GetProperty("PROJECT_LABEL"); const char* projLabel = this->GeneratorTarget->GetProperty("PROJECT_LABEL");
if (!projLabel) { if (!projLabel) {
projLabel = this->Name.c_str(); projLabel = this->Name.c_str();
} }
this->WriteString("<ProjectName>", 2); this->WriteElemEscapeXML("ProjectName", projLabel, 2);
(*this->BuildFileStream) << cmVS10EscapeXML(projLabel) << "</ProjectName>\n";
if (const char* targetFrameworkVersion = this->GeneratorTarget->GetProperty( if (const char* targetFrameworkVersion = this->GeneratorTarget->GetProperty(
"VS_DOTNET_TARGET_FRAMEWORK_VERSION")) { "VS_DOTNET_TARGET_FRAMEWORK_VERSION")) {
this->WriteString("<TargetFrameworkVersion>", 2); this->WriteElemEscapeXML("TargetFrameworkVersion", targetFrameworkVersion,
(*this->BuildFileStream) << cmVS10EscapeXML(targetFrameworkVersion) 2);
<< "</TargetFrameworkVersion>\n";
} }
// Disable the project upgrade prompt that is displayed the first time a // Disable the project upgrade prompt that is displayed the first time a
@@ -384,9 +381,7 @@ void cmVisualStudio10TargetGenerator::Generate()
// the IDE (respected by VS 2013 and above). // the IDE (respected by VS 2013 and above).
if (this->GlobalGenerator->GetVersion() >= if (this->GlobalGenerator->GetVersion() >=
cmGlobalVisualStudioGenerator::VS12) { cmGlobalVisualStudioGenerator::VS12) {
this->WriteString("<VCProjectUpgraderObjectName>NoUpgrade" this->WriteElem("VCProjectUpgraderObjectName", "NoUpgrade", 2);
"</VCProjectUpgraderObjectName>\n",
2);
} }
std::vector<std::string> keys = this->GeneratorTarget->GetPropertyKeys(); std::vector<std::string> keys = this->GeneratorTarget->GetPropertyKeys();
@@ -437,8 +432,7 @@ void cmVisualStudio10TargetGenerator::Generate()
} }
outputType += "</OutputType>\n"; outputType += "</OutputType>\n";
this->WriteString(outputType.c_str(), 2); this->WriteString(outputType.c_str(), 2);
this->WriteString("<AppDesignerFolder>Properties</AppDesignerFolder>\n", this->WriteElem("AppDesignerFolder", "Properties", 2);
2);
} }
this->WriteString("</PropertyGroup>\n", 1); this->WriteString("</PropertyGroup>\n", 1);
@@ -635,12 +629,8 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReference(
{ {
this->WriteString("<Reference Include=\"", 2); this->WriteString("<Reference Include=\"", 2);
(*this->BuildFileStream) << cmVS10EscapeXML(ref) << "\">\n"; (*this->BuildFileStream) << cmVS10EscapeXML(ref) << "\">\n";
this->WriteString("<CopyLocalSatelliteAssemblies>true" this->WriteElem("CopyLocalSatelliteAssemblies", "true", 3);
"</CopyLocalSatelliteAssemblies>\n", this->WriteElem("ReferenceOutputAssembly", "true", 3);
3);
this->WriteString("<ReferenceOutputAssembly>true"
"</ReferenceOutputAssembly>\n",
3);
if (!hint.empty()) { if (!hint.empty()) {
const char* privateReference = "True"; const char* privateReference = "True";
if (const char* value = this->GeneratorTarget->GetProperty( if (const char* value = this->GeneratorTarget->GetProperty(
@@ -649,10 +639,8 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReference(
privateReference = "False"; privateReference = "False";
} }
} }
this->WriteString("<Private>", 3); this->WriteElem("Private", privateReference, 3);
(*this->BuildFileStream) << privateReference << "</Private>\n"; this->WriteElem("HintPath", hint, 3);
this->WriteString("<HintPath>", 3);
(*this->BuildFileStream) << hint << "</HintPath>\n";
} }
this->WriteDotNetReferenceCustomTags(ref); this->WriteDotNetReferenceCustomTags(ref);
this->WriteString("</Reference>\n", 2); this->WriteString("</Reference>\n", 2);
@@ -711,9 +699,8 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
(*this->BuildFileStream) << obj << "\">\n"; (*this->BuildFileStream) << obj << "\">\n";
if (this->ProjectType != csproj) { if (this->ProjectType != csproj) {
this->WriteString("<DependentUpon>", 3);
std::string hFileName = obj.substr(0, obj.find_last_of(".")) + ".h"; std::string hFileName = obj.substr(0, obj.find_last_of(".")) + ".h";
(*this->BuildFileStream) << hFileName << "</DependentUpon>\n"; this->WriteElem("DependentUpon", hFileName, 3);
for (std::string const& i : this->Configurations) { for (std::string const& i : this->Configurations) {
this->WritePlatformConfigTag("LogicalName", i, 3); this->WritePlatformConfigTag("LogicalName", i, 3);
@@ -741,8 +728,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
link = cmsys::SystemTools::GetFilenameName(obj); link = cmsys::SystemTools::GetFilenameName(obj);
} }
if (!link.empty()) { if (!link.empty()) {
this->WriteString("<Link>", 3); this->WriteElem("Link", link, 3);
(*this->BuildFileStream) << link << "</Link>\n";
} }
} }
// Determine if this is a generated resource from a .Designer.cs file // Determine if this is a generated resource from a .Designer.cs file
@@ -756,9 +742,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
generator = g; generator = g;
} }
if (!generator.empty()) { if (!generator.empty()) {
this->WriteString("<Generator>", 3); this->WriteElemEscapeXML("Generator", generator, 3);
(*this->BuildFileStream) << cmVS10EscapeXML(generator)
<< "</Generator>\n";
if (designerResource.find(srcDir) == 0) { if (designerResource.find(srcDir) == 0) {
designerResource = designerResource.substr(srcDir.length() + 1); designerResource = designerResource.substr(srcDir.length() + 1);
} else if (designerResource.find(binDir) == 0) { } else if (designerResource.find(binDir) == 0) {
@@ -768,9 +752,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
cmsys::SystemTools::GetFilenameName(designerResource); cmsys::SystemTools::GetFilenameName(designerResource);
} }
ConvertToWindowsSlash(designerResource); ConvertToWindowsSlash(designerResource);
this->WriteString("<LastGenOutput>", 3); this->WriteElem("LastGenOutput", designerResource, 3);
(*this->BuildFileStream) << designerResource
<< "</LastGenOutput>\n";
} }
} }
const cmPropertyMap& props = oi->GetProperties(); const cmPropertyMap& props = oi->GetProperties();
@@ -828,11 +810,10 @@ void cmVisualStudio10TargetGenerator::WriteXamlFilesGroup()
} }
if (!link.empty()) { if (!link.empty()) {
ConvertToWindowsSlash(link); ConvertToWindowsSlash(link);
this->WriteString("<Link>", 3); this->WriteElem("Link", link, 3);
(*this->BuildFileStream) << link << "</Link>\n";
} }
} }
this->WriteString("<SubType>Designer</SubType>\n", 3); this->WriteElem("SubType", "Designer", 3);
this->WriteString("</", 2); this->WriteString("</", 2);
(*this->BuildFileStream) << xamlType << ">\n"; (*this->BuildFileStream) << xamlType << ">\n";
} }
@@ -894,7 +875,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTReferences()
for (std::string const& ri : references) { for (std::string const& ri : references) {
this->WriteString("<Reference Include=\"", 2); this->WriteString("<Reference Include=\"", 2);
(*this->BuildFileStream) << cmVS10EscapeXML(ri) << "\">\n"; (*this->BuildFileStream) << cmVS10EscapeXML(ri) << "\">\n";
this->WriteString("<IsWinMDFile>true</IsWinMDFile>\n", 3); this->WriteElem("IsWinMDFile", "true", 3);
this->WriteString("</Reference>\n", 2); this->WriteString("</Reference>\n", 2);
} }
this->WriteString("</ItemGroup>\n", 1); this->WriteString("</ItemGroup>\n", 1);
@@ -909,11 +890,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurations()
for (std::string const& c : this->Configurations) { for (std::string const& c : this->Configurations) {
this->WriteString("<ProjectConfiguration Include=\"", 2); this->WriteString("<ProjectConfiguration Include=\"", 2);
(*this->BuildFileStream) << c << "|" << this->Platform << "\">\n"; (*this->BuildFileStream) << c << "|" << this->Platform << "\">\n";
this->WriteString("<Configuration>", 3); this->WriteElem("Configuration", c, 3);
(*this->BuildFileStream) << c << "</Configuration>\n"; this->WriteElemEscapeXML("Platform", this->Platform, 3);
this->WriteString("<Platform>", 3);
(*this->BuildFileStream) << cmVS10EscapeXML(this->Platform)
<< "</Platform>\n";
this->WriteString("</ProjectConfiguration>\n", 2); this->WriteString("</ProjectConfiguration>\n", 2);
} }
this->WriteString("</ItemGroup>\n", 1); this->WriteString("</ItemGroup>\n", 1);
@@ -997,9 +975,7 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues(
useOfMfcValue = "Dynamic"; useOfMfcValue = "Dynamic";
} }
} }
std::string mfcLine = "<UseOfMfc>"; this->WriteElem("UseOfMfc", useOfMfcValue, 2);
mfcLine += useOfMfcValue + "</UseOfMfc>\n";
this->WriteString(mfcLine.c_str(), 2);
} }
if ((this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY && if ((this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY &&
@@ -1008,25 +984,20 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues(
this->GlobalGenerator->TargetsWindowsPhone() || this->GlobalGenerator->TargetsWindowsPhone() ||
this->GlobalGenerator->TargetsWindowsStore() || this->GlobalGenerator->TargetsWindowsStore() ||
this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) { this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) {
this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2); this->WriteElem("CharacterSet", "Unicode", 2);
} else if (this->GeneratorTarget->GetType() <= } else if (this->GeneratorTarget->GetType() <=
cmStateEnums::MODULE_LIBRARY && cmStateEnums::MODULE_LIBRARY &&
this->ClOptions[config]->UsingSBCS()) { this->ClOptions[config]->UsingSBCS()) {
this->WriteString("<CharacterSet>NotSet</CharacterSet>\n", 2); this->WriteElem("CharacterSet", "NotSet", 2);
} else { } else {
this->WriteString("<CharacterSet>MultiByte</CharacterSet>\n", 2); this->WriteElem("CharacterSet", "MultiByte", 2);
} }
if (const char* toolset = gg->GetPlatformToolset()) { if (const char* toolset = gg->GetPlatformToolset()) {
std::string pts = "<PlatformToolset>"; this->WriteElem("PlatformToolset", toolset, 2);
pts += toolset;
pts += "</PlatformToolset>\n";
this->WriteString(pts.c_str(), 2);
} }
if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") || if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") ||
this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) { this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) {
this->WriteString("<WindowsAppContainer>true" this->WriteElem("WindowsAppContainer", "true", 2);
"</WindowsAppContainer>\n",
2);
} }
} }
@@ -1038,26 +1009,21 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged(
Options& o = *(this->ClOptions[config]); Options& o = *(this->ClOptions[config]);
if (o.IsDebug()) { if (o.IsDebug()) {
this->WriteString("<DebugSymbols>true</DebugSymbols>\n", 2); this->WriteElem("DebugSymbols", "true", 2);
this->WriteString("<DefineDebug>true</DefineDebug>\n", 2); this->WriteElem("DefineDebug", "true", 2);
} }
std::string outDir = this->GeneratorTarget->GetDirectory(config) + "/"; std::string outDir = this->GeneratorTarget->GetDirectory(config) + "/";
ConvertToWindowsSlash(outDir); ConvertToWindowsSlash(outDir);
this->WriteString("<OutputPath>", 2); this->WriteElemEscapeXML("OutputPath", outDir, 2);
(*this->BuildFileStream) << cmVS10EscapeXML(outDir) << "</OutputPath>\n";
if (o.HasFlag("Platform")) { if (o.HasFlag("Platform")) {
this->WriteString("<PlatformTarget>", 2); this->WriteElemEscapeXML("PlatformTarget", o.GetFlag("Platform"), 2);
(*this->BuildFileStream) << cmVS10EscapeXML(o.GetFlag("Platform"))
<< "</PlatformTarget>\n";
o.RemoveFlag("Platform"); o.RemoveFlag("Platform");
} }
if (const char* toolset = gg->GetPlatformToolset()) { if (const char* toolset = gg->GetPlatformToolset()) {
this->WriteString("<PlatformToolset>", 2); this->WriteElemEscapeXML("PlatformToolset", toolset, 2);
(*this->BuildFileStream) << cmVS10EscapeXML(toolset)
<< "</PlatformToolset>\n";
} }
std::string postfixName = cmSystemTools::UpperCase(config); std::string postfixName = cmSystemTools::UpperCase(config);
@@ -1067,12 +1033,10 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged(
if (const char* postfix = this->GeneratorTarget->GetProperty(postfixName)) { if (const char* postfix = this->GeneratorTarget->GetProperty(postfixName)) {
assemblyName += postfix; assemblyName += postfix;
} }
this->WriteString("<AssemblyName>", 2); this->WriteElemEscapeXML("AssemblyName", assemblyName, 2);
(*this->BuildFileStream) << cmVS10EscapeXML(assemblyName)
<< "</AssemblyName>\n";
if (cmStateEnums::EXECUTABLE == this->GeneratorTarget->GetType()) { if (cmStateEnums::EXECUTABLE == this->GeneratorTarget->GetType()) {
this->WriteString("<StartAction>Program</StartAction>\n", 2); this->WriteElem("StartAction", "Program", 2);
this->WriteString("<StartProgram>", 2); this->WriteString("<StartProgram>", 2);
(*this->BuildFileStream) << cmVS10EscapeXML(outDir) (*this->BuildFileStream) << cmVS10EscapeXML(outDir)
<< cmVS10EscapeXML(assemblyName) << cmVS10EscapeXML(assemblyName)
@@ -1094,27 +1058,20 @@ void cmVisualStudio10TargetGenerator::WriteNsightTegraConfigurationValues(
this->WriteString(ntv.c_str(), 2); this->WriteString(ntv.c_str(), 2);
if (const char* minApi = if (const char* minApi =
this->GeneratorTarget->GetProperty("ANDROID_API_MIN")) { this->GeneratorTarget->GetProperty("ANDROID_API_MIN")) {
this->WriteString("<AndroidMinAPI>", 2); this->WriteElem("AndroidMinAPI", "android-" + cmVS10EscapeXML(minApi), 2);
(*this->BuildFileStream) << "android-" << cmVS10EscapeXML(minApi)
<< "</AndroidMinAPI>\n";
} }
if (const char* api = this->GeneratorTarget->GetProperty("ANDROID_API")) { if (const char* api = this->GeneratorTarget->GetProperty("ANDROID_API")) {
this->WriteString("<AndroidTargetAPI>", 2); this->WriteElem("AndroidTargetAPI", "android-" + cmVS10EscapeXML(api), 2);
(*this->BuildFileStream) << "android-" << cmVS10EscapeXML(api)
<< "</AndroidTargetAPI>\n";
} }
if (const char* cpuArch = if (const char* cpuArch =
this->GeneratorTarget->GetProperty("ANDROID_ARCH")) { this->GeneratorTarget->GetProperty("ANDROID_ARCH")) {
this->WriteString("<AndroidArch>", 2); this->WriteElemEscapeXML("AndroidArch", cpuArch, 2);
(*this->BuildFileStream) << cmVS10EscapeXML(cpuArch) << "</AndroidArch>\n";
} }
if (const char* stlType = if (const char* stlType =
this->GeneratorTarget->GetProperty("ANDROID_STL_TYPE")) { this->GeneratorTarget->GetProperty("ANDROID_STL_TYPE")) {
this->WriteString("<AndroidStlType>", 2); this->WriteElemEscapeXML("AndroidStlType", stlType, 2);
(*this->BuildFileStream) << cmVS10EscapeXML(stlType)
<< "</AndroidStlType>\n";
} }
} }
@@ -1199,8 +1156,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
this->GetCSharpSourceLink(source, link); this->GetCSharpSourceLink(source, link);
this->WriteSource("None", source, ">\n"); this->WriteSource("None", source, ">\n");
if (!link.empty()) { if (!link.empty()) {
this->WriteString("<Link>", 3); this->WriteElem("Link", link, 3);
(*this->BuildFileStream) << link << "</Link>\n";
} }
this->WriteString("</None>\n", 2); this->WriteString("</None>\n", 2);
this->WriteString("</ItemGroup>\n", 1); this->WriteString("</ItemGroup>\n", 1);
@@ -1372,23 +1328,23 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
if (fileName == "wmappmanifest.xml") { if (fileName == "wmappmanifest.xml") {
this->WriteString("<XML Include=\"", 2); this->WriteString("<XML Include=\"", 2);
(*this->BuildFileStream) << oi << "\">\n"; (*this->BuildFileStream) << oi << "\">\n";
this->WriteString("<Filter>Resource Files</Filter>\n", 3); this->WriteElem("Filter", "Resource Files", 3);
this->WriteString("</XML>\n", 2); this->WriteString("</XML>\n", 2);
} else if (cmSystemTools::GetFilenameExtension(fileName) == } else if (cmSystemTools::GetFilenameExtension(fileName) ==
".appxmanifest") { ".appxmanifest") {
this->WriteString("<AppxManifest Include=\"", 2); this->WriteString("<AppxManifest Include=\"", 2);
(*this->BuildFileStream) << oi << "\">\n"; (*this->BuildFileStream) << oi << "\">\n";
this->WriteString("<Filter>Resource Files</Filter>\n", 3); this->WriteElem("Filter", "Resource Files", 3);
this->WriteString("</AppxManifest>\n", 2); this->WriteString("</AppxManifest>\n", 2);
} else if (cmSystemTools::GetFilenameExtension(fileName) == ".pfx") { } else if (cmSystemTools::GetFilenameExtension(fileName) == ".pfx") {
this->WriteString("<None Include=\"", 2); this->WriteString("<None Include=\"", 2);
(*this->BuildFileStream) << oi << "\">\n"; (*this->BuildFileStream) << oi << "\">\n";
this->WriteString("<Filter>Resource Files</Filter>\n", 3); this->WriteElem("Filter", "Resource Files", 3);
this->WriteString("</None>\n", 2); this->WriteString("</None>\n", 2);
} else { } else {
this->WriteString("<Image Include=\"", 2); this->WriteString("<Image Include=\"", 2);
(*this->BuildFileStream) << oi << "\">\n"; (*this->BuildFileStream) << oi << "\">\n";
this->WriteString("<Filter>Resource Files</Filter>\n", 3); this->WriteElem("Filter", "Resource Files", 3);
this->WriteString("</Image>\n", 2); this->WriteString("</Image>\n", 2);
} }
} }
@@ -1404,7 +1360,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
this->WriteString("<EmbeddedResource Include=\"", 2); this->WriteString("<EmbeddedResource Include=\"", 2);
ConvertToWindowsSlash(obj); ConvertToWindowsSlash(obj);
(*this->BuildFileStream) << cmVS10EscapeXML(obj) << "\">\n"; (*this->BuildFileStream) << cmVS10EscapeXML(obj) << "\">\n";
this->WriteString("<Filter>Resource Files</Filter>\n", 3); this->WriteElem("Filter", "Resource Files", 3);
this->WriteString("</EmbeddedResource>\n", 2); this->WriteString("</EmbeddedResource>\n", 2);
} }
this->WriteString("</ItemGroup>\n", 1); this->WriteString("</ItemGroup>\n", 1);
@@ -1423,10 +1379,8 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
(*this->BuildFileStream) << name << "\">\n"; (*this->BuildFileStream) << name << "\">\n";
std::string guidName = "SG_Filter_"; std::string guidName = "SG_Filter_";
guidName += name; guidName += name;
this->WriteString("<UniqueIdentifier>", 3);
std::string guid = this->GlobalGenerator->GetGUID(guidName); std::string guid = this->GlobalGenerator->GetGUID(guidName);
(*this->BuildFileStream) << "{" << guid << "}" this->WriteElem("UniqueIdentifier", "{" + guid + "}", 3);
<< "</UniqueIdentifier>\n";
this->WriteString("</Filter>\n", 2); this->WriteString("</Filter>\n", 2);
} }
} }
@@ -1434,10 +1388,8 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
if (!resxObjs.empty() || !this->AddedFiles.empty()) { if (!resxObjs.empty() || !this->AddedFiles.empty()) {
this->WriteString("<Filter Include=\"Resource Files\">\n", 2); this->WriteString("<Filter Include=\"Resource Files\">\n", 2);
std::string guidName = "SG_Filter_Resource Files"; std::string guidName = "SG_Filter_Resource Files";
this->WriteString("<UniqueIdentifier>", 3);
std::string guid = this->GlobalGenerator->GetGUID(guidName); std::string guid = this->GlobalGenerator->GetGUID(guidName);
(*this->BuildFileStream) << "{" << guid << "}" this->WriteElem("UniqueIdentifier", "{" + guid + "}", 3);
<< "</UniqueIdentifier>\n";
this->WriteString("<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;", 3); this->WriteString("<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;", 3);
(*this->BuildFileStream) << "gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;"; (*this->BuildFileStream) << "gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;";
(*this->BuildFileStream) << "mfcribbon-ms</Extensions>\n"; (*this->BuildFileStream) << "mfcribbon-ms</Extensions>\n";
@@ -1508,8 +1460,7 @@ void cmVisualStudio10TargetGenerator::WriteGroupSources(
(*this->BuildFileStream) << name << " Include=\"" << cmVS10EscapeXML(path); (*this->BuildFileStream) << name << " Include=\"" << cmVS10EscapeXML(path);
if (!filter.empty()) { if (!filter.empty()) {
(*this->BuildFileStream) << "\">\n"; (*this->BuildFileStream) << "\">\n";
this->WriteString("<Filter>", 3); this->WriteElem("Filter", filter, 3);
(*this->BuildFileStream) << filter << "</Filter>\n";
this->WriteString("</", 2); this->WriteString("</", 2);
(*this->BuildFileStream) << name << ">\n"; (*this->BuildFileStream) << name << ">\n";
} else { } else {
@@ -1524,13 +1475,12 @@ void cmVisualStudio10TargetGenerator::WriteHeaderSource(cmSourceFile const* sf)
std::string const& fileName = sf->GetFullPath(); std::string const& fileName = sf->GetFullPath();
if (this->IsResxHeader(fileName)) { if (this->IsResxHeader(fileName)) {
this->WriteSource("ClInclude", sf, ">\n"); this->WriteSource("ClInclude", sf, ">\n");
this->WriteString("<FileType>CppForm</FileType>\n", 3); this->WriteElem("FileType", "CppForm", 3);
this->WriteString("</ClInclude>\n", 2); this->WriteString("</ClInclude>\n", 2);
} else if (this->IsXamlHeader(fileName)) { } else if (this->IsXamlHeader(fileName)) {
this->WriteSource("ClInclude", sf, ">\n"); this->WriteSource("ClInclude", sf, ">\n");
this->WriteString("<DependentUpon>", 3);
std::string xamlFileName = fileName.substr(0, fileName.find_last_of(".")); std::string xamlFileName = fileName.substr(0, fileName.find_last_of("."));
(*this->BuildFileStream) << xamlFileName << "</DependentUpon>\n"; this->WriteElem("DependentUpon", xamlFileName, 3);
this->WriteString("</ClInclude>\n", 2); this->WriteString("</ClInclude>\n", 2);
} else { } else {
this->WriteSource("ClInclude", sf); this->WriteSource("ClInclude", sf);
@@ -1725,19 +1675,13 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
} }
} }
if (!shaderType.empty()) { if (!shaderType.empty()) {
this->WriteString("<ShaderType>", 3); this->WriteElemEscapeXML("ShaderType", shaderType, 3);
(*this->BuildFileStream) << cmVS10EscapeXML(shaderType)
<< "</ShaderType>\n";
} }
if (!shaderEntryPoint.empty()) { if (!shaderEntryPoint.empty()) {
this->WriteString("<EntryPointName>", 3); this->WriteElemEscapeXML("EntryPointName", shaderEntryPoint, 3);
(*this->BuildFileStream) << cmVS10EscapeXML(shaderEntryPoint)
<< "</EntryPointName>\n";
} }
if (!shaderModel.empty()) { if (!shaderModel.empty()) {
this->WriteString("<ShaderModel>", 3); this->WriteElemEscapeXML("ShaderModel", shaderModel, 3);
(*this->BuildFileStream) << cmVS10EscapeXML(shaderModel)
<< "</ShaderModel>\n";
} }
if (!outputHeaderFile.empty()) { if (!outputHeaderFile.empty()) {
for (size_t i = 0; i != this->Configurations.size(); ++i) { for (size_t i = 0; i != this->Configurations.size(); ++i) {
@@ -1762,47 +1706,33 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
} }
} }
if (!shaderEnableDebug.empty()) { if (!shaderEnableDebug.empty()) {
this->WriteString("<EnableDebuggingInformation>", 3); this->WriteElemEscapeXML("EnableDebuggingInformation", shaderEnableDebug,
(*this->BuildFileStream) << cmVS10EscapeXML(shaderEnableDebug) 3);
<< "</EnableDebuggingInformation>\n";
} }
if (!shaderDisableOptimizations.empty()) { if (!shaderDisableOptimizations.empty()) {
this->WriteString("<DisableOptimizations>", 3); this->WriteElemEscapeXML("DisableOptimizations",
(*this->BuildFileStream) << cmVS10EscapeXML(shaderDisableOptimizations) shaderDisableOptimizations, 3);
<< "</DisableOptimizations>\n";
} }
if (!shaderAdditionalFlags.empty()) { if (!shaderAdditionalFlags.empty()) {
this->WriteString("<AdditionalOptions>", 3); this->WriteElemEscapeXML("AdditionalOptions", shaderAdditionalFlags, 3);
(*this->BuildFileStream) << cmVS10EscapeXML(shaderAdditionalFlags)
<< "</AdditionalOptions>\n";
} }
if (!settingsGenerator.empty()) { if (!settingsGenerator.empty()) {
this->WriteString("<Generator>", 3); this->WriteElemEscapeXML("Generator", settingsGenerator, 3);
(*this->BuildFileStream) << cmVS10EscapeXML(settingsGenerator)
<< "</Generator>\n";
} }
if (!settingsLastGenOutput.empty()) { if (!settingsLastGenOutput.empty()) {
this->WriteString("<LastGenOutput>", 3); this->WriteElemEscapeXML("LastGenOutput", settingsLastGenOutput, 3);
(*this->BuildFileStream) << cmVS10EscapeXML(settingsLastGenOutput)
<< "</LastGenOutput>\n";
} }
if (!sourceLink.empty()) { if (!sourceLink.empty()) {
this->WriteString("<Link>", 3); this->WriteElemEscapeXML("Link", sourceLink, 3);
(*this->BuildFileStream) << cmVS10EscapeXML(sourceLink) << "</Link>\n";
} }
if (!subType.empty()) { if (!subType.empty()) {
this->WriteString("<SubType>", 3); this->WriteElemEscapeXML("SubType", subType, 3);
(*this->BuildFileStream) << cmVS10EscapeXML(subType) << "</SubType>\n";
} }
if (!copyToOutDir.empty()) { if (!copyToOutDir.empty()) {
this->WriteString("<CopyToOutputDirectory>", 3); this->WriteElemEscapeXML("CopyToOutputDirectory", copyToOutDir, 3);
(*this->BuildFileStream) << cmVS10EscapeXML(copyToOutDir)
<< "</CopyToOutputDirectory>\n";
} }
if (!includeInVsix.empty()) { if (!includeInVsix.empty()) {
this->WriteString("<IncludeInVSIX>", 3); this->WriteElemEscapeXML("IncludeInVSIX", includeInVsix, 3);
(*this->BuildFileStream) << cmVS10EscapeXML(includeInVsix)
<< "</IncludeInVSIX>\n";
} }
// write source file specific tags // write source file specific tags
this->WriteCSharpSourceProperties(sourceFileTags); this->WriteCSharpSourceProperties(sourceFileTags);
@@ -2057,13 +1987,9 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
firstString = ""; firstString = "";
hasFlags = true; hasFlags = true;
if (lang == "CUDA") { if (lang == "CUDA") {
this->WriteString("<CompileOut>", 3); this->WriteElem("CompileOut", "$(IntDir)/" + objectName, 3);
(*this->BuildFileStream) << "$(IntDir)/" << objectName
<< "</CompileOut>\n";
} else { } else {
this->WriteString("<ObjectFileName>", 3); this->WriteElem("ObjectFileName", "$(IntDir)/" + objectName, 3);
(*this->BuildFileStream) << "$(IntDir)/" << objectName
<< "</ObjectFileName>\n";
} }
} }
for (std::string const& config : this->Configurations) { for (std::string const& config : this->Configurations) {
@@ -2163,10 +2089,9 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
(*this->BuildFileStream) << firstString; (*this->BuildFileStream) << firstString;
firstString = ""; // only do firstString once firstString = ""; // only do firstString once
hasFlags = true; hasFlags = true;
this->WriteString("<DependentUpon>", 3);
const std::string& fileName = source->GetFullPath(); const std::string& fileName = source->GetFullPath();
std::string xamlFileName = fileName.substr(0, fileName.find_last_of(".")); std::string xamlFileName = fileName.substr(0, fileName.find_last_of("."));
(*this->BuildFileStream) << xamlFileName << "</DependentUpon>\n"; this->WriteElem("DependentUpon", xamlFileName, 3);
} }
if (this->ProjectType == csproj) { if (this->ProjectType == csproj) {
std::string f = source->GetFullPath(); std::string f = source->GetFullPath();
@@ -2214,9 +2139,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
} }
this->WriteString("<PropertyGroup>\n", 1); this->WriteString("<PropertyGroup>\n", 1);
this->WriteString("<_ProjectFileVersion>10.0.20506.1" this->WriteElem("_ProjectFileVersion", "10.0.20506.1", 2);
"</_ProjectFileVersion>\n",
2);
for (std::string const& config : this->Configurations) { for (std::string const& config : this->Configurations) {
if (ttype >= cmStateEnums::UTILITY) { if (ttype >= cmStateEnums::UTILITY) {
this->WritePlatformConfigTag("IntDir", config, 2); this->WritePlatformConfigTag("IntDir", config, 2);
@@ -2521,9 +2444,7 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
if (this->NsightTegra) { if (this->NsightTegra) {
if (const char* processMax = if (const char* processMax =
this->GeneratorTarget->GetProperty("ANDROID_PROCESS_MAX")) { this->GeneratorTarget->GetProperty("ANDROID_PROCESS_MAX")) {
this->WriteString("<ProcessMax>", 3); this->WriteElemEscapeXML("ProcessMax", processMax, 3);
*this->BuildFileStream << cmVS10EscapeXML(processMax)
<< "</ProcessMax>\n";
} }
} }
@@ -2531,12 +2452,9 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
cmsys::RegularExpression clangToolset("v[0-9]+_clang_.*"); cmsys::RegularExpression clangToolset("v[0-9]+_clang_.*");
const char* toolset = this->GlobalGenerator->GetPlatformToolset(); const char* toolset = this->GlobalGenerator->GetPlatformToolset();
if (toolset && clangToolset.find(toolset)) { if (toolset && clangToolset.find(toolset)) {
this->WriteString("<ObjectFileName>" this->WriteElem("ObjectFileName", "$(IntDir)%(filename).obj", 3);
"$(IntDir)%(filename).obj"
"</ObjectFileName>\n",
3);
} else { } else {
this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3); this->WriteElem("ObjectFileName", "$(IntDir)", 3);
} }
// If not in debug mode, write the DebugInformationFormat field // If not in debug mode, write the DebugInformationFormat field
@@ -2552,9 +2470,7 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
std::string pdb = this->GeneratorTarget->GetCompilePDBPath(configName); std::string pdb = this->GeneratorTarget->GetCompilePDBPath(configName);
if (!pdb.empty()) { if (!pdb.empty()) {
ConvertToWindowsSlash(pdb); ConvertToWindowsSlash(pdb);
this->WriteString("<ProgramDataBaseFileName>", 3); this->WriteElemEscapeXML("ProgramDataBaseFileName", pdb, 3);
*this->BuildFileStream << cmVS10EscapeXML(pdb)
<< "</ProgramDataBaseFileName>\n";
} }
} }
@@ -2973,9 +2889,7 @@ void cmVisualStudio10TargetGenerator::WriteLibOptions(
if (this->GlobalGenerator->TargetsWindowsPhone() || if (this->GlobalGenerator->TargetsWindowsPhone() ||
this->GlobalGenerator->TargetsWindowsStore()) { this->GlobalGenerator->TargetsWindowsStore()) {
this->WriteString("<Link>\n", 2); this->WriteString("<Link>\n", 2);
this->WriteString("<GenerateWindowsMetadata>false" this->WriteElem("GenerateWindowsMetadata", "false", 3);
"</GenerateWindowsMetadata>\n",
3);
this->WriteString("</Link>\n", 2); this->WriteString("</Link>\n", 2);
} }
} }
@@ -3026,32 +2940,28 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
{ {
std::string antBuildPath = rootDir; std::string antBuildPath = rootDir;
this->WriteString("<AntBuild>\n", 2); this->WriteString("<AntBuild>\n", 2);
this->WriteString("<AntBuildPath>", 3);
ConvertToWindowsSlash(antBuildPath); ConvertToWindowsSlash(antBuildPath);
(*this->BuildFileStream) << cmVS10EscapeXML(antBuildPath) this->WriteElemEscapeXML("AntBuildPath", antBuildPath, 3);
<< "</AntBuildPath>\n";
} }
if (this->GeneratorTarget->GetPropertyAsBool("ANDROID_SKIP_ANT_STEP")) { if (this->GeneratorTarget->GetPropertyAsBool("ANDROID_SKIP_ANT_STEP")) {
this->WriteString("<SkipAntStep>true</SkipAntStep>\n", 3); this->WriteElem("SkipAntStep", "true", 3);
} }
if (this->GeneratorTarget->GetPropertyAsBool("ANDROID_PROGUARD")) { if (this->GeneratorTarget->GetPropertyAsBool("ANDROID_PROGUARD")) {
this->WriteString("<EnableProGuard>true</EnableProGuard>\n", 3); this->WriteElem("EnableProGuard", "true", 3);
} }
if (const char* proGuardConfigLocation = if (const char* proGuardConfigLocation =
this->GeneratorTarget->GetProperty("ANDROID_PROGUARD_CONFIG_PATH")) { this->GeneratorTarget->GetProperty("ANDROID_PROGUARD_CONFIG_PATH")) {
this->WriteString("<ProGuardConfigLocation>", 3); this->WriteElemEscapeXML("ProGuardConfigLocation", proGuardConfigLocation,
(*this->BuildFileStream) << cmVS10EscapeXML(proGuardConfigLocation) 3);
<< "</ProGuardConfigLocation>\n";
} }
if (const char* securePropertiesLocation = if (const char* securePropertiesLocation =
this->GeneratorTarget->GetProperty("ANDROID_SECURE_PROPS_PATH")) { this->GeneratorTarget->GetProperty("ANDROID_SECURE_PROPS_PATH")) {
this->WriteString("<SecurePropertiesLocation>", 3); this->WriteElemEscapeXML("SecurePropertiesLocation",
(*this->BuildFileStream) << cmVS10EscapeXML(securePropertiesLocation) securePropertiesLocation, 3);
<< "</SecurePropertiesLocation>\n";
} }
if (const char* nativeLibDirectoriesExpression = if (const char* nativeLibDirectoriesExpression =
@@ -3061,9 +2971,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
ge.Parse(nativeLibDirectoriesExpression); ge.Parse(nativeLibDirectoriesExpression);
std::string nativeLibDirs = std::string nativeLibDirs =
cge->Evaluate(this->LocalGenerator, configName); cge->Evaluate(this->LocalGenerator, configName);
this->WriteString("<NativeLibDirectories>", 3); this->WriteElemEscapeXML("NativeLibDirectories", nativeLibDirs, 3);
(*this->BuildFileStream) << cmVS10EscapeXML(nativeLibDirs)
<< "</NativeLibDirectories>\n";
} }
if (const char* nativeLibDependenciesExpression = if (const char* nativeLibDependenciesExpression =
@@ -3074,16 +2982,12 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
ge.Parse(nativeLibDependenciesExpression); ge.Parse(nativeLibDependenciesExpression);
std::string nativeLibDeps = std::string nativeLibDeps =
cge->Evaluate(this->LocalGenerator, configName); cge->Evaluate(this->LocalGenerator, configName);
this->WriteString("<NativeLibDependencies>", 3); this->WriteElemEscapeXML("NativeLibDependencies", nativeLibDeps, 3);
(*this->BuildFileStream) << cmVS10EscapeXML(nativeLibDeps)
<< "</NativeLibDependencies>\n";
} }
if (const char* javaSourceDir = if (const char* javaSourceDir =
this->GeneratorTarget->GetProperty("ANDROID_JAVA_SOURCE_DIR")) { this->GeneratorTarget->GetProperty("ANDROID_JAVA_SOURCE_DIR")) {
this->WriteString("<JavaSourceDir>", 3); this->WriteElemEscapeXML("JavaSourceDir", javaSourceDir, 3);
(*this->BuildFileStream) << cmVS10EscapeXML(javaSourceDir)
<< "</JavaSourceDir>\n";
} }
if (const char* jarDirectoriesExpression = if (const char* jarDirectoriesExpression =
@@ -3093,31 +2997,23 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
ge.Parse(jarDirectoriesExpression); ge.Parse(jarDirectoriesExpression);
std::string jarDirectories = std::string jarDirectories =
cge->Evaluate(this->LocalGenerator, configName); cge->Evaluate(this->LocalGenerator, configName);
this->WriteString("<JarDirectories>", 3); this->WriteElemEscapeXML("JarDirectories", jarDirectories, 3);
(*this->BuildFileStream) << cmVS10EscapeXML(jarDirectories)
<< "</JarDirectories>\n";
} }
if (const char* jarDeps = if (const char* jarDeps =
this->GeneratorTarget->GetProperty("ANDROID_JAR_DEPENDENCIES")) { this->GeneratorTarget->GetProperty("ANDROID_JAR_DEPENDENCIES")) {
this->WriteString("<JarDependencies>", 3); this->WriteElemEscapeXML("JarDependencies", jarDeps, 3);
(*this->BuildFileStream) << cmVS10EscapeXML(jarDeps)
<< "</JarDependencies>\n";
} }
if (const char* assetsDirectories = if (const char* assetsDirectories =
this->GeneratorTarget->GetProperty("ANDROID_ASSETS_DIRECTORIES")) { this->GeneratorTarget->GetProperty("ANDROID_ASSETS_DIRECTORIES")) {
this->WriteString("<AssetsDirectories>", 3); this->WriteElemEscapeXML("AssetsDirectories", assetsDirectories, 3);
(*this->BuildFileStream) << cmVS10EscapeXML(assetsDirectories)
<< "</AssetsDirectories>\n";
} }
{ {
std::string manifest_xml = rootDir + "/AndroidManifest.xml"; std::string manifest_xml = rootDir + "/AndroidManifest.xml";
ConvertToWindowsSlash(manifest_xml); ConvertToWindowsSlash(manifest_xml);
this->WriteString("<AndroidManifestLocation>", 3); this->WriteElemEscapeXML("AndroidManifestLocation", manifest_xml, 3);
(*this->BuildFileStream) << cmVS10EscapeXML(manifest_xml)
<< "</AndroidManifestLocation>\n";
} }
if (const char* antAdditionalOptions = if (const char* antAdditionalOptions =
@@ -3335,7 +3231,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
cmGeneratorTarget::ModuleDefinitionInfo const* mdi = cmGeneratorTarget::ModuleDefinitionInfo const* mdi =
this->GeneratorTarget->GetModuleDefinitionInfo(config); this->GeneratorTarget->GetModuleDefinitionInfo(config);
if (mdi && !mdi->DefFile.empty()) { if (mdi && !mdi->DefFile.empty()) {
linkOptions.AddFlag("ModuleDefinitionFile", mdi->DefFile.c_str()); linkOptions.AddFlag("ModuleDefinitionFile", mdi->DefFile);
} }
linkOptions.AppendFlag("IgnoreSpecificDefaultLibraries", linkOptions.AppendFlag("IgnoreSpecificDefaultLibraries",
"%(IgnoreSpecificDefaultLibraries)"); "%(IgnoreSpecificDefaultLibraries)");
@@ -3418,8 +3314,7 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(
if (!this->GlobalGenerator->NeedLinkLibraryDependencies( if (!this->GlobalGenerator->NeedLinkLibraryDependencies(
this->GeneratorTarget)) { this->GeneratorTarget)) {
this->WriteString("<ProjectReference>\n", 2); this->WriteString("<ProjectReference>\n", 2);
this->WriteString( this->WriteElem("LinkLibraryDependencies", "false", 3);
"<LinkLibraryDependencies>false</LinkLibraryDependencies>\n", 3);
this->WriteString("</ProjectReference>\n", 2); this->WriteString("</ProjectReference>\n", 2);
} }
} }
@@ -3513,15 +3408,11 @@ void cmVisualStudio10TargetGenerator::WriteMidlOptions(
this->WriteString("%(AdditionalIncludeDirectories)" this->WriteString("%(AdditionalIncludeDirectories)"
"</AdditionalIncludeDirectories>\n", "</AdditionalIncludeDirectories>\n",
0); 0);
this->WriteString("<OutputDirectory>$(ProjectDir)/$(IntDir)" this->WriteElem("OutputDirectory", "$(ProjectDir)/$(IntDir)", 3);
"</OutputDirectory>\n", this->WriteElem("HeaderFileName", "%(Filename).h", 3);
3); this->WriteElem("TypeLibraryName", "%(Filename).tlb", 3);
this->WriteString("<HeaderFileName>%(Filename).h</HeaderFileName>\n", 3); this->WriteElem("InterfaceIdentifierFileName", "%(Filename)_i.c", 3);
this->WriteString("<TypeLibraryName>%(Filename).tlb</TypeLibraryName>\n", 3); this->WriteElem("ProxyFileName", "%(Filename)_p.c", 3);
this->WriteString("<InterfaceIdentifierFileName>"
"%(Filename)_i.c</InterfaceIdentifierFileName>\n",
3);
this->WriteString("<ProxyFileName>%(Filename)_p.c</ProxyFileName>\n", 3);
this->WriteString("</Midl>\n", 2); this->WriteString("</Midl>\n", 2);
} }
@@ -3613,8 +3504,7 @@ void cmVisualStudio10TargetGenerator::WriteEvent(
} }
comment = cmVS10EscapeComment(comment); comment = cmVS10EscapeComment(comment);
if (this->ProjectType != csproj) { if (this->ProjectType != csproj) {
this->WriteString("<Message>", 3); this->WriteElemEscapeXML("Message", comment, 3);
(*this->BuildFileStream) << cmVS10EscapeXML(comment) << "</Message>\n";
this->WriteString("<Command>", 3); this->WriteString("<Command>", 3);
} else { } else {
std::string strippedComment = comment; std::string strippedComment = comment;
@@ -3667,17 +3557,13 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences()
} }
ConvertToWindowsSlash(path); ConvertToWindowsSlash(path);
(*this->BuildFileStream) << cmVS10EscapeXML(path) << "\">\n"; (*this->BuildFileStream) << cmVS10EscapeXML(path) << "\">\n";
this->WriteString("<Project>", 3); this->WriteElem("Project",
(*this->BuildFileStream) << "{" << this->GlobalGenerator->GetGUID(name) "{" + this->GlobalGenerator->GetGUID(name) + "}", 3);
<< "}"; this->WriteElem("Name", name, 3);
(*this->BuildFileStream) << "</Project>\n";
this->WriteString("<Name>", 3);
(*this->BuildFileStream) << name << "</Name>\n";
this->WriteDotNetReferenceCustomTags(name); this->WriteDotNetReferenceCustomTags(name);
if (csproj == this->ProjectType) { if (csproj == this->ProjectType) {
if (!this->GlobalGenerator->TargetCanBeReferenced(dt)) { if (!this->GlobalGenerator->TargetCanBeReferenced(dt)) {
this->WriteString( this->WriteElem("ReferenceOutputAssembly", "false", 3);
"<ReferenceOutputAssembly>false</ReferenceOutputAssembly>\n", 3);
} }
} }
this->WriteString("</ProjectReference>\n", 2); this->WriteString("</ProjectReference>\n", 2);
@@ -3807,14 +3693,12 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile()
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
ConvertToWindowsSlash(artifactDir); ConvertToWindowsSlash(artifactDir);
this->WriteString("<PropertyGroup>\n", 1); this->WriteString("<PropertyGroup>\n", 1);
this->WriteString("<AppxPackageArtifactsDir>", 2); this->WriteElemEscapeXML("AppxPackageArtifactsDir", artifactDir + "\\",
(*this->BuildFileStream) << cmVS10EscapeXML(artifactDir) 2);
<< "\\</AppxPackageArtifactsDir>\n";
this->WriteString("<ProjectPriFullPath>", 2);
std::string resourcePriFile = std::string resourcePriFile =
this->DefaultArtifactDir + "/resources.pri"; this->DefaultArtifactDir + "/resources.pri";
ConvertToWindowsSlash(resourcePriFile); ConvertToWindowsSlash(resourcePriFile);
(*this->BuildFileStream) << resourcePriFile << "</ProjectPriFullPath>\n"; this->WriteElem("ProjectPriFullPath", resourcePriFile, 2);
// If we are missing files and we don't have a certificate and // If we are missing files and we don't have a certificate and
// aren't targeting WP8.0, add a default certificate // aren't targeting WP8.0, add a default certificate
@@ -3828,26 +3712,18 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile()
this->AddedFiles.push_back(pfxFile); this->AddedFiles.push_back(pfxFile);
} }
this->WriteString("<", 2); this->WriteElem("PackageCertificateKeyFile", pfxFile, 2);
(*this->BuildFileStream) << "PackageCertificateKeyFile>" << pfxFile
<< "</PackageCertificateKeyFile>\n";
std::string thumb = cmSystemTools::ComputeCertificateThumbprint(pfxFile); std::string thumb = cmSystemTools::ComputeCertificateThumbprint(pfxFile);
if (!thumb.empty()) { if (!thumb.empty()) {
this->WriteString("<PackageCertificateThumbprint>", 2); this->WriteElem("PackageCertificateThumbprint", thumb, 2);
(*this->BuildFileStream) << thumb
<< "</PackageCertificateThumbprint>\n";
} }
this->WriteString("</PropertyGroup>\n", 1); this->WriteString("</PropertyGroup>\n", 1);
} else if (!pfxFile.empty()) { } else if (!pfxFile.empty()) {
this->WriteString("<PropertyGroup>\n", 1); this->WriteString("<PropertyGroup>\n", 1);
this->WriteString("<", 2); this->WriteElem("PackageCertificateKeyFile", pfxFile, 2);
(*this->BuildFileStream) << "PackageCertificateKeyFile>" << pfxFile
<< "</PackageCertificateKeyFile>\n";
std::string thumb = cmSystemTools::ComputeCertificateThumbprint(pfxFile); std::string thumb = cmSystemTools::ComputeCertificateThumbprint(pfxFile);
if (!thumb.empty()) { if (!thumb.empty()) {
this->WriteString("<PackageCertificateThumbprint>", 2); this->WriteElem("PackageCertificateThumbprint", thumb, 2);
(*this->BuildFileStream) << thumb
<< "</PackageCertificateThumbprint>\n";
} }
this->WriteString("</PropertyGroup>\n", 1); this->WriteString("</PropertyGroup>\n", 1);
} }
@@ -3895,45 +3771,29 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings()
bool const isWindowsStore = this->GlobalGenerator->TargetsWindowsStore(); bool const isWindowsStore = this->GlobalGenerator->TargetsWindowsStore();
std::string const& v = this->GlobalGenerator->GetSystemVersion(); std::string const& v = this->GlobalGenerator->GetSystemVersion();
if (isWindowsPhone || isWindowsStore) { if (isWindowsPhone || isWindowsStore) {
this->WriteString("<ApplicationType>", 2); this->WriteElem("ApplicationType",
(*this->BuildFileStream) (isWindowsPhone ? "Windows Phone" : "Windows Store"), 2);
<< (isWindowsPhone ? "Windows Phone" : "Windows Store") this->WriteElem("DefaultLanguage", "en-US", 2);
<< "</ApplicationType>\n";
this->WriteString("<DefaultLanguage>en-US"
"</DefaultLanguage>\n",
2);
if (cmHasLiteralPrefix(v, "10.0")) { if (cmHasLiteralPrefix(v, "10.0")) {
this->WriteString("<ApplicationTypeRevision>", 2); this->WriteElemEscapeXML("ApplicationTypeRevision", "10.0", 2);
(*this->BuildFileStream) << cmVS10EscapeXML("10.0")
<< "</ApplicationTypeRevision>\n";
// Visual Studio 14.0 is necessary for building 10.0 apps // Visual Studio 14.0 is necessary for building 10.0 apps
this->WriteString("<MinimumVisualStudioVersion>14.0" this->WriteElem("MinimumVisualStudioVersion", "14.0", 2);
"</MinimumVisualStudioVersion>\n",
2);
if (this->GeneratorTarget->GetType() < cmStateEnums::UTILITY) { if (this->GeneratorTarget->GetType() < cmStateEnums::UTILITY) {
isAppContainer = true; isAppContainer = true;
} }
} else if (v == "8.1") { } else if (v == "8.1") {
this->WriteString("<ApplicationTypeRevision>", 2); this->WriteElemEscapeXML("ApplicationTypeRevision", v, 2);
(*this->BuildFileStream) << cmVS10EscapeXML(v)
<< "</ApplicationTypeRevision>\n";
// Visual Studio 12.0 is necessary for building 8.1 apps // Visual Studio 12.0 is necessary for building 8.1 apps
this->WriteString("<MinimumVisualStudioVersion>12.0" this->WriteElem("MinimumVisualStudioVersion", "12.0", 2);
"</MinimumVisualStudioVersion>\n",
2);
if (this->GeneratorTarget->GetType() < cmStateEnums::UTILITY) { if (this->GeneratorTarget->GetType() < cmStateEnums::UTILITY) {
isAppContainer = true; isAppContainer = true;
} }
} else if (v == "8.0") { } else if (v == "8.0") {
this->WriteString("<ApplicationTypeRevision>", 2); this->WriteElemEscapeXML("ApplicationTypeRevision", v, 2);
(*this->BuildFileStream) << cmVS10EscapeXML(v)
<< "</ApplicationTypeRevision>\n";
// Visual Studio 11.0 is necessary for building 8.0 apps // Visual Studio 11.0 is necessary for building 8.0 apps
this->WriteString("<MinimumVisualStudioVersion>11.0" this->WriteElem("MinimumVisualStudioVersion", "11.0", 2);
"</MinimumVisualStudioVersion>\n",
2);
if (isWindowsStore && if (isWindowsStore &&
this->GeneratorTarget->GetType() < cmStateEnums::UTILITY) { this->GeneratorTarget->GetType() < cmStateEnums::UTILITY) {
@@ -3941,52 +3801,42 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings()
} else if (isWindowsPhone && } else if (isWindowsPhone &&
this->GeneratorTarget->GetType() == this->GeneratorTarget->GetType() ==
cmStateEnums::EXECUTABLE) { cmStateEnums::EXECUTABLE) {
this->WriteString("<XapOutputs>true</XapOutputs>\n", 2); this->WriteElem("XapOutputs", "true", 2);
this->WriteString("<XapFilename>", 2); this->WriteElem("XapFilename", cmVS10EscapeXML(this->Name) +
(*this->BuildFileStream) "_$(Configuration)_$(Platform).xap",
<< cmVS10EscapeXML(this->Name) 2);
<< "_$(Configuration)_$(Platform).xap</XapFilename>\n";
} }
} }
} }
if (isAppContainer) { if (isAppContainer) {
this->WriteString("<AppContainerApplication>true" this->WriteElem("AppContainerApplication", "true", 2);
"</AppContainerApplication>\n",
2);
} else if (this->Platform == "ARM64") { } else if (this->Platform == "ARM64") {
this->WriteString("<WindowsSDKDesktopARM64Support>true" this->WriteElem("WindowsSDKDesktopARM64Support", "true", 2);
"</WindowsSDKDesktopARM64Support>\n",
2);
} else if (this->Platform == "ARM") { } else if (this->Platform == "ARM") {
this->WriteString("<WindowsSDKDesktopARMSupport>true" this->WriteElem("WindowsSDKDesktopARMSupport", "true", 2);
"</WindowsSDKDesktopARMSupport>\n",
2);
} }
std::string const& targetPlatformVersion = std::string const& targetPlatformVersion =
gg->GetWindowsTargetPlatformVersion(); gg->GetWindowsTargetPlatformVersion();
if (!targetPlatformVersion.empty()) { if (!targetPlatformVersion.empty()) {
this->WriteString("<WindowsTargetPlatformVersion>", 2); this->WriteElemEscapeXML("WindowsTargetPlatformVersion",
(*this->BuildFileStream) << cmVS10EscapeXML(targetPlatformVersion) targetPlatformVersion, 2);
<< "</WindowsTargetPlatformVersion>\n";
} }
const char* targetPlatformMinVersion = this->GeneratorTarget->GetProperty( const char* targetPlatformMinVersion = this->GeneratorTarget->GetProperty(
"VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION"); "VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION");
if (targetPlatformMinVersion) { if (targetPlatformMinVersion) {
this->WriteString("<WindowsTargetPlatformMinVersion>", 2); this->WriteElemEscapeXML("WindowsTargetPlatformMinVersion",
(*this->BuildFileStream) << cmVS10EscapeXML(targetPlatformMinVersion) targetPlatformMinVersion, 2);
<< "</WindowsTargetPlatformMinVersion>\n";
} else if (isWindowsStore && cmHasLiteralPrefix(v, "10.0")) { } else if (isWindowsStore && cmHasLiteralPrefix(v, "10.0")) {
// If the min version is not set, then use the TargetPlatformVersion // If the min version is not set, then use the TargetPlatformVersion
if (!targetPlatformVersion.empty()) { if (!targetPlatformVersion.empty()) {
this->WriteString("<WindowsTargetPlatformMinVersion>", 2); this->WriteElemEscapeXML("WindowsTargetPlatformMinVersion",
(*this->BuildFileStream) << cmVS10EscapeXML(targetPlatformVersion) targetPlatformVersion, 2);
<< "</WindowsTargetPlatformMinVersion>\n";
} }
} }
// Added IoT Startup Task support // Added IoT Startup Task support
if (this->GeneratorTarget->GetPropertyAsBool("VS_IOT_STARTUP_TASK")) { if (this->GeneratorTarget->GetPropertyAsBool("VS_IOT_STARTUP_TASK")) {
this->WriteString("<ContainsStartupTask>true</ContainsStartupTask>\n", 2); this->WriteElem("ContainsStartupTask", "true", 2);
} }
} }
@@ -4117,7 +3967,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80()
ConvertToWindowsSlash(sourceFile); ConvertToWindowsSlash(sourceFile);
this->WriteString("<Xml Include=\"", 2); this->WriteString("<Xml Include=\"", 2);
(*this->BuildFileStream) << cmVS10EscapeXML(sourceFile) << "\">\n"; (*this->BuildFileStream) << cmVS10EscapeXML(sourceFile) << "\">\n";
this->WriteString("<SubType>Designer</SubType>\n", 3); this->WriteElem("SubType", "Designer", 3);
this->WriteString("</Xml>\n", 2); this->WriteString("</Xml>\n", 2);
this->AddedFiles.push_back(sourceFile); this->AddedFiles.push_back(sourceFile);
@@ -4395,7 +4245,7 @@ void cmVisualStudio10TargetGenerator::WriteCommonMissingFiles(
ConvertToWindowsSlash(sourceFile); ConvertToWindowsSlash(sourceFile);
this->WriteString("<AppxManifest Include=\"", 2); this->WriteString("<AppxManifest Include=\"", 2);
(*this->BuildFileStream) << cmVS10EscapeXML(sourceFile) << "\">\n"; (*this->BuildFileStream) << cmVS10EscapeXML(sourceFile) << "\">\n";
this->WriteString("<SubType>Designer</SubType>\n", 3); this->WriteElem("SubType", "Designer", 3);
this->WriteString("</AppxManifest>\n", 2); this->WriteString("</AppxManifest>\n", 2);
this->AddedFiles.push_back(sourceFile); this->AddedFiles.push_back(sourceFile);

View File

@@ -55,6 +55,10 @@ private:
std::string ConvertPath(std::string const& path, bool forceRelative); std::string ConvertPath(std::string const& path, bool forceRelative);
void WriteString(const char* line, int indentLevel); void WriteString(const char* line, int indentLevel);
void WriteElem(const char* tag, const char* val, int indentLevel);
void WriteElem(const char* tag, std::string const& val, int indentLevel);
void WriteElemEscapeXML(const char* tag, std::string const& val,
int indentLevel);
void WriteProjectConfigurations(); void WriteProjectConfigurations();
void WriteProjectConfigurationValues(); void WriteProjectConfigurationValues();
void WriteMSToolConfigurationValues(std::string const& config); void WriteMSToolConfigurationValues(std::string const& config);