update cfg creation script

This commit is contained in:
yyc12345 2022-07-26 17:15:35 +08:00
parent 73a2c9f14a
commit 79d973adb1
3 changed files with 168 additions and 91 deletions

View File

@ -20,7 +20,7 @@
按如下格式运行指令: 按如下格式运行指令:
``` ```
python3 mk_materializer_cfg.py [plugin|standalone] [21|25|35|40|50] [virtools_root_path] [sqlite_header] [sqlite_lib] [sqlite attach ref] [bml path] python3 mk_materializer_cfg.py [plugin|standalone] [21|25|35|40|50] [virtools_root_path] [sqlite_header] [sqlite_lib] [bml path]
``` ```
每一项参数的含义: 每一项参数的含义:
@ -28,9 +28,8 @@ python3 mk_materializer_cfg.py [plugin|standalone] [21|25|35|40|50] [virtools_ro
* `[plugin|standalone]`:编译为插件还是独立程序 * `[plugin|standalone]`:编译为插件还是独立程序
* `[21|25|35|40|50]`Virtools版本 * `[21|25|35|40|50]`Virtools版本
* `[virtools_root_path]`Virtools Dev的根目录用于Virtools SDK的头文件链接库的寻找也决定程序编译后的输出位置 * `[virtools_root_path]`Virtools Dev的根目录用于Virtools SDK的头文件链接库的寻找也决定程序编译后的输出位置
* `[sqlite_header]`SQlite头文件路径 * `[sqlite_header]`SQlite头文件路径通常来说指向SQlite头文件所在的文件夹
* `[sqlite_lib]`SQlite链接库的路径用于找到下一项 * `[sqlite_lib]`SQlite链接库的路径通常来说是指向`sqlite3.lib`的路径
* `[sqlite attach ref]`SQlite链接库通常来说是`sqlite3.lib`
* `[bml path]`BML的路径只有在以Virtools 2.1为目标编译时才有用 * `[bml path]`BML的路径只有在以Virtools 2.1为目标编译时才有用
以下是一些指令示例: 以下是一些指令示例:

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?><Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
@ -16,7 +15,7 @@
<RootNamespace>SuperScriptMaterializer</RootNamespace> <RootNamespace>SuperScriptMaterializer</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup> </PropertyGroup>
<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>v100</PlatformToolset> <PlatformToolset>v100</PlatformToolset>
<UseOfMfc>Dynamic</UseOfMfc> <UseOfMfc>Dynamic</UseOfMfc>
@ -31,18 +30,18 @@
<UseOfMfc>Dynamic</UseOfMfc> <UseOfMfc>Dynamic</UseOfMfc>
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">
</ImportGroup> </ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="Virtools.props" /> <Import Project="Virtools.props"/>
</ImportGroup> </ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="Virtools.props" /> <Import Project="Virtools.props"/>
</ImportGroup> </ImportGroup>
<ImportGroup Label="Shared"> <ImportGroup Label="Shared">
</ImportGroup> </ImportGroup>
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros"/>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(VIRTOOLS_OUTPUT_PATH)</OutDir> <OutDir>$(VIRTOOLS_OUTPUT_PATH)</OutDir>
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
@ -64,7 +63,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);$(VIRTOOLS_EXTRA_MACRO);$(BML_SPECIAL_MACRO);VX_MEM_RELEASE;$(VIRTOOLS_BUILD_TYPE);%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WINDOWS;_USRDLL;$(VIRTOOLS_VER);$(VIRTOOLS_STD_MACRO);$(VIRTOOLS_EXTRA_MACRO);VX_MEM_RELEASE;$(VIRTOOLS_BUILD_TYPE);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<DisableSpecificWarnings>4819;4996</DisableSpecificWarnings> <DisableSpecificWarnings>4819;4996</DisableSpecificWarnings>
@ -74,7 +73,7 @@
</Link> </Link>
<Link> <Link>
<AdditionalLibraryDirectories>$(SQLITE_LIB_PATH);$(VIRTOOLS_LIB_PATH);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(SQLITE_LIB_PATH);$(VIRTOOLS_LIB_PATH);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(VIRTOOLS_ATTACH_REF);$(SQLITE_ATTACH_REF);%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>$(SQLITE_LIB_FILENAME);$(VIRTOOLS_LIB_FILENAME);%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(VIRTOOLS_OUTPUT_PATH)SuperScriptMaterializer.pdb</ProgramDatabaseFile> <ProgramDatabaseFile>$(VIRTOOLS_OUTPUT_PATH)SuperScriptMaterializer.pdb</ProgramDatabaseFile>
<ModuleDefinitionFile>$(VIRTOOLS_MODULE_DEFINE)</ModuleDefinitionFile> <ModuleDefinitionFile>$(VIRTOOLS_MODULE_DEFINE)</ModuleDefinitionFile>
@ -93,7 +92,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);$(VIRTOOLS_EXTRA_MACRO);$(BML_SPECIAL_MACRO);VX_MEM_RELEASE;_RELEASE;$(VIRTOOLS_BUILD_TYPE);%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WINDOWS;_USRDLL;$(VIRTOOLS_VER);$(VIRTOOLS_STD_MACRO);$(VIRTOOLS_EXTRA_MACRO);VX_MEM_RELEASE;_RELEASE;$(VIRTOOLS_BUILD_TYPE);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<DisableSpecificWarnings>4819;4996</DisableSpecificWarnings> <DisableSpecificWarnings>4819;4996</DisableSpecificWarnings>
</ClCompile> </ClCompile>
@ -103,36 +102,36 @@
<ModuleDefinitionFile>$(VIRTOOLS_MODULE_DEFINE)</ModuleDefinitionFile> <ModuleDefinitionFile>$(VIRTOOLS_MODULE_DEFINE)</ModuleDefinitionFile>
<OutputFile>$(VIRTOOLS_OUTPUT_PATH)SuperScriptMaterializer.$(VIRTOOLS_BUILD_SUFFIX)</OutputFile> <OutputFile>$(VIRTOOLS_OUTPUT_PATH)SuperScriptMaterializer.$(VIRTOOLS_BUILD_SUFFIX)</OutputFile>
<AdditionalLibraryDirectories>$(VIRTOOLS_LIB_PATH);$(SQLITE_LIB_PATH);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(VIRTOOLS_LIB_PATH);$(SQLITE_LIB_PATH);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(VIRTOOLS_ATTACH_REF);$(SQLITE_ATTACH_REF);%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>$(SQLITE_LIB_FILENAME);$(VIRTOOLS_LIB_FILENAME);%(AdditionalDependencies)</AdditionalDependencies>
<ProgramDatabaseFile>$(VIRTOOLS_OUTPUT_PATH)SuperScriptMaterializer.pdb</ProgramDatabaseFile> <ProgramDatabaseFile>$(VIRTOOLS_OUTPUT_PATH)SuperScriptMaterializer.pdb</ProgramDatabaseFile>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="database.h" /> <ClInclude Include="database.h"/>
<ClInclude Include="data_export.h" /> <ClInclude Include="data_export.h"/>
<ClInclude Include="env_export.h" /> <ClInclude Include="env_export.h"/>
<ClInclude Include="resource.h" /> <ClInclude Include="resource.h"/>
<ClInclude Include="script_export.h" /> <ClInclude Include="script_export.h"/>
<ClInclude Include="shared_export.h" /> <ClInclude Include="shared_export.h"/>
<ClInclude Include="virtools_compatible.h" /> <ClInclude Include="virtools_compatible.h"/>
<ClInclude Include="vt_menu.h" /> <ClInclude Include="vt_menu.h"/>
<ClInclude Include="stdafx.h" /> <ClInclude Include="stdafx.h"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="database.cpp" /> <ClCompile Include="database.cpp"/>
<ClCompile Include="data_export.cpp" /> <ClCompile Include="data_export.cpp"/>
<ClCompile Include="env_export.cpp" /> <ClCompile Include="env_export.cpp"/>
<ClCompile Include="main.cpp" /> <ClCompile Include="main.cpp"/>
<ClCompile Include="script_export.cpp" /> <ClCompile Include="script_export.cpp"/>
<ClCompile Include="shared_export.cpp" /> <ClCompile Include="shared_export.cpp"/>
<ClCompile Include="virtools_compatible.cpp" /> <ClCompile Include="virtools_compatible.cpp"/>
<ClCompile Include="vt_menu.cpp" /> <ClCompile Include="vt_menu.cpp"/>
<ClCompile Include="vt_player.cpp" /> <ClCompile Include="vt_player.cpp"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="SuperScriptMaterializer.def" /> <None Include="SuperScriptMaterializer.def"/>
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>
</Project> </Project>

