diff options
20 files changed, 100 insertions, 449 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index c9c6938..4709194 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -488,16 +488,6 @@ std::string cmGlobalVisualStudio10Generator::SelectWindowsCEToolset() const return ""; } -void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout) -{ - fout << "Microsoft Visual Studio Solution File, Format Version 11.00\n"; - if (this->ExpressEdition) { - fout << "# Visual C++ Express 2010\n"; - } else { - fout << "# Visual Studio 2010\n"; - } -} - ///! Create a local generator appropriate to this Global Generator cmLocalGenerator* cmGlobalVisualStudio10Generator::CreateLocalGenerator( cmMakefile* mf) @@ -1024,6 +1014,27 @@ std::string cmGlobalVisualStudio10Generator::Encoding() return "utf-8"; } +const char* cmGlobalVisualStudio10Generator::GetToolsVersion() const +{ + switch (this->Version) { + case cmGlobalVisualStudioGenerator::VS9: + case cmGlobalVisualStudioGenerator::VS10: + case cmGlobalVisualStudioGenerator::VS11: + return "4.0"; + + // in Visual Studio 2013 they detached the MSBuild tools version + // from the .Net Framework version and instead made it have it's own + // version number + case cmGlobalVisualStudioGenerator::VS12: + return "12.0"; + case cmGlobalVisualStudioGenerator::VS14: + return "14.0"; + case cmGlobalVisualStudioGenerator::VS15: + return "15.0"; + } + return ""; +} + bool cmGlobalVisualStudio10Generator::IsNsightTegra() const { return !this->NsightTegraVersion.empty(); diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index dc49ded..1e72959 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -43,7 +43,6 @@ public: */ void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*, bool optional) override; - void WriteSLNHeader(std::ostream& fout) override; bool IsCudaEnabled() const { return this->CudaEnabled; } @@ -104,7 +103,7 @@ public: std::string const& sfRel); std::string Encoding() override; - virtual const char* GetToolsVersion() { return "4.0"; } + const char* GetToolsVersion() const; virtual bool IsDefaultToolset(const std::string& version) const; virtual std::string GetAuxiliaryToolset() const; @@ -140,8 +139,6 @@ protected: virtual bool SelectWindowsPhoneToolset(std::string& toolset) const; virtual bool SelectWindowsStoreToolset(std::string& toolset) const; - const char* GetIDEVersion() const override { return "10.0"; } - std::string const& GetMSBuildCommand(); cmIDEFlagTable const* LoadFlagTable(std::string const& flagTableName, diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 4cde874..499ae32 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -188,16 +188,6 @@ bool cmGlobalVisualStudio11Generator::SelectWindowsStoreToolset( toolset); } -void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout) -{ - fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; - if (this->ExpressEdition) { - fout << "# Visual Studio Express 2012 for Windows Desktop\n"; - } else { - fout << "# Visual Studio 2012\n"; - } -} - bool cmGlobalVisualStudio11Generator::UseFolderProperty() const { // Intentionally skip up to the top-level class implementation. diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index 5b089a4..6346da2 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -26,8 +26,6 @@ public: bool MatchesGeneratorName(const std::string& name) const override; - void WriteSLNHeader(std::ostream& fout) override; - protected: bool InitializeWindowsPhone(cmMakefile* mf) override; bool InitializeWindowsStore(cmMakefile* mf) override; @@ -43,7 +41,6 @@ protected: bool IsWindowsPhoneToolsetInstalled() const; bool IsWindowsStoreToolsetInstalled() const; - const char* GetIDEVersion() const override { return "11.0"; } bool UseFolderProperty() const override; static std::set<std::string> GetInstalledWindowsCESDKs(); diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 3be7d24..2cec48c 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -186,16 +186,6 @@ bool cmGlobalVisualStudio12Generator::SelectWindowsStoreToolset( toolset); } -void cmGlobalVisualStudio12Generator::WriteSLNHeader(std::ostream& fout) -{ - fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; - if (this->ExpressEdition) { - fout << "# Visual Studio Express 2013 for Windows Desktop\n"; - } else { - fout << "# Visual Studio 2013\n"; - } -} - bool cmGlobalVisualStudio12Generator::IsWindowsDesktopToolsetInstalled() const { const char desktop81Key[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h index ae78de7..1b7bbc9 100644 --- a/Source/cmGlobalVisualStudio12Generator.h +++ b/Source/cmGlobalVisualStudio12Generator.h @@ -24,13 +24,6 @@ public: bool MatchesGeneratorName(const std::string& name) const override; - void WriteSLNHeader(std::ostream& fout) override; - - // in Visual Studio 2013 they detached the MSBuild tools version - // from the .Net Framework version and instead made it have it's own - // version number - const char* GetToolsVersion() override { return "12.0"; } - protected: bool ProcessGeneratorToolsetField(std::string const& key, std::string const& value) override; @@ -48,7 +41,6 @@ protected: // of the toolset is installed bool IsWindowsPhoneToolsetInstalled() const; bool IsWindowsStoreToolsetInstalled() const; - const char* GetIDEVersion() const override { return "12.0"; } private: class Factory; diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index ac969e8..a6dbc23 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -174,17 +174,6 @@ bool cmGlobalVisualStudio14Generator::SelectWindowsStoreToolset( toolset); } -void cmGlobalVisualStudio14Generator::WriteSLNHeader(std::ostream& fout) -{ - // Visual Studio 14 writes .sln format 12.00 - fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; - if (this->ExpressEdition) { - fout << "# Visual Studio Express 14 for Windows Desktop\n"; - } else { - fout << "# Visual Studio 14\n"; - } -} - bool cmGlobalVisualStudio14Generator::IsWindowsDesktopToolsetInstalled() const { const char desktop10Key[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h index 4bc430b..4be21e0 100644 --- a/Source/cmGlobalVisualStudio14Generator.h +++ b/Source/cmGlobalVisualStudio14Generator.h @@ -24,10 +24,6 @@ public: bool MatchesGeneratorName(const std::string& name) const override; - void WriteSLNHeader(std::ostream& fout) override; - - const char* GetToolsVersion() override { return "14.0"; } - protected: bool InitializeWindows(cmMakefile* mf) override; bool InitializeWindowsStore(cmMakefile* mf) override; @@ -41,7 +37,6 @@ protected: // version of the toolset. virtual std::string GetWindows10SDKMaxVersion() const; - const char* GetIDEVersion() const override { return "14.0"; } virtual bool SelectWindows10SDK(cmMakefile* mf, bool required); // Used to verify that the Desktop toolset for the current generator is diff --git a/Source/cmGlobalVisualStudio15Generator.cxx b/Source/cmGlobalVisualStudio15Generator.cxx index 4a08352..2af17e8 100644 --- a/Source/cmGlobalVisualStudio15Generator.cxx +++ b/Source/cmGlobalVisualStudio15Generator.cxx @@ -97,17 +97,6 @@ bool cmGlobalVisualStudio15Generator::MatchesGeneratorName( return false; } -void cmGlobalVisualStudio15Generator::WriteSLNHeader(std::ostream& fout) -{ - // Visual Studio 15 writes .sln format 12.00 - fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; - if (this->ExpressEdition) { - fout << "# Visual Studio Express 15 for Windows Desktop\n"; - } else { - fout << "# Visual Studio 15\n"; - } -} - bool cmGlobalVisualStudio15Generator::SetGeneratorInstance( std::string const& i, cmMakefile* mf) { diff --git a/Source/cmGlobalVisualStudio15Generator.h b/Source/cmGlobalVisualStudio15Generator.h index 68aa14f..233f3bc 100644 --- a/Source/cmGlobalVisualStudio15Generator.h +++ b/Source/cmGlobalVisualStudio15Generator.h @@ -24,10 +24,6 @@ public: bool MatchesGeneratorName(const std::string& name) const override; - void WriteSLNHeader(std::ostream& fout) override; - - const char* GetToolsVersion() override { return "15.0"; } - bool SetGeneratorInstance(std::string const& i, cmMakefile* mf) override; bool GetVSInstance(std::string& dir) const; @@ -39,8 +35,6 @@ protected: bool InitializeWindows(cmMakefile* mf) override; bool SelectWindowsStoreToolset(std::string& toolset) const override; - const char* GetIDEVersion() const override { return "15.0"; } - // Used to verify that the Desktop toolset for the current generator is // installed on the machine. bool IsWindowsDesktopToolsetInstalled() const override; diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 3be09b0..8694df2 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -217,9 +217,3 @@ void cmGlobalVisualStudio71Generator::WriteProjectConfigurations( } } } - -// output standard header for dsw file -void cmGlobalVisualStudio71Generator::WriteSLNHeader(std::ostream& fout) -{ - fout << "Microsoft Visual Studio Solution File, Format Version 8.00\n"; -} diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index b634b95..85755af 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -34,7 +34,6 @@ protected: void WriteExternalProject(std::ostream& fout, const std::string& name, const char* path, const char* typeGuid, const std::set<BT<std::string>>& depends) override; - void WriteSLNHeader(std::ostream& fout) override; // Folders are not supported by VS 7.1. bool UseFolderProperty() const override { return false; } diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 12a86f2..f092b56 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -134,7 +134,6 @@ protected: virtual void WriteSLNGlobalSections(std::ostream& fout, cmLocalGenerator* root); virtual void WriteSLNFooter(std::ostream& fout); - virtual void WriteSLNHeader(std::ostream& fout) = 0; std::string WriteUtilityDepend(const cmGeneratorTarget* target) override; virtual void WriteTargetsToSolution( diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index a21c53d..cacfa68 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -44,12 +44,8 @@ public: return !this->WindowsCEVersion.empty(); } - /** Is the installed VS an Express edition? */ - bool IsExpressEdition() const { return this->ExpressEdition; } - protected: void AddExtraIDETargets() override; - const char* GetIDEVersion() const override { return "8.0"; } std::string FindDevEnvCommand() override; @@ -77,6 +73,5 @@ protected: std::string Name; std::string WindowsCEVersion; - bool ExpressEdition; }; #endif diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index 7ac3a6f..760cce4 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -94,12 +94,6 @@ cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator( vc9Express, cmSystemTools::KeyWOW64_32); } -void cmGlobalVisualStudio9Generator::WriteSLNHeader(std::ostream& fout) -{ - fout << "Microsoft Visual Studio Solution File, Format Version 10.00\n"; - fout << "# Visual Studio 2008\n"; -} - std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory() { std::string base; diff --git a/Source/cmGlobalVisualStudio9Generator.h b/Source/cmGlobalVisualStudio9Generator.h index ee17c37..e537a3d 100644 --- a/Source/cmGlobalVisualStudio9Generator.h +++ b/Source/cmGlobalVisualStudio9Generator.h @@ -18,12 +18,6 @@ public: static cmGlobalGeneratorFactory* NewFactory(); /** - * Try to determine system information such as shared library - * extension, pthreads, byte order etc. - */ - void WriteSLNHeader(std::ostream& fout) override; - - /** * Where does this version of Visual Studio look for macros for the * current user? Returns the empty string if this version of Visual * Studio does not implement support for VB macros. @@ -36,9 +30,6 @@ public: */ std::string GetUserMacrosRegKeyBase() override; -protected: - const char* GetIDEVersion() const override { return "9.0"; } - private: class Factory; friend class Factory; diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index da3daf8..adf0a81 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -43,6 +43,77 @@ void cmGlobalVisualStudioGenerator::SetVersion(VSVersion v) this->Version = v; } +const char* cmGlobalVisualStudioGenerator::GetIDEVersion() const +{ + switch (this->Version) { + case cmGlobalVisualStudioGenerator::VS9: + return "9.0"; + case cmGlobalVisualStudioGenerator::VS10: + return "10.0"; + case cmGlobalVisualStudioGenerator::VS11: + return "11.0"; + case cmGlobalVisualStudioGenerator::VS12: + return "12.0"; + case cmGlobalVisualStudioGenerator::VS14: + return "14.0"; + case cmGlobalVisualStudioGenerator::VS15: + return "15.0"; + } + return ""; +} + +void cmGlobalVisualStudioGenerator::WriteSLNHeader(std::ostream& fout) +{ + switch (this->Version) { + case cmGlobalVisualStudioGenerator::VS9: + fout << "Microsoft Visual Studio Solution File, Format Version 10.00\n"; + fout << "# Visual Studio 2008\n"; + break; + case cmGlobalVisualStudioGenerator::VS10: + fout << "Microsoft Visual Studio Solution File, Format Version 11.00\n"; + if (this->ExpressEdition) { + fout << "# Visual C++ Express 2010\n"; + } else { + fout << "# Visual Studio 2010\n"; + } + break; + case cmGlobalVisualStudioGenerator::VS11: + fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; + if (this->ExpressEdition) { + fout << "# Visual Studio Express 2012 for Windows Desktop\n"; + } else { + fout << "# Visual Studio 2012\n"; + } + break; + case cmGlobalVisualStudioGenerator::VS12: + fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; + if (this->ExpressEdition) { + fout << "# Visual Studio Express 2013 for Windows Desktop\n"; + } else { + fout << "# Visual Studio 2013\n"; + } + break; + case cmGlobalVisualStudioGenerator::VS14: + // Visual Studio 14 writes .sln format 12.00 + fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; + if (this->ExpressEdition) { + fout << "# Visual Studio Express 14 for Windows Desktop\n"; + } else { + fout << "# Visual Studio 14\n"; + } + break; + case cmGlobalVisualStudioGenerator::VS15: + // Visual Studio 15 writes .sln format 12.00 + fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; + if (this->ExpressEdition) { + fout << "# Visual Studio Express 15 for Windows Desktop\n"; + } else { + fout << "# Visual Studio 15\n"; + } + break; + } +} + std::string cmGlobalVisualStudioGenerator::GetRegistryBase() { return cmGlobalVisualStudioGenerator::GetRegistryBase(this->GetIDEVersion()); diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index c891160..0d4491d 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -47,6 +47,9 @@ public: VSVersion GetVersion() const; void SetVersion(VSVersion v); + /** Is the installed VS an Express edition? */ + bool IsExpressEdition() const { return this->ExpressEdition; } + /** * Configure CMake's Visual Studio macros file into the user's Visual * Studio macros directory. @@ -137,7 +140,9 @@ protected: // below 8. virtual bool VSLinksDependencies() const { return true; } - virtual const char* GetIDEVersion() const = 0; + const char* GetIDEVersion() const; + + void WriteSLNHeader(std::ostream& fout); bool ComputeTargetDepends() override; class VSDependSet : public std::set<std::string> @@ -159,6 +164,7 @@ protected: protected: VSVersion Version; + bool ExpressEdition; private: virtual std::string GetVSMakeProgram() = 0; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 1bc36cc..e1bae34 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1528,7 +1528,6 @@ void cmake::CreateDefaultGlobalGenerator() const char* GeneratorName; }; static VSVersionedGenerator const vsGenerators[] = { - { "15.0", "Visual Studio 15 2017" }, // { "14.0", "Visual Studio 14 2015" }, // { "12.0", "Visual Studio 12 2013" }, // { "11.0", "Visual Studio 11 2012" }, // diff --git a/Source/cmparseMSBuildXML.py b/Source/cmparseMSBuildXML.py deleted file mode 100755 index 1b38d15..0000000 --- a/Source/cmparseMSBuildXML.py +++ /dev/null @@ -1,341 +0,0 @@ -# This python script parses the spec files from MSBuild to create -# mappings from compiler options to IDE XML specifications. For -# more information see here: - -# http://blogs.msdn.com/vcblog/archive/2008/12/16/msbuild-task.aspx -# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/1033/cl.xml" -# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/1033/lib.xml" -# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/1033/link.xml" -# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/V110/1033/cl.xml" -# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/V110/1033/lib.xml" -# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/V110/1033/link.xml" -# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/v120/1033/cl.xml" -# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/v120/1033/lib.xml" -# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/v120/1033/link.xml" -# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/V140/1033/cl.xml" -# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/V140/1033/lib.xml" -# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/V140/1033/link.xml" -# "${PROGRAMFILES}/Microsoft Visual Studio/VS15Preview/Common7/IDE/VC/VCTargets/1033/cl.xml" -# "${PROGRAMFILES}/Microsoft Visual Studio/VS15Preview/Common7/IDE/VC/VCTargets/1033/lib.xml" -# "${PROGRAMFILES}/Microsoft Visual Studio/VS15Preview/Common7/IDE/VC/VCTargets/1033/link.xml" -# -# BoolProperty <Name>true|false</Name> -# simple example: -# <BoolProperty ReverseSwitch="Oy-" Name="OmitFramePointers" -# Category="Optimization" Switch="Oy"> -# <BoolProperty.DisplayName> <BoolProperty.Description> -# <CLCompile> -# <OmitFramePointers>true</OmitFramePointers> -# </ClCompile> -# -# argument means it might be this: /MP3 -# example with argument: -# <BoolProperty Name="MultiProcessorCompilation" Category="General" Switch="MP"> -# <BoolProperty.DisplayName> -# <sys:String>Multi-processor Compilation</sys:String> -# </BoolProperty.DisplayName> -# <BoolProperty.Description> -# <sys:String>Multi-processor Compilation</sys:String> -# </BoolProperty.Description> -# <Argument Property="ProcessorNumber" IsRequired="false" /> -# </BoolProperty> -# <CLCompile> -# <MultiProcessorCompilation>true</MultiProcessorCompilation> -# <ProcessorNumber>4</ProcessorNumber> -# </ClCompile> -# IntProperty -# not used AFIT -# <IntProperty Name="ProcessorNumber" Category="General" Visible="false"> - - -# per config options example -# <EnableFiberSafeOptimizations Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</EnableFiberSafeOptimizations> -# -# EnumProperty -# <EnumProperty Name="Optimization" Category="Optimization"> -# <EnumProperty.DisplayName> -# <sys:String>Optimization</sys:String> -# </EnumProperty.DisplayName> -# <EnumProperty.Description> -# <sys:String>Select option for code optimization; choose Custom to use specific optimization options. (/Od, /O1, /O2, /Ox)</sys:String> -# </EnumProperty.Description> -# <EnumValue Name="MaxSpeed" Switch="O2"> -# <EnumValue.DisplayName> -# <sys:String>Maximize Speed</sys:String> -# </EnumValue.DisplayName> -# <EnumValue.Description> -# <sys:String>Equivalent to /Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy</sys:String> -# </EnumValue.Description> -# </EnumValue> -# <EnumValue Name="MinSpace" Switch="O1"> -# <EnumValue.DisplayName> -# <sys:String>Minimize Size</sys:String> -# </EnumValue.DisplayName> -# <EnumValue.Description> -# <sys:String>Equivalent to /Og /Os /Oy /Ob2 /Gs /GF /Gy</sys:String> -# </EnumValue.Description> -# </EnumValue> -# example for O2 would be this: -# <Optimization>MaxSpeed</Optimization> -# example for O1 would be this: -# <Optimization>MinSpace</Optimization> -# -# StringListProperty -# <StringListProperty Name="PreprocessorDefinitions" Category="Preprocessor" Switch="D "> -# <StringListProperty.DisplayName> -# <sys:String>Preprocessor Definitions</sys:String> -# </StringListProperty.DisplayName> -# <StringListProperty.Description> -# <sys:String>Defines a preprocessing symbols for your source file.</sys:String> -# </StringListProperty.Description> -# </StringListProperty> - -# <StringListProperty Subtype="folder" Name="AdditionalIncludeDirectories" Category="General" Switch="I"> -# <StringListProperty.DisplayName> -# <sys:String>Additional Include Directories</sys:String> -# </StringListProperty.DisplayName> -# <StringListProperty.Description> -# <sys:String>Specifies one or more directories to add to the include path; separate with semi-colons if more than one. (/I[path])</sys:String> -# </StringListProperty.Description> -# </StringListProperty> -# StringProperty - -# Example add bill include: - -# <AdditionalIncludeDirectories>..\..\..\..\..\..\bill;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - - -import sys -from xml.dom.minidom import parse, parseString - -def getText(node): - nodelist = node.childNodes - rc = "" - for child in nodelist: - if child.nodeType == child.TEXT_NODE: - rc = rc + child.data - return rc - -def print_tree(document, spaces=""): - for i in range(len(document.childNodes)): - if document.childNodes[i].nodeType == document.childNodes[i].ELEMENT_NODE: - print spaces+str(document.childNodes[i].nodeName ) - print_tree(document.childNodes[i],spaces+"----") - pass - -########################################################################################### -#Data structure that stores a property of MSBuild -class Property: - #type = type of MSBuild property (ex. if the property is EnumProperty type should be "Enum") - #attributeNames = a list of any attributes that this property could have (ex. if this was a EnumProperty it should be ["Name","Category"]) - #document = the dom file that's root node is the Property node (ex. if you were parsing a BoolProperty the root node should be something like <BoolProperty Name="RegisterOutput" Category="General" IncludeInCommandLine="false"> - def __init__(self,type,attributeNames,document=None): - self.suffix_type = "Property" - self.prefix_type = type - self.attributeNames = attributeNames - self.attributes = {} - self.DisplayName = "" - self.Description = "" - self.argumentProperty = "" - self.argumentIsRequired = "" - self.values = [] - if document is not None: - self.populate(document) - pass - - #document = the dom file that's root node is the Property node (ex. if you were parsing a BoolProperty the root node should be something like <BoolProperty Name="RegisterOutput" Category="General" IncludeInCommandLine="false"> - #spaces = do not use - def populate(self,document, spaces = ""): - if document.nodeName == self.prefix_type+self.suffix_type: - for i in self.attributeNames: - self.attributes[i] = document.getAttribute(i) - for i in range(len(document.childNodes)): - child = document.childNodes[i] - if child.nodeType == child.ELEMENT_NODE: - if child.nodeName == self.prefix_type+self.suffix_type+".DisplayName": - self.DisplayName = getText(child.childNodes[1]) - if child.nodeName == self.prefix_type+self.suffix_type+".Description": - self.Description = getText(child.childNodes[1]) - if child.nodeName == "Argument": - self.argumentProperty = child.getAttribute("Property") - self.argumentIsRequired = child.getAttribute("IsRequired") - if child.nodeName == self.prefix_type+"Value": - va = Property(self.prefix_type,["Name","DisplayName","Switch"]) - va.suffix_type = "Value" - va.populate(child) - self.values.append(va) - self.populate(child,spaces+"----") - pass - - #toString function - def __str__(self): - toReturn = self.prefix_type+self.suffix_type+":" - for i in self.attributeNames: - toReturn += "\n "+i+": "+self.attributes[i] - if self.argumentProperty != "": - toReturn += "\n Argument:\n Property: "+self.argumentProperty+"\n IsRequired: "+self.argumentIsRequired - for i in self.values: - toReturn+="\n "+str(i).replace("\n","\n ") - return toReturn -########################################################################################### - -########################################################################################### -#Class that populates itself from an MSBuild file and outputs it in CMake -#format - -class MSBuildToCMake: - #document = the entire MSBuild xml file - def __init__(self,document=None): - self.enumProperties = [] - self.stringProperties = [] - self.stringListProperties = [] - self.boolProperties = [] - self.intProperties = [] - if document!=None : - self.populate(document) - pass - - #document = the entire MSBuild xml file - #spaces = don't use - #To add a new property (if they exist) copy and paste this code and fill in appropriate places - # - #if child.nodeName == "<Name>Property": - # self.<Name>Properties.append(Property("<Name>",[<List of attributes>],child)) - # - #Replace <Name> with the name of the new property (ex. if property is StringProperty replace <Name> with String) - #Replace <List of attributes> with a list of attributes in your property's root node - #in the __init__ function add the line self.<Name>Properties = [] - # - #That is all that is required to add new properties - # - def populate(self,document, spaces=""): - for i in range(len(document.childNodes)): - child = document.childNodes[i] - if child.nodeType == child.ELEMENT_NODE: - if child.nodeName == "EnumProperty": - self.enumProperties.append(Property("Enum",["Name","Category"],child)) - if child.nodeName == "StringProperty": - self.stringProperties.append(Property("String",["Name","Subtype","Separator","Category","Visible","IncludeInCommandLine","Switch","DisplayName","ReadOnly"],child)) - if child.nodeName == "StringListProperty": - self.stringListProperties.append(Property("StringList",["Name","Category","Switch","DisplayName","Subtype"],child)) - if child.nodeName == "BoolProperty": - self.boolProperties.append(Property("Bool",["ReverseSwitch","Name","Category","Switch","DisplayName","SwitchPrefix","IncludeInCommandLine"],child)) - if child.nodeName == "IntProperty": - self.intProperties.append(Property("Int",["Name","Category","Visible"],child)) - self.populate(child,spaces+"----") - pass - - #outputs information that CMake needs to know about MSBuild xml files - def toCMake(self): - toReturn = "static cmVS7FlagTable cmVS10CxxTable[] =\n{\n" - toReturn += "\n //Enum Properties\n" - lastProp = {} - for i in self.enumProperties: - if i.attributes["Name"] == "CompileAsManaged": - #write these out after the rest of the enumProperties - lastProp = i - continue - for j in i.values: - #hardcore Brad King's manual fixes for cmVS10CLFlagTable.h - if i.attributes["Name"] == "PrecompiledHeader" and j.attributes["Switch"] != "": - toReturn+=" {\""+i.attributes["Name"]+"\", \""+j.attributes["Switch"]+"\",\n \""+j.attributes["DisplayName"]+"\", \""+j.attributes["Name"]+"\",\n cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},\n" - else: - #default (normal, non-hardcoded) case - toReturn+=" {\""+i.attributes["Name"]+"\", \""+j.attributes["Switch"]+"\",\n \""+j.attributes["DisplayName"]+"\", \""+j.attributes["Name"]+"\", 0},\n" - toReturn += "\n" - - if lastProp != {}: - for j in lastProp.values: - toReturn+=" {\""+lastProp.attributes["Name"]+"\", \""+j.attributes["Switch"]+"\",\n \""+j.attributes["DisplayName"]+"\", \""+j.attributes["Name"]+"\", 0},\n" - toReturn += "\n" - - toReturn += "\n //Bool Properties\n" - for i in self.boolProperties: - if i.argumentProperty == "": - if i.attributes["ReverseSwitch"] != "": - toReturn += " {\""+i.attributes["Name"]+"\", \""+i.attributes["ReverseSwitch"]+"\", \"\", \"false\", 0},\n" - if i.attributes["Switch"] != "": - toReturn += " {\""+i.attributes["Name"]+"\", \""+i.attributes["Switch"]+"\", \"\", \"true\", 0},\n" - - toReturn += "\n //Bool Properties With Argument\n" - for i in self.boolProperties: - if i.argumentProperty != "": - if i.attributes["ReverseSwitch"] != "": - toReturn += " {\""+i.attributes["Name"]+"\", \""+i.attributes["ReverseSwitch"]+"\", \"\", \"false\",\n cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},\n" - toReturn += " {\""+i.attributes["Name"]+"\", \""+i.attributes["ReverseSwitch"]+"\", \""+i.attributes["DisplayName"]+"\", \"\",\n cmVS7FlagTable::UserValueRequired},\n" - if i.attributes["Switch"] != "": - toReturn += " {\""+i.attributes["Name"]+"\", \""+i.attributes["Switch"]+"\", \"\", \"true\",\n cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},\n" - toReturn += " {\""+i.argumentProperty+"\", \""+i.attributes["Switch"]+"\", \""+i.attributes["DisplayName"]+"\", \"\",\n cmVS7FlagTable::UserValueRequired},\n" - - toReturn += "\n //String List Properties\n" - for i in self.stringListProperties: - if i.attributes["Switch"] == "": - toReturn += " // Skip [" + i.attributes["Name"] + "] - no command line Switch.\n"; - else: - toReturn +=" {\""+i.attributes["Name"]+"\", \""+i.attributes["Switch"]+"\",\n \""+i.attributes["DisplayName"]+"\",\n \"\", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},\n" - - toReturn += "\n //String Properties\n" - for i in self.stringProperties: - if i.attributes["Switch"] == "": - if i.attributes["Name"] == "PrecompiledHeaderFile": - #more hardcoding - toReturn += " {\"PrecompiledHeaderFile\", \"Yc\",\n" - toReturn += " \"Precompiled Header Name\",\n" - toReturn += " \"\", cmVS7FlagTable::UserValueRequired},\n" - toReturn += " {\"PrecompiledHeaderFile\", \"Yu\",\n" - toReturn += " \"Precompiled Header Name\",\n" - toReturn += " \"\", cmVS7FlagTable::UserValueRequired},\n" - else: - toReturn += " // Skip [" + i.attributes["Name"] + "] - no command line Switch.\n"; - else: - toReturn +=" {\""+i.attributes["Name"]+"\", \""+i.attributes["Switch"]+i.attributes["Separator"]+"\",\n \""+i.attributes["DisplayName"]+"\",\n \"\", cmVS7FlagTable::UserValue},\n" - - toReturn += " {0,0,0,0,0}\n};" - return toReturn - pass - - #toString function - def __str__(self): - toReturn = "" - allList = [self.enumProperties,self.stringProperties,self.stringListProperties,self.boolProperties,self.intProperties] - for p in allList: - for i in p: - toReturn += "==================================================\n"+str(i).replace("\n","\n ")+"\n==================================================\n" - - return toReturn -########################################################################################### - -########################################################################################### -# main function -def main(argv): - xml_file = None - help = """ - Please specify an input xml file with -x - - Exiting... - Have a nice day :)""" - for i in range(0,len(argv)): - if argv[i] == "-x": - xml_file = argv[i+1] - if argv[i] == "-h": - print help - sys.exit(0) - pass - if xml_file == None: - print help - sys.exit(1) - - f = open(xml_file,"r") - xml_str = f.read() - xml_dom = parseString(xml_str) - - convertor = MSBuildToCMake(xml_dom) - print convertor.toCMake() - - xml_dom.unlink() -########################################################################################### -# main entry point -if __name__ == "__main__": - main(sys.argv) - -sys.exit(0) |