From f063a914c649b1dfbcd1a02d381b4e94ad01ceaa Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 29 Jul 2014 14:41:03 -0400 Subject: VS: Re-arrange WriteExtraSource to support tool configuration Add a code path to write the tool open and close elements separately so that we can add content in between to configure it. --- Source/cmVisualStudio10TargetGenerator.cxx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 1e9e8e8..3dadd52 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1018,6 +1018,7 @@ void cmVisualStudio10TargetGenerator::WriteHeaderSource(cmSourceFile const* sf) void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) { + bool toolHasSettings = false; std::string tool = "None"; std::string const& ext = sf->GetExtension(); if(ext == "appxmanifest") @@ -1033,7 +1034,18 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) { tool = "XML"; } - this->WriteSource(tool, sf); + + if(toolHasSettings) + { + this->WriteSource(tool, sf, ">\n"); + + this->WriteString("BuildFileStream) << tool << ">\n"; + } + else + { + this->WriteSource(tool, sf); + } } void cmVisualStudio10TargetGenerator::WriteSource( -- cgit v0.12 From 9b4dc2ad4a82b233520015fdc5cbf5df1ed540f7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 29 Jul 2014 14:03:35 -0400 Subject: VS: Add a source file property to mark content for Windows App deployment Create a VS_DEPLOYMENT_CONTENT source file property, supporting generator expressions, to compute whether a source file should be marked as DeploymentContent or ExcludedFromBuild in Windows Phone and Windows Store projects. Inspired-by: Minmin Gong --- Help/manual/cmake-properties.7.rst | 1 + Help/prop_sf/VS_DEPLOYMENT_CONTENT.rst | 11 ++++++++ Source/cmVisualStudio10TargetGenerator.cxx | 40 ++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 Help/prop_sf/VS_DEPLOYMENT_CONTENT.rst diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 17dadc2..3b7436a 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -287,6 +287,7 @@ Properties on Source Files /prop_sf/OBJECT_DEPENDS /prop_sf/OBJECT_OUTPUTS /prop_sf/SYMBOLIC + /prop_sf/VS_DEPLOYMENT_CONTENT /prop_sf/WRAP_EXCLUDE /prop_sf/XCODE_EXPLICIT_FILE_TYPE /prop_sf/XCODE_LAST_KNOWN_FILE_TYPE diff --git a/Help/prop_sf/VS_DEPLOYMENT_CONTENT.rst b/Help/prop_sf/VS_DEPLOYMENT_CONTENT.rst new file mode 100644 index 0000000..9fb3ba3 --- /dev/null +++ b/Help/prop_sf/VS_DEPLOYMENT_CONTENT.rst @@ -0,0 +1,11 @@ +VS_DEPLOYMENT_CONTENT +--------------------- + +Mark a source file as content for deployment with a Windows Phone or +Windows Store application when built with a Visual Studio generator. +The value must evaluate to either ``1`` or ``0`` and may use +:manual:`generator expressions ` +to make the choice based on the build configuration. +The ``.vcxproj`` file entry for the source file will be +marked either ``DeploymentContent`` or ``ExcludedFromBuild`` +for values ``1`` and ``0``, respectively. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 3dadd52..01a3b37 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1035,10 +1035,50 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) tool = "XML"; } + std::string deployContent; + if(this->GlobalGenerator->TargetsWindowsPhone() || + this->GlobalGenerator->TargetsWindowsStore()) + { + const char* content = sf->GetProperty("VS_DEPLOYMENT_CONTENT"); + if(content && *content) + { + toolHasSettings = true; + deployContent = content; + } + } + if(toolHasSettings) { this->WriteSource(tool, sf, ">\n"); + if(!deployContent.empty()) + { + std::vector const* configs = + this->GlobalGenerator->GetConfigurations(); + cmGeneratorExpression ge; + cmsys::auto_ptr cge = + ge.Parse(deployContent); + for(size_t i = 0; i != configs->size(); ++i) + { + if(0 == strcmp(cge->Evaluate(this->Makefile, (*configs)[i]), "1")) + { + this->WriteString("BuildFileStream) << (*configs)[i] << "|" + << this->Platform << "'\">true"; + this->WriteString("\n", 0); + } + else + { + this->WriteString("BuildFileStream) << (*configs)[i] << "|" + << this->Platform << "'\">true"; + this->WriteString("\n", 0); + } + } + } + this->WriteString("BuildFileStream) << tool << ">\n"; } -- cgit v0.12 From 6fe770e163daf005cd151798c18b89ad50c17125 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 29 Jul 2014 14:48:20 -0400 Subject: VS: Add a source file property to set the hlsl shader type Create a VS_SHADER_TYPE source file property. Inspired-by: Gilles Khouzam --- Help/manual/cmake-properties.7.rst | 1 + Help/prop_sf/VS_SHADER_TYPE.rst | 4 ++++ Source/cmVisualStudio10TargetGenerator.cxx | 17 +++++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 Help/prop_sf/VS_SHADER_TYPE.rst diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 3b7436a..81b00fa 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -288,6 +288,7 @@ Properties on Source Files /prop_sf/OBJECT_OUTPUTS /prop_sf/SYMBOLIC /prop_sf/VS_DEPLOYMENT_CONTENT + /prop_sf/VS_SHADER_TYPE /prop_sf/WRAP_EXCLUDE /prop_sf/XCODE_EXPLICIT_FILE_TYPE /prop_sf/XCODE_LAST_KNOWN_FILE_TYPE diff --git a/Help/prop_sf/VS_SHADER_TYPE.rst b/Help/prop_sf/VS_SHADER_TYPE.rst new file mode 100644 index 0000000..6880256 --- /dev/null +++ b/Help/prop_sf/VS_SHADER_TYPE.rst @@ -0,0 +1,4 @@ +VS_SHADER_TYPE +-------------- + +Set the VS shader type of a ``.hlsl`` source file. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 01a3b37..6989c51 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1020,11 +1020,22 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) { bool toolHasSettings = false; std::string tool = "None"; + std::string shaderType; std::string const& ext = sf->GetExtension(); if(ext == "appxmanifest") { tool = "AppxManifest"; } + else if(ext == "hlsl") + { + tool = "FXCompile"; + // Figure out the type of shader compiler to use. + if(const char* st = sf->GetProperty("VS_SHADER_TYPE")) + { + shaderType = st; + toolHasSettings = true; + } + } else if(ext == "jpg" || ext == "png") { @@ -1078,6 +1089,12 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) } } } + if(!shaderType.empty()) + { + this->WriteString("", 3); + (*this->BuildFileStream) << cmVS10EscapeXML(shaderType) + << "\n"; + } this->WriteString("BuildFileStream) << tool << ">\n"; -- cgit v0.12 From aa21001bd3c723f79e74407a2ba315d5988804a0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 6 Aug 2014 09:35:24 -0400 Subject: Help: Add notes for topic 'vs-special-source-file-properties' --- Help/release/dev/vs-special-source-file-properties.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Help/release/dev/vs-special-source-file-properties.rst diff --git a/Help/release/dev/vs-special-source-file-properties.rst b/Help/release/dev/vs-special-source-file-properties.rst new file mode 100644 index 0000000..166c4b3 --- /dev/null +++ b/Help/release/dev/vs-special-source-file-properties.rst @@ -0,0 +1,11 @@ +vs-special-source-file-properties +--------------------------------- + +* A :prop_sf:`VS_DEPLOYMENT_CONTENT` source file property was added + to tell the Visual Studio generators to mark content for deployment + in Windows Phone and Windows Store projects. + +* The Visual Studio generators learned to treat ``.hlsl`` source + files as High Level Shading Language sources (using ``FXCompile`` + in ``.vcxproj`` files). A :prop_sf:`VS_SHADER_TYPE` source file + property was added to specify the Shader Type. -- cgit v0.12