diff --git a/GPVirtoolsStatic/GPVirtoolsStatic.vcxproj b/GPVirtoolsStatic/GPVirtoolsStatic.vcxproj deleted file mode 100644 index 864b159..0000000 --- a/GPVirtoolsStatic/GPVirtoolsStatic.vcxproj +++ /dev/null @@ -1,227 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - 16.0 - Win32Proj - {38703ab6-bc5d-4062-bc5b-1bf195333b16} - GPVirtoolsStatic - 10.0 - - - - StaticLibrary - true - v142 - MultiByte - Dynamic - - - StaticLibrary - false - v142 - true - MultiByte - Dynamic - - - - - - - - - - - - - - - - - true - $(SolutionDir)out\$(Platform)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)temp\$(Platform)\$(Configuration)\$(ProjectName)\ - - - false - $(SolutionDir)out\$(Platform)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)temp\$(Platform)\$(Configuration)\$(ProjectName)\ - - - - Level3 - true - BML_EXPORT=;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - false - stdcpp17 - - - Console - true - - - - - Level3 - true - true - true - BML_EXPORT=;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - false - stdcpp17 - - - Console - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/GPVirtoolsStatic/GPVirtoolsStatic.vcxproj.filters b/GPVirtoolsStatic/GPVirtoolsStatic.vcxproj.filters deleted file mode 100644 index ebfdb1f..0000000 --- a/GPVirtoolsStatic/GPVirtoolsStatic.vcxproj.filters +++ /dev/null @@ -1,411 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - \ No newline at end of file diff --git a/Scripts/VSProp.py b/Scripts/VSProp.py deleted file mode 100644 index f2b6466..0000000 --- a/Scripts/VSProp.py +++ /dev/null @@ -1,127 +0,0 @@ -import xml.dom.minidom as minidom -import xml.dom -import os -import sys - -class VSPropWriter(object): - - SUBSYSTEM_WIN: str = 'Windows' - SUBSYSTEM_CON: str = 'Console' - - def __init__(self): - self.__MacroList: dict[str, str] = {} - self.__SubSystem: str = None - self.__BuildType: str = None - - def AddMacro(self, key: str, value: str): - if (key in self.__MacroList): - raise Exception(f'Duplicated Set Macro "{key}".') - self.__MacroList[key] = value - - def SetSubSystem(self, subsys: str): - self.__SubSystem = subsys - - def Write2File(self, filename: str): - # create some header - dom = minidom.getDOMImplementation().createDocument(None, 'Project', None) - root = dom.documentElement - root.setAttribute('ToolsVersion', '4.0') - root.setAttribute('xmlns', 'http://schemas.microsoft.com/developer/msbuild/2003') - - cache = dom.createElement('ImportGroup') - cache.setAttribute('Label', 'PropertySheets') - root.appendChild(cache) - - # write sub system - if self.__SubSystem is not None: - for bt in ('Debug', 'Release'): - node_IDG = dom.createElement('ItemDefinitionGroup') - node_IDG.setAttribute('Condition', f"'$(Configuration)|$(Platform)'=='{bt}|Win32'") - - node_link = dom.createElement('Link') - node_sub_system = dom.createElement('SubSystem') - - node_sub_system.appendChild(dom.createTextNode(self.__SubSystem)) - - node_link.appendChild(node_sub_system) - node_IDG.appendChild(node_link) - root.appendChild(node_IDG) - - # write macro - node_PG = dom.createElement('PropertyGroup') # macro node 1 - node_PG.setAttribute('Label', 'UserMacros') - root.appendChild(node_PG) - - cache = dom.createElement('PropertyGroup') # dummy structure - root.appendChild(cache) - cache = dom.createElement('ItemDefinitionGroup') #dummy structure - root.appendChild(cache) - - node_IG = dom.createElement('ItemGroup') # macro node 2 - root.appendChild(node_IG) - - for key, value in self.__MacroList.items(): - # create for PropertyGroup - node_macro_decl = dom.createElement(key) - if value != '': # check whether data is empty. - node_macro_decl.appendChild(dom.createTextNode(value)) - node_PG.appendChild(node_macro_decl) - - # create for ItemGroup - node_macro_ref = dom.createElement("BuildMacro") - node_macro_ref.setAttribute('Include', key) - node_inner_macro_ref = dom.createElement('Value') - node_inner_macro_ref.appendChild(dom.createTextNode("$({})".format(key))) - node_macro_ref.appendChild(node_inner_macro_ref) - node_IG.appendChild(node_macro_ref) - - # write to file - with open(filename, 'w', encoding='utf-8') as f: - dom.writexml(f, addindent='\t', newl='\n', encoding='utf-8') - -class VSVcxprojModifier(object): - - BUILDTYPE_EXE: str = 'Application' - BUILDTYPE_DLL: str = 'DynamicLibrary' - - def __init__(self, vcfile: str): - self.__Dom = minidom.parse(vcfile) - self.__FileName: str = vcfile - self.__BuildType: str = None - - def SetBuildType(self, bt: str): - self.__BuildType = bt - - def Write2File(self): - # if no spec build type, do not modify - if self.__BuildType is None: - return - - # get corresponding entry - dom = self.__Dom - node_project = dom.documentElement - for node_PG in node_project.getElementsByTagName('PropertyGroup'): - attr_label = node_PG.getAttribute('Label') - attr_condition = node_PG.getAttribute('Condition') - - # skip invalid node - if attr_label != 'Configuration': - continue - if attr_condition != "'$(Configuration)|$(Platform)'=='Debug|Win32'" and attr_condition != "'$(Configuration)|$(Platform)'=='Release|Win32'": - continue - - # this is valid node, process it - node_CT = node_PG.getElementsByTagName('ConfigurationType') - if len(node_CT) != 0: - # have node, change it - node_CT[0].childNodes[0].nodeValue = self.__BuildType - else: - # don't have node, add one - node_CT = dom.createElement('ConfigurationType') - node_CT.appendChild(dom.createTextNode(self.__BuildType)) - node_PG.appendChild(node_CT) - - # write file - with open(self.__FileName, 'w', encoding='utf-8') as f: - dom.writexml(f, encoding='utf-8') - diff --git a/SuperScriptMaterializer.sln b/SuperScriptMaterializer.sln index e513fb2..2edaf07 100644 --- a/SuperScriptMaterializer.sln +++ b/SuperScriptMaterializer.sln @@ -5,8 +5,6 @@ VisualStudioVersion = 16.0.29418.71 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SuperScriptMaterializer", "SuperScriptMaterializer\SuperScriptMaterializer.vcxproj", "{4D941003-020F-47FD-9FA2-FFC989E306B8}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GPVirtoolsStatic", "GPVirtoolsStatic\GPVirtoolsStatic.vcxproj", "{38703AB6-BC5D-4062-BC5B-1BF195333B16}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x86 = Debug|x86 @@ -17,10 +15,6 @@ Global {4D941003-020F-47FD-9FA2-FFC989E306B8}.Debug|x86.Build.0 = Debug|Win32 {4D941003-020F-47FD-9FA2-FFC989E306B8}.Release|x86.ActiveCfg = Release|Win32 {4D941003-020F-47FD-9FA2-FFC989E306B8}.Release|x86.Build.0 = Release|Win32 - {38703AB6-BC5D-4062-BC5B-1BF195333B16}.Debug|x86.ActiveCfg = Debug|Win32 - {38703AB6-BC5D-4062-BC5B-1BF195333B16}.Debug|x86.Build.0 = Debug|Win32 - {38703AB6-BC5D-4062-BC5B-1BF195333B16}.Release|x86.ActiveCfg = Release|Win32 - {38703AB6-BC5D-4062-BC5B-1BF195333B16}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj.filters b/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj.filters index 40f1228..946a747 100644 --- a/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj.filters +++ b/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj.filters @@ -1,77 +1,77 @@  - + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - + {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - 头文件 + Headers - 头文件 + Headers - 头文件 + Headers - 头文件 + Headers - 头文件 + Headers - 头文件 + Headers - 头文件 + Headers - 头文件 + Headers - 头文件 + Headers - 源文件 + Sources - 源文件 + Sources - 源文件 + Sources - 源文件 + Sources - 源文件 + Sources - 源文件 + Sources - 源文件 + Sources - 源文件 + Sources - 源文件 + Sources \ No newline at end of file diff --git a/Documents/COMPILE_ZH.md b/docs/COMPILE_ZH.md similarity index 100% rename from Documents/COMPILE_ZH.md rename to docs/COMPILE_ZH.md diff --git a/Documents/DEPLOY_ZH.md b/docs/DEPLOY_ZH.md similarity index 100% rename from Documents/DEPLOY_ZH.md rename to docs/DEPLOY_ZH.md diff --git a/Documents/DevDocument_ZH.md b/docs/DevDocument_ZH.md similarity index 100% rename from Documents/DevDocument_ZH.md rename to docs/DevDocument_ZH.md diff --git a/Scripts/MkMtlCfg.py b/scripts/mk_mtl_cfg.py similarity index 69% rename from Scripts/MkMtlCfg.py rename to scripts/mk_mtl_cfg.py index 200704d..99fc607 100644 --- a/Scripts/MkMtlCfg.py +++ b/scripts/mk_mtl_cfg.py @@ -1,6 +1,124 @@ -import VSProp -import os -import sys +import vs_props_writer, vs_vcxproj_modifier +import os, enum, sys + +#region Constant Declarations + +class BuildType(enum.Enum): + Standalone: str = "standalone" + Plugin: str = "plugin" + +class VirtoolsVersion(enum.Enum): + V21 = '21' + V25 = '25' + V30 = '30' + V35 = '35' + V40 = '40' + V50 = '50' + +VT_STANDALONE_ATTACHED_LIBS: dict[VirtoolsVersion, str] = { + VirtoolsVersion.V21: "VxMath.lib;CK2.lib", + VirtoolsVersion.V25: "VxMath.lib;CK2.lib", + VirtoolsVersion.V30: "VxMath.lib;CK2.lib", + VirtoolsVersion.V35: "VxMath.lib;CK2.lib", + VirtoolsVersion.V40: "VxMath.lib;CK2.lib", + VirtoolsVersion.V50: "VxMath.lib;CK2.lib" +} +VT_PLUGIN_ATTACHED_LIBS: dict[VirtoolsVersion, str] = { + VirtoolsVersion.V21: "", + VirtoolsVersion.V25: "", + VirtoolsVersion.V30: "VxMath.lib;DllEditor.lib;CK2.lib;InterfaceControls.lib;CKControls.lib", + VirtoolsVersion.V35: "VxMath.lib;DllEditor.lib;CK2.lib;InterfaceControls.lib;CKControls.lib", + VirtoolsVersion.V40: "VxMath.lib;DllEditor.lib;CK2.lib;InterfaceControls.lib;CKControls.lib", + VirtoolsVersion.V50: "VxMath.lib;DllEditor.lib;CK2.lib;InterfaceControls.lib;CKControls.lib" +} + +VT_PLUGIN_MACROS: dict[VirtoolsVersion, str] = { + VirtoolsVersion.V21: "_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE", + VirtoolsVersion.V25: "_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE", + VirtoolsVersion.V30: "_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE", + VirtoolsVersion.V35: "_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE", + VirtoolsVersion.V40: "_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE", + VirtoolsVersion.V50: "_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" +} +VT_STANDALONE_MACROS: dict[VirtoolsVersion, str] = { + VirtoolsVersion.V21: "_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG", + VirtoolsVersion.V25: "_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG", + VirtoolsVersion.V30: "_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG", + VirtoolsVersion.V35: "_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG", + VirtoolsVersion.V40: "_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG", + VirtoolsVersion.V50: "_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;VIRTOOLS_USER_SDK" +} + +VT_EXECUTABLE_DEV: dict[VirtoolsVersion, str] = { + VirtoolsVersion.V21: "Dev.exe", + VirtoolsVersion.V25: "Dev.exe", + VirtoolsVersion.V30: "devr.exe", + VirtoolsVersion.V35: "devr.exe", + VirtoolsVersion.V40: "devr.exe", + VirtoolsVersion.V50: "devr.exe" +} + +#endregion + +#region Assist Functions + +def get_project_root() -> str: + # build project root path + ret: str = os.path.dirname(os.path.dirname(__file__)) + # check whether have readme file + if not os.path.isfile(os.path.join(ret, 'README.md')): + print('Fail to get project root folder. This script may be placed at wrong location.') + sys.exit(1) + # return value + return ret + +def get_attached_libs(build_type: BuildType, vt_version: VirtoolsVersion) -> str: + match(build_type): + case BuildType.Standalone: + return VT_STANDALONE_ATTACHED_LIBS[vt_version] + case BuildType.Plugin: + return VT_PLUGIN_ATTACHED_LIBS[vt_version] + case _: + raise Exception('invalid build type') + +def get_macros(build_type: BuildType, vt_version: VirtoolsVersion) -> str: + match(build_type): + case BuildType.Standalone: + return VT_STANDALONE_MACROS[vt_version] + case BuildType.Plugin: + return VT_PLUGIN_MACROS[vt_version] + case _: + raise Exception('invalid build type') + +def get_executable_dev(vt_version: VirtoolsVersion) -> str: + """ + Return the path to executable Virtools Dev according to given Virtools version. + + Usually it is `Dev.exe` or `devr.exe`. + + :param vt_version The version of Virtools. + """ + pass + +def get_output_path(build_type: BuildType, vt_root: str) -> str: + # fetch output path by build type + ret: str + match(build_type): + case BuildType.Standalone: + ret = vt_root + case BuildType.Plugin: + ret = os.path.join(vt_root, 'InterfacePlugins') + case _: + raise Exception('invalid build type') + # make sure return value is end with slash or backslash + if ret[-1] != '\\' or ret[-1] != '/': + ret += '\\' + # return value + return ret + +#endregion + + # =========== check work dir =========== @@ -233,8 +351,10 @@ else: # =========== create props =========== -props = VSProp.VSPropWriter() -vcxproj = VSProp.VSVcxprojModifier('./SuperScriptMaterializer/SuperScriptMaterializer.vcxproj') +props = vs_props_writer.VsPropsWriter() +vcxproj = vs_vcxproj_modifier.VsVcxprojModifier( + './SuperScriptMaterializer/SuperScriptMaterializer.vcxproj' +) # write build type if input_build_type == build_type_standalone: @@ -244,9 +364,9 @@ elif input_build_type == build_type_plugin: # write subsystem if input_build_type == build_type_standalone: - props.SetSubSystem(props.SUBSYSTEM_CON); + props.SetSubSystem(vs_props_writer.VsSubSystem.Console) elif input_build_type == build_type_plugin: - props.SetSubSystem(props.SUBSYSTEM_WIN) + props.SetSubSystem(vs_props_writer.VsSubSystem.Windows) # write macro and misc # build type distinguish macro @@ -286,3 +406,7 @@ if input_virtools_version == '21' and input_vt21_reverse_work_type == 'gamepiayn gp_props.Write2File('./GPVirtoolsStatic/Virtools.props') print("OK!") + +if __name__ == '__main__': + pass + diff --git a/scripts/vs_props_writer.py b/scripts/vs_props_writer.py new file mode 100644 index 0000000..ea1a5c3 --- /dev/null +++ b/scripts/vs_props_writer.py @@ -0,0 +1,80 @@ +import xml.dom.minidom as minidom +import enum, os, sys + +class VsSubSystem(enum.Enum): + Windows = 'Windows' + Console = 'Console' + +class VsPropsWriter(): + + __mMacroList: dict[str, str] + __mSubSystem: VsSubSystem + + def __init__(self): + self.__mMacroList = {} + self.__mSubSystem = VsSubSystem.Windows + + def AddMacro(self, key: str, value: str): + if key in self.__mMacroList: + raise Exception(f'Duplicated Set Macro "{key}".') + self.__mMacroList[key] = value + + def SetSubSystem(self, subsys: VsSubSystem): + self.__mSubSystem = subsys + + def Generate(self, filename: str): + # create some header + document = minidom.getDOMImplementation().createDocument(None, 'Project', None) + root: minidom.Element = document.documentElement + root.setAttribute('ToolsVersion', '4.0') + root.setAttribute('xmlns', 'http://schemas.microsoft.com/developer/msbuild/2003') + + cache = document.createElement('ImportGroup') + cache.setAttribute('Label', 'PropertySheets') + root.appendChild(cache) + + # write sub system + for bt in ('Debug', 'Release'): + node_IDG = document.createElement('ItemDefinitionGroup') + node_IDG.setAttribute('Condition', f"'$(Configuration)|$(Platform)'=='{bt}|Win32'") + + node_link = document.createElement('Link') + node_sub_system = document.createElement('SubSystem') + + node_sub_system.appendChild(document.createTextNode(self.__mSubSystem.value)) + + node_link.appendChild(node_sub_system) + node_IDG.appendChild(node_link) + root.appendChild(node_IDG) + + # write macro + node_PG = document.createElement('PropertyGroup') # macro node 1 + node_PG.setAttribute('Label', 'UserMacros') + root.appendChild(node_PG) + + cache = document.createElement('PropertyGroup') # dummy structure + root.appendChild(cache) + cache = document.createElement('ItemDefinitionGroup') #dummy structure + root.appendChild(cache) + + node_IG = document.createElement('ItemGroup') # macro node 2 + root.appendChild(node_IG) + + for key, value in self.__mMacroList.items(): + # create for PropertyGroup + node_macro_decl = document.createElement(key) + if value != '': # check whether data is empty. + node_macro_decl.appendChild(document.createTextNode(value)) + node_PG.appendChild(node_macro_decl) + + # create for ItemGroup + node_macro_ref = document.createElement("BuildMacro") + node_macro_ref.setAttribute('Include', key) + node_inner_macro_ref = document.createElement('Value') + node_inner_macro_ref.appendChild(document.createTextNode("$({})".format(key))) + node_macro_ref.appendChild(node_inner_macro_ref) + node_IG.appendChild(node_macro_ref) + + # write to file + with open(filename, 'w', encoding='utf-8') as f: + document.writexml(f, addindent='\t', newl='\n', encoding='utf-8') diff --git a/scripts/vs_vcxproj_modifier.py b/scripts/vs_vcxproj_modifier.py new file mode 100644 index 0000000..20b3dad --- /dev/null +++ b/scripts/vs_vcxproj_modifier.py @@ -0,0 +1,51 @@ +import xml.dom.minidom as minidom +import xml.dom +import os +import sys + +class VsVcxprojModifier(): + + BUILDTYPE_EXE: str = 'Application' + BUILDTYPE_DLL: str = 'DynamicLibrary' + + def __init__(self, vcfile: str): + self.__Dom = minidom.parse(vcfile) + self.__FileName: str = vcfile + self.__BuildType: str = None + + def SetBuildType(self, bt: str): + self.__BuildType = bt + + def Write2File(self): + # if no spec build type, do not modify + if self.__BuildType is None: + return + + # get corresponding entry + dom = self.__Dom + node_project = dom.documentElement + for node_PG in node_project.getElementsByTagName('PropertyGroup'): + attr_label = node_PG.getAttribute('Label') + attr_condition = node_PG.getAttribute('Condition') + + # skip invalid node + if attr_label != 'Configuration': + continue + if attr_condition != "'$(Configuration)|$(Platform)'=='Debug|Win32'" and attr_condition != "'$(Configuration)|$(Platform)'=='Release|Win32'": + continue + + # this is valid node, process it + node_CT = node_PG.getElementsByTagName('ConfigurationType') + if len(node_CT) != 0: + # have node, change it + node_CT[0].childNodes[0].nodeValue = self.__BuildType + else: + # don't have node, add one + node_CT = dom.createElement('ConfigurationType') + node_CT.appendChild(dom.createTextNode(self.__BuildType)) + node_PG.appendChild(node_CT) + + # write file + with open(self.__FileName, 'w', encoding='utf-8') as f: + dom.writexml(f, encoding='utf-8') +