diff options
author | Miguel Costa <miguel.costa@qt.io> | 2019-07-08 16:16:15 +0200 |
---|---|---|
committer | Miguel Costa <miguel.costa@qt.io> | 2019-08-05 09:24:17 +0000 |
commit | cff73364c3b632a84ab3c7ca2f2ea32b563910ce (patch) | |
tree | 41d0c87644f3322aa29709bae3d58529511cd7fc /src/common.tt | |
parent | 3e7709dcf5927f5674cccc253ecefae3ab758166 (diff) |
Add C++ compiler properties to Qt tools
Qt tools that generate C++ code will now include all properties
available in the C++ compiler property page, allowing the default values
of the C++ compiler properties to be used directly by the Qt tools,
without the need to actively monitor changes to maintain properties
synchronized. It is also possible to extend (i.e. append to) or override
(i.e. replace) the default C++ property values for Qt tools.
Task-number: QTVSADDINBUG-575
Task-number: QTVSADDINBUG-632
Change-Id: I456ee6b4926cd11c83c845656a617a4fb204542a
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/common.tt')
-rw-r--r-- | src/common.tt | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/common.tt b/src/common.tt index bc5342e8..d8edd875 100644 --- a/src/common.tt +++ b/src/common.tt @@ -1,7 +1,14 @@ <#@template hostspecific="true" language="C#" #> <#@assembly Name="System.Core" #> +<#@assembly Name="System.Xml" #> +<#@assembly Name="System.Xml.Linq" #> <#@import namespace="System" #> +<#@import namespace="System.Collections.Generic" #> <#@import namespace="System.IO" #> +<#@import namespace="System.Linq" #> +<#@import namespace="System.Text" #> +<#@import namespace="System.Xml" #> +<#@import namespace="System.Xml.Linq" #> <#@assembly name="EnvDTE" #> <#@import namespace="EnvDTE" #> <# @@ -39,8 +46,46 @@ VS_VERSION.StartsWith("15.") ? "2017" : VS_VERSION.StartsWith("14.") ? "2015" : VS_VERSION.StartsWith("12.") ? "2013" : "????"; + string VS_EDITION = Dte.Edition; + string VC_TARGETS_PATH = Path.Combine( + Environment.GetEnvironmentVariable("ProgramFiles(x86)"), + VS_VERSION.StartsWith("16.") ? + @"Microsoft Visual Studio\2019\" + VS_EDITION + @"\MSBuild\Microsoft\VC\v160" : + VS_VERSION.StartsWith("15.") ? + @"Microsoft Visual Studio\2017\" + VS_EDITION + @"\Common7\IDE\VC\VCTargets" : + VS_VERSION.StartsWith("14.") ? + @"MSBuild\Microsoft.Cpp\v4.0\V140" : + VS_VERSION.StartsWith("12.") ? + @"MSBuild\Microsoft.Cpp\v4.0\V120" : null); /***************************************************************************/ string WARNING_GENERATED_FILE = "This file was generated automatically."; string XML_COMMENT_BEGIN = "<!--"; string XML_COMMENT_END = "-->"; + + var XmlLoad = new Func<string, XElement>(xmlText => + { + XDocument xmlDoc = null; + using (var reader = XmlReader.Create(new StringReader(xmlText))) + xmlDoc = XDocument.Load(reader); + var xmlRoot = xmlDoc.Root; + xmlRoot.Descendants().ToList().ForEach(x => x.Name = x.Name.LocalName); + return xmlRoot; + }); + + var XmlPrint = new Func<IEnumerable<XElement>, string>(x => + { + var xmlOut = new StringBuilder(); + var xmlOutSettings = new XmlWriterSettings() + { + ConformanceLevel = ConformanceLevel.Fragment, + OmitXmlDeclaration = true, + Indent = true, + }; + using (var xmlOutWriter = XmlWriter.Create(xmlOut, xmlOutSettings)) { + foreach (var y in x) + y.WriteTo(xmlOutWriter); + } + return xmlOut.ToString(); + }); + #>
\ No newline at end of file |