View File

@ -12,29 +12,29 @@ valid_build_type = (
build_type_plugin build_type_plugin
) )
virtools_attach_ref_plugin_dict = { virtools_attached_lib_plugin_dict = {
"21": "vxmath.lib;DllEditor.lib;ck2.lib;InterfaceControls.lib;CKControls.lib", "21": "",
"25": "vxmath.lib;DllEditor.lib;ck2.lib;InterfaceControls.lib;CKControls.lib", "25": "",
"35": "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", "40": "vxmath.lib;DllEditor.lib;ck2.lib;InterfaceControls.lib;CKControls.lib",
"50": "vxmath.lib;DllEditor.lib;ck2.lib;InterfaceControls.lib;CKControls.lib" "50": "vxmath.lib;DllEditor.lib;ck2.lib;InterfaceControls.lib;CKControls.lib"
} }
virtools_attach_ref_standalone_dict = { virtools_attached_lib_standalone_dict = {
"21": "", "21": "VxMath.lib;CK2.lib",
"25": "VxMath.lib;CK2.lib", "25": "VxMath.lib;CK2.lib",
"35": "vxmath.lib;ck2.lib", "35": "vxmath.lib;ck2.lib",
"40": "vxmath.lib;ck2.lib", "40": "vxmath.lib;ck2.lib",
"50": "vxmath.lib;ck2.lib" "50": "vxmath.lib;ck2.lib"
} }
virtools_extra_macro_plugin_dict = { virtools_std_macro_plugin_dict = {
"21": "", "21": "",
"25": "", "25": "",
"35": "_CRT_SECURE_NO_WARNINGS", "35": "_CRT_SECURE_NO_WARNINGS",
"40": "_CRT_SECURE_NO_WARNINGS", "40": "_CRT_SECURE_NO_WARNINGS",
"50": "" "50": ""
} }
virtools_extra_macro_standalone_dict = { virtools_std_macro_standalone_dict = {
"21": "_DEBUG", "21": "_DEBUG",
"25": "_CRT_SECURE_NO_WARNINGS;_DEBUG", "25": "_CRT_SECURE_NO_WARNINGS;_DEBUG",
"35": "_CRT_SECURE_NO_WARNINGS;_DEBUG", "35": "_CRT_SECURE_NO_WARNINGS;_DEBUG",
@ -63,6 +63,11 @@ valid_virtools_plugin_ver = (
"50" "50"
) )
valid_vt21_reverse_work_type = (
'gamepiaynmo',
'doyagu'
)
# ======================== 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)
@ -101,74 +106,139 @@ def get_executable_virtools(vt_ver):
elif vt_ver == '50': elif vt_ver == '50':
return 'devr.exe' return 'devr.exe'
# ======================== requirement check # ======================== requirement get
if len(sys.argv) != 8: # get basic cfg, such as build type, and vt version
print("Error parameter!") while True:
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]") input_build_type = input('Choose build type(plugin, standalone): ')
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"') if input_build_type not in valid_build_type:
sys.exit(1) print("Invalid build type!")
else:
break
input_build_type = sys.argv[1] valid_vtver_for_this_type = valid_virtools_plugin_ver if input_build_type == build_type_plugin else valid_virtools_standalone_ver
if input_build_type not in valid_build_type: while True:
print("Invalid build_type!") input_virtools_version = input('Choose virtools version({}): '.format(', '.join(valid_vtver_for_this_type)))
sys.exit(1) if input_virtools_version not in valid_vtver_for_this_type:
print("Invalid virtools version!")
else:
break
input_virtools_version = sys.argv[2] # collect sqlite library data
if input_build_type == build_type_standalone and input_virtools_version not in valid_virtools_standalone_ver: while True:
print("Invalid virtools_version!") input_sqlite_header_path = input('SQLite header folder path: ')
sys.exit(1) if not os.path.isdir(input_sqlite_header_path):
elif input_build_type == build_type_plugin and input_virtools_version not in valid_virtools_plugin_ver: print("Invalid SQLite header folder!")
print("Invalid virtools_version!") else:
sys.exit(1) break
input_virtools_root_path = sys.argv[3] while True:
input_sqlite_header_path = sys.argv[4] input_sqlite_lib_path = input('SQLite lib file path: ')
input_sqlite_lib_path = sys.argv[5] if not os.path.isfile(input_sqlite_lib_path):
input_sqlite_attach_ref = sys.argv[6] print("Invalid SQLite lib file!")
input_bml_path = sys.argv[7] else:
break
# collect virtools sdk data
if input_virtools_version != '21':
# if we do not use virtools 21, we order get original virtools SDK
while True:
input_virtools_root_path = input('Virtools root path: ')
if not os.path.isdir(input_virtools_root_path):
print("Invalid virtools root path!")
else:
break
else:
# if we are in virtools 21 environment, we have 2 choose aboud used virtools sdk
# one is gamepiaynmo and another one is doyagu
# allow user choose a proper one from them and input their corresponding path about cloned repository.
# also order a proper runtime environment for debug
while True:
input_vt21_reverse_work_type = input('Choose Virtools 2.1 reverse work source(gamepiaynmo, doyagu): ')
if input_vt21_reverse_work_type not in valid_vt21_reverse_work_type:
print("Invalid Virtools 2.1 reverse work source!")
else:
break
while True:
input_vt21_reverse_work_path = input('Virtools 2.1 reverse work root path: ')
if not os.path.isdir(input_vt21_reverse_work_path):
print("Invalid Virtools 2.1 reverse work root path!")
else:
break
while True:
input_vt21_runtime_path = input('Virtools 2.1 runtime path: ')
if not os.path.isdir(input_vt21_runtime_path):
print("Invalid Virtools 2.1 runtime path!")
else:
break
# ======================== construct some path # ======================== construct some path
# .......todo # .......todo
# build sqlite related data
sqlite_header_path = input_sqlite_header_path sqlite_header_path = input_sqlite_header_path
sqlite_lib_path = input_sqlite_lib_path (sqlite_lib_path, sqlite_lib_filename) = os.path.split(input_sqlite_lib_path)
sqlite_attach_ref = input_sqlite_attach_ref
# virtools version macro
virtools_ver = 'VIRTOOLS_' + input_virtools_version virtools_ver = 'VIRTOOLS_' + input_virtools_version
virtools_debug_root = input_virtools_root_path
# build type macro, and some essential build macros, linked lib
if input_build_type == build_type_plugin: 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_module_define = 'SuperScriptMaterializer.def' virtools_module_define = 'SuperScriptMaterializer.def'
virtools_debug_commandline = '' virtools_attached_lib = virtools_attached_lib_plugin_dict[input_virtools_version]
virtools_debug_target = os.path.join(input_virtools_root_path, executable_virtools[input_virtools_version]) virtools_std_macro = virtools_std_macro_plugin_dict[input_virtools_version]
virtools_output_path = os.path.join(input_virtools_root_path, 'InterfacePlugins')
virtools_attach_ref = virtools_attach_ref_plugin_dict[input_virtools_version]
virtools_extra_macro = virtools_extra_macro_plugin_dict[input_virtools_version]
elif input_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_module_define = '' virtools_module_define = ''
virtools_attached_lib = virtools_attached_lib_standalone_dict[input_virtools_version]
virtools_std_macro = virtools_std_macro_standalone_dict[input_virtools_version]
# debug configuration and output path
if input_virtools_version == '21':
# virtools 21 onlt allow standalone build type
# we copy it and specific some field
virtools_debug_root = iinput_vt21_runtime_path
virtools_debug_commandline = 'test.nmo test_script.db test_env.db'
virtools_debug_target = os.path.join(input_vt21_runtime_path, 'SuperScriptMaterializer.exe')
virtools_output_path = input_vt21_runtime_path
else:
# in original virtools sdk environment
# output file according to build type
virtools_debug_root = input_virtools_root_path
if input_build_type == build_type_plugin:
virtools_debug_commandline = ''
virtools_debug_target = os.path.join(input_virtools_root_path, executable_virtools[input_virtools_version])
virtools_output_path = os.path.join(input_virtools_root_path, 'InterfacePlugins')
else:
virtools_debug_commandline = 'test.nmo test_script.db test_env.db' virtools_debug_commandline = 'test.nmo test_script.db test_env.db'
virtools_debug_target = os.path.join(input_virtools_root_path, 'SuperScriptMaterializer.exe') virtools_debug_target = os.path.join(input_virtools_root_path, 'SuperScriptMaterializer.exe')
virtools_output_path = input_virtools_root_path virtools_output_path = input_virtools_root_path
virtools_attach_ref = virtools_attach_ref_standalone_dict[input_virtools_version]
virtools_extra_macro = virtools_extra_macro_standalone_dict[input_virtools_version]
# make sure the last char of output_path is slash # 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 + '\\'
# in virtools 2.1, we use bml, so we need add bml macro and set virtools header and virtools lib to blank # virtools compile and link options
# because all virtools file have been imported in project # we need do different strategy for virtools 2.1 and anything else virtools version
if input_virtools_version == '21': if input_virtools_version == '21':
# the reverse work of doyagu and gamepiaynmo is different, so we need to
# use them differently
if input_vt21_reverse_work_type == 'doyagu':
# doyagu do not need any extra macro
virtools_extra_macro = ''
virtools_header_path = os.path.join(input_vt21_reverse_work_path, 'Include')
virtools_lib_path = os.path.join(input_vt21_reverse_work_path, 'Lib')
else:
# gamepiaynmo need a special macro but his proj do not need any link,
# instead, we need compile it fully which will be implemented in following code
bml_special_macro = 'BML_EXPORT=' bml_special_macro = 'BML_EXPORT='
virtools_header_path = os.path.join(input_bml_path, 'virtools') virtools_header_path = os.path.join(input_vt21_reverse_work_path, 'virtools')
virtools_lib_path = '' virtools_lib_path = ''
else: else:
bml_special_macro = '' virtools_extra_macro = ''
if input_virtools_version == '25': if input_virtools_version == '25':
virtools_header_path = os.path.join(input_virtools_root_path, 'Virtools_SDK/Includes') virtools_header_path = os.path.join(input_virtools_root_path, 'Virtools_SDK/Includes')
virtools_lib_path = os.path.join(input_virtools_root_path, 'Virtools_SDK/Lib') virtools_lib_path = os.path.join(input_virtools_root_path, 'Virtools_SDK/Lib')
@ -179,6 +249,7 @@ else:
# ======================== create document # ======================== create document
# create header
dom = minidom.getDOMImplementation().createDocument(None, 'Project', None) dom = minidom.getDOMImplementation().createDocument(None, 'Project', None)
root = dom.documentElement root = dom.documentElement
root.setAttribute('ToolsVersion', '4.0') root.setAttribute('ToolsVersion', '4.0')
@ -190,6 +261,7 @@ root.appendChild(cache)
# ======================== write build type # ======================== write build type
# due to build chain v100 shit design, this configuration onlt can be modified in .vcxproj # due to build chain v100 shit design, this configuration onlt can be modified in .vcxproj
# so these code were annotated
''' '''
for bt in ('Debug', 'Release'): for bt in ('Debug', 'Release'):
node_build_type = dom.createElement('PropertyGroup') node_build_type = dom.createElement('PropertyGroup')
@ -235,29 +307,36 @@ 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)
# build type distinguish macro
write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_VER', virtools_ver)
write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_BUILD_TYPE', virtools_build_type)
# header and libs
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, 'VIRTOOLS_LIB_FILENAME', virtools_attached_lib)
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)
write_macro(dom, node_property_group, node_item_group, 'SQLITE_LIB_PATH', sqlite_lib_path) write_macro(dom, node_property_group, node_item_group, 'SQLITE_LIB_PATH', sqlite_lib_path)
write_macro(dom, node_property_group, node_item_group, 'SQLITE_LIB_FILENAME', sqlite_lib_filename)
# output and debug
write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_OUTPUT_PATH', virtools_output_path) write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_OUTPUT_PATH', virtools_output_path)
write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_BUILD_TYPE', virtools_build_type)
write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_DEBUG_TARGET', virtools_debug_target) write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_DEBUG_TARGET', virtools_debug_target)
write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_DEBUG_ROOT', virtools_debug_root) write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_DEBUG_ROOT', virtools_debug_root)
write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_DEBUG_COMMANDLINE', virtools_debug_commandline) write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_DEBUG_COMMANDLINE', virtools_debug_commandline)
write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_BUILD_SUFFIX', virtools_build_suffix) # essential build macro
write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_VER', virtools_ver) write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_STD_MACRO', virtools_std_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', 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, 'VIRTOOLS_MODULE_DEFINE', virtools_module_define)
write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_EXTRA_MACRO', virtools_extra_macro) write_macro(dom, node_property_group, node_item_group, 'VIRTOOLS_EXTRA_MACRO', virtools_extra_macro)
# misc macro
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_MODULE_DEFINE', virtools_module_define)
# ======================== write extra compile # ======================== write extra compile
if input_virtools_version == '21': # if we using gamepiaynmp vt21 reverse work
# we need add all his cpp file into our compile list
if input_virtools_version == '21' and input_vt21_reverse_work_type == 'gamepiaynmo':
header_item_group = dom.createElement('ItemGroup') header_item_group = dom.createElement('ItemGroup')
cpp_item_group = dom.createElement('ItemGroup') cpp_item_group = dom.createElement('ItemGroup')
bml_virtools_path = os.path.join(input_bml_path, 'virtools') bml_virtools_path = os.path.join(input_vt21_reverse_work_path, 'virtools')
for folderName, subfolders, filenames in os.walk(bml_virtools_path): for folderName, subfolders, filenames in os.walk(bml_virtools_path):
for filename in filenames: for filename in filenames:
write_cl(dom, header_item_group, cpp_item_group, os.path.join(folderName, filename)) write_cl(dom, header_item_group, cpp_item_group, os.path.join(folderName, filename))