Finish mk_materializer_cfg.py

* Finish mk_materializer_cfg.py with all possible options
* SuperScriptMaterializer now load Virtools.props to define how the entire project should be compiled
This commit is contained in:
yyc12345 2021-08-28 12:23:11 +08:00
parent 4951670e3d
commit e991ab1172
3 changed files with 105 additions and 35 deletions

View File

@ -19,12 +19,10 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<PlatformToolset>v142</PlatformToolset> <PlatformToolset>v142</PlatformToolset>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfMfc>Dynamic</UseOfMfc> <UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset> <PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
@ -64,7 +62,7 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>$(VIRTOOLS_HEADER_PATH);$(SQLITE_HEADER_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(VIRTOOLS_HEADER_PATH);$(SQLITE_HEADER_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;_USRDLL;$(VIRTOOLS_VER);VX_MEM_RELEASE;$(VIRTOOLS_BUILD_TYPE);%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WINDOWS;_USRDLL;$(VIRTOOLS_VER);$(BML_SPECIAL_MACRO);VX_MEM_RELEASE;$(VIRTOOLS_BUILD_TYPE);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
</ClCompile> </ClCompile>
@ -93,7 +91,7 @@
<LanguageStandard>Default</LanguageStandard> <LanguageStandard>Default</LanguageStandard>
<AdditionalIncludeDirectories>$(VIRTOOLS_HEADER_PATH);$(SQLITE_HEADER_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(VIRTOOLS_HEADER_PATH);$(SQLITE_HEADER_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<PreprocessorDefinitions>WIN32;_WINDOWS;_USRDLL;$(VIRTOOLS_VER);VX_MEM_RELEASE;_RELEASE;$(VIRTOOLS_BUILD_TYPE);%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WINDOWS;_USRDLL;$(VIRTOOLS_VER);$(BML_SPECIAL_MACRO);VX_MEM_RELEASE;_RELEASE;$(VIRTOOLS_BUILD_TYPE);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
</ClCompile> </ClCompile>
<Link> <Link>

View File

@ -1,18 +1,24 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets"/> <ImportGroup Label="PropertySheets"/>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ConfigurationType>Application</ConfigurationType>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ConfigurationType>Application</ConfigurationType>
</PropertyGroup>
<PropertyGroup Label="UserMacros"> <PropertyGroup Label="UserMacros">
<VIRTOOLS_HEADER_PATH>E:\Virtools\Virtools Dev 5.0\Sdk/Includes</VIRTOOLS_HEADER_PATH> <VIRTOOLS_HEADER_PATH>E:\Virtools\Virtools Dev 5.0\Sdk/Includes</VIRTOOLS_HEADER_PATH>
<VIRTOOLS_LIB_PATH>E:\Virtools\Virtools Dev 5.0\Sdk/Lib/Win32/Release</VIRTOOLS_LIB_PATH> <VIRTOOLS_LIB_PATH>E:\Virtools\Virtools Dev 5.0\Sdk/Lib/Win32/Release</VIRTOOLS_LIB_PATH>
<SQLITE_HEADER_PATH>D:\CppLib\SQLite\sqlite-amalgamation-3310100</SQLITE_HEADER_PATH> <SQLITE_HEADER_PATH>D:\CppLib\SQLite\sqlite-amalgamation-3310100</SQLITE_HEADER_PATH>
<SQLITE_LIB_PATH>D:\CppLib\SQLite\sqlite-dll-win32-x86-3310100</SQLITE_LIB_PATH> <SQLITE_LIB_PATH>D:\CppLib\SQLite\sqlite-dll-win32-x86-3310100</SQLITE_LIB_PATH>
<VIRTOOLS_OUTPUT_PATH>E:\Virtools\Virtools Dev 5.0\InterfacePlugins\</VIRTOOLS_OUTPUT_PATH> <VIRTOOLS_OUTPUT_PATH>E:\Virtools\Virtools Dev 5.0\</VIRTOOLS_OUTPUT_PATH>
<VIRTOOLS_BUILD_TYPE>VIRTOOLS_PLUGIN</VIRTOOLS_BUILD_TYPE> <VIRTOOLS_BUILD_TYPE>VIRTOOLS_STANDALONE</VIRTOOLS_BUILD_TYPE>
<VIRTOOLS_DEBUG_TARGET>E:\Virtools\Virtools Dev 5.0\devr.exe</VIRTOOLS_DEBUG_TARGET> <VIRTOOLS_DEBUG_TARGET>E:\Virtools\Virtools Dev 5.0\SuperScriptMaterializer.exe</VIRTOOLS_DEBUG_TARGET>
<VIRTOOLS_DEBUG_ROOT>E:\Virtools\Virtools Dev 5.0</VIRTOOLS_DEBUG_ROOT> <VIRTOOLS_DEBUG_ROOT>E:\Virtools\Virtools Dev 5.0</VIRTOOLS_DEBUG_ROOT>
<VIRTOOLS_BUILD_SUFFIX>dll</VIRTOOLS_BUILD_SUFFIX> <VIRTOOLS_BUILD_SUFFIX>exe</VIRTOOLS_BUILD_SUFFIX>
<VIRTOOLS_VER>VIRTOOLS_50</VIRTOOLS_VER> <VIRTOOLS_VER>VIRTOOLS_50</VIRTOOLS_VER>
<BML_SPECIAL_MACRO></BML_SPECIAL_MACRO> <BML_SPECIAL_MACRO/>
<VIRTOOLS_ATTACH_REF>vxmath.lib;DllEditor.lib;ck2.lib;InterfaceControls.lib;CKControls.lib</VIRTOOLS_ATTACH_REF> <VIRTOOLS_ATTACH_REF>vxmath.lib;DllEditor.lib;ck2.lib;InterfaceControls.lib;CKControls.lib</VIRTOOLS_ATTACH_REF>
<SQLITE_ATTACH_REF>sqlite3.lib</SQLITE_ATTACH_REF> <SQLITE_ATTACH_REF>sqlite3.lib</SQLITE_ATTACH_REF>
</PropertyGroup> </PropertyGroup>

View File

@ -14,6 +14,22 @@ valid_build_type = (
build_type_plugin build_type_plugin
) )
virtools_attach_ref_dict = {
"21": "vxmath.lib;DllEditor.lib;ck2.lib;InterfaceControls.lib;CKControls.lib",
"25": "vxmath.lib;DllEditor.lib;ck2.lib;InterfaceControls.lib;CKControls.lib",
"35": "vxmath.lib;DllEditor.lib;ck2.lib;InterfaceControls.lib;CKControls.lib",
"40": "vxmath.lib;DllEditor.lib;ck2.lib;InterfaceControls.lib;CKControls.lib",
"50": "vxmath.lib;DllEditor.lib;ck2.lib;InterfaceControls.lib;CKControls.lib"
}
executable_virtools = {
"21": "Dev.exe",
"25": "Dev.exe",
"35": "devr.exe",
"40": "devr.exe",
"50": "devr.exe"
}
valid_virtools_standalone_ver = ( valid_virtools_standalone_ver = (
"21", "21",
"25", "25",
@ -30,6 +46,7 @@ valid_virtools_plugin_ver = (
# ======================== assist func # ======================== assist func
def write_macro(dom, node_property_group, node_item_group, macro_upcase, data): def write_macro(dom, node_property_group, node_item_group, macro_upcase, data):
node = dom.createElement(macro_upcase) node = dom.createElement(macro_upcase)
if data != '':
node.appendChild(dom.createTextNode(data)) node.appendChild(dom.createTextNode(data))
node_property_group.appendChild(node) node_property_group.appendChild(node)
@ -40,6 +57,18 @@ def write_macro(dom, node_property_group, node_item_group, macro_upcase, data):
node.appendChild(inter_node) node.appendChild(inter_node)
node_item_group.appendChild(node) node_item_group.appendChild(node)
def write_cl(dom, node_include, node_compile, filename):
if filename.endswith('.h'):
cl = dom.createElement('ClInclude')
node = node_include
elif filename.endswith('.cpp'):
cl = dom.createElement('ClCompile')
node = node_compile
else:
return
cl.setAttribute('Include', filename)
node.appendChild(cl)
def get_executable_virtools(vt_ver): def get_executable_virtools(vt_ver):
if vt_ver == '21': if vt_ver == '21':
return 'Dev.exe' return 'Dev.exe'
@ -56,52 +85,64 @@ def get_executable_virtools(vt_ver):
if len(sys.argv) != 8: if len(sys.argv) != 8:
print("Error parameter!") print("Error parameter!")
print("Example: python3 mk_materializer_cfg.py [plugin|standalone] [21|25|35|40|50] [virtools_root_path] [sqlite_header] [sqlite_lib] [sqlite attach ref] [bml path]") print("Format: python3 mk_materializer_cfg.py [plugin|standalone] [21|25|35|40|50] [virtools_root_path] [sqlite_header] [sqlite_lib] [sqlite attach ref] [bml path]")
print('Example: python3 .\mk_materializer_cfg.py standalone 50 "E:\Virtools\Virtools Dev 5.0" "D:\CppLib\SQLite\sqlite-amalgamation-3310100" "D:\CppLib\SQLite\sqlite-dll-win32-x86-3310100" sqlite3.lib "D:\BallanceModLoader"')
sys.exit(1) sys.exit(1)
build_type = sys.argv[1] input_build_type = sys.argv[1]
if build_type not in valid_build_type: if input_build_type not in valid_build_type:
print("Invalid build_type!") print("Invalid build_type!")
sys.exit(1) sys.exit(1)
virtools_version = sys.argv[2] input_virtools_version = sys.argv[2]
if build_type == build_type_standalone and virtools_version not in valid_virtools_standalone_ver: if input_build_type == build_type_standalone and input_virtools_version not in valid_virtools_standalone_ver:
print("Invalid virtools_version!") print("Invalid virtools_version!")
sys.exit(1) sys.exit(1)
elif build_type == build_type_plugin and virtools_version not in valid_virtools_plugin_ver: elif input_build_type == build_type_plugin and input_virtools_version not in valid_virtools_plugin_ver:
print("Invalid virtools_version!") print("Invalid virtools_version!")
sys.exit(1) sys.exit(1)
virtools_root_path = sys.argv[3] input_virtools_root_path = sys.argv[3]
sqlite_header_path = sys.argv[4] input_sqlite_header_path = sys.argv[4]
sqlite_lib_path = sys.argv[5] input_sqlite_lib_path = sys.argv[5]
sqlite_attach_ref = sys.argv[6] input_sqlite_attach_ref = sys.argv[6]
bml_path = sys.argv[7] input_bml_path = sys.argv[7]
# ======================== construct some path # ======================== construct some path
# .......todo # .......todo
virtools_header_path = os.path.join(virtools_root_path, 'Sdk/Includes') sqlite_header_path = input_sqlite_header_path
virtools_lib_path = os.path.join(virtools_root_path, 'Sdk/Lib/Win32/Release') sqlite_lib_path = input_sqlite_lib_path
virtools_ver = 'VIRTOOLS_' + virtools_version sqlite_attach_ref = input_sqlite_attach_ref
virtools_debug_root = virtools_root_path
if build_type == build_type_plugin: virtools_ver = 'VIRTOOLS_' + input_virtools_version
virtools_debug_root = input_virtools_root_path
virtools_attach_ref = virtools_attach_ref_dict[input_virtools_version]
if input_build_type == build_type_plugin:
virtools_build_type = 'VIRTOOLS_PLUGIN' virtools_build_type = 'VIRTOOLS_PLUGIN'
virtools_build_suffix = 'dll' virtools_build_suffix = 'dll'
virtools_debug_target = os.path.join(virtools_root_path, get_executable_virtools(virtools_version)) virtools_debug_target = os.path.join(input_virtools_root_path, executable_virtools[input_virtools_version])
virtools_output_path = os.path.join(virtools_root_path, 'InterfacePlugins') virtools_output_path = os.path.join(input_virtools_root_path, 'InterfacePlugins')
elif build_type == build_type_standalone: elif input_build_type == build_type_standalone:
virtools_build_type = 'VIRTOOLS_STANDALONE' virtools_build_type = 'VIRTOOLS_STANDALONE'
virtools_build_suffix = 'exe' virtools_build_suffix = 'exe'
virtools_debug_target = os.path.join(virtools_root_path, 'SuperScriptMaterializer.exe') virtools_debug_target = os.path.join(input_virtools_root_path, 'SuperScriptMaterializer.exe')
virtools_output_path = virtools_root_path virtools_output_path = input_virtools_root_path
# make sure the last char of output_path is slash
if virtools_output_path[-1] != '\\' or virtools_output_path[-1] != '/': if virtools_output_path[-1] != '\\' or virtools_output_path[-1] != '/':
virtools_output_path = virtools_output_path + '\\' virtools_output_path = virtools_output_path + '\\'
if virtools_version == '21': # in virtools 2.1, we use bml, so we need add bml macro and set virtools header to bml's virtools header
# also, we don't need set lib path because all virtools file have been imported in project
if input_virtools_version == '21':
virtools_header_path = ''#os.path.join(input_bml_path, 'virtools')
virtools_lib_path = ''
bml_special_macro = 'BML_EXPORT=' bml_special_macro = 'BML_EXPORT='
else: else:
virtools_header_path = os.path.join(input_virtools_root_path, 'Sdk/Includes')
virtools_lib_path = os.path.join(input_virtools_root_path, 'Sdk/Lib/Win32/Release')
bml_special_macro = '' bml_special_macro = ''
# ======================== create document # ======================== create document
@ -115,6 +156,20 @@ cache = dom.createElement('ImportGroup')
cache.setAttribute('Label', 'PropertySheets') cache.setAttribute('Label', 'PropertySheets')
root.appendChild(cache) root.appendChild(cache)
# ======================== write build type
for bt in ('Debug', 'Release'):
node_build_type = dom.createElement('PropertyGroup')
node_build_type.setAttribute('Label', 'Configuration')
node_build_type.setAttribute('Condition', "'$(Configuration)|$(Platform)'=='{}|Win32'".format(bt))
node_configuration_type = dom.createElement('ConfigurationType')
if input_build_type == build_type_standalone:
node_configuration_type.appendChild(dom.createTextNode('Application'))
elif input_build_type == build_type_plugin:
node_configuration_type.appendChild(dom.createTextNode('DynamicLibrary'))
node_build_type.appendChild(node_configuration_type)
root.appendChild(node_build_type)
# ======================== write macro and misc
node_property_group = dom.createElement('PropertyGroup') node_property_group = dom.createElement('PropertyGroup')
node_property_group.setAttribute('Label', 'UserMacros') node_property_group.setAttribute('Label', 'UserMacros')
root.appendChild(node_property_group) root.appendChild(node_property_group)
@ -128,8 +183,6 @@ root.appendChild(cache)
node_item_group = dom.createElement('ItemGroup') node_item_group = dom.createElement('ItemGroup')
root.appendChild(node_item_group) root.appendChild(node_item_group)
# ======================== write macro
write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_HEADER_PATH', virtools_header_path) write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_HEADER_PATH', virtools_header_path)
write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_LIB_PATH', virtools_lib_path) write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_LIB_PATH', virtools_lib_path)
write_macro(dom, node_property_group, node_item_group, 'SQLITE_HEADER_PATH', sqlite_header_path) write_macro(dom, node_property_group, node_item_group, 'SQLITE_HEADER_PATH', sqlite_header_path)
@ -141,9 +194,22 @@ write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_DEBUG_ROOT', vi
write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_BUILD_SUFFIX', virtools_build_suffix) write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_BUILD_SUFFIX', virtools_build_suffix)
write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_VER', virtools_ver) write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_VER', virtools_ver)
write_macro(dom, node_property_group, node_item_group, 'BML_SPECIAL_MACRO', bml_special_macro) write_macro(dom, node_property_group, node_item_group, 'BML_SPECIAL_MACRO', bml_special_macro)
write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_ATTACH_REF', "vxmath.lib;DllEditor.lib;ck2.lib;InterfaceControls.lib;CKControls.lib") write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_ATTACH_REF', virtools_attach_ref)
write_macro(dom, node_property_group, node_item_group, 'SQLITE_ATTACH_REF', sqlite_attach_ref) write_macro(dom, node_property_group, node_item_group, 'SQLITE_ATTACH_REF', sqlite_attach_ref)
# ======================== write extra compile
if input_virtools_version == '21':
header_item_group = dom.createElement('ItemGroup')
cpp_item_group = dom.createElement('ItemGroup')
bml_virtools_path = os.path.join(input_bml_path, 'virtools')
for folderName, subfolders, filenames in os.walk(bml_virtools_path):
for filename in filenames:
write_cl(dom, header_item_group, cpp_item_group, os.path.join(folderName, filename))
root.appendChild(header_item_group)
root.appendChild(cpp_item_group)
# ======================== output # ======================== output
with open('./SuperScriptMaterializer/Virtools.props', 'w', encoding='utf-8') as f: with open('./SuperScriptMaterializer/Virtools.props', 'w', encoding='utf-8') as f: