-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_build_win_bat.py
129 lines (97 loc) · 7.09 KB
/
generate_build_win_bat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import os
CPPVERSION="201103L" #C++11, change to "201703L" for C++17
def files_from_dir(dir, extension, filter=[]):
out = []
for f in os.listdir(dir):
if f.endswith(extension) and f not in filter:
out.append(os.path.join(dir, f))
return out
def convert_to_obj(files, obj_dir):
out = []
for f in files:
out.append(os.path.join(obj_dir, os.path.splitext(os.path.basename(f))[0] + ".obj"))
return out
def cl_line_obj(arguments, out_dir):
return "rmdir /S /Q {0}\nmkdir {0}\ncl /Fo:{0}/ /c {1}\n".format(out_dir, ' '.join(arguments))
def cl_line_link(arguments, linker_arguments):
return "cl /LD {} /link {}\n".format(' '.join(arguments), ' '.join(linker_arguments))
def cl_line_exe(arguments, linker_arguments):
return "cl {} /link {}\n".format(' '.join(arguments), ' '.join(linker_arguments))
def localise(command: str) -> str:
return "setlocal\n" + command + "endlocal\n"
jobs = 4
normal_build_args = ["/EHsc", "/Ox", "/MP{}".format(jobs), "/D ImTextureID=ImU64", f"/DUTF_CPP_CPLUSPLUS={CPPVERSION}", "/DCAPSTONE_USE_SYS_DYN_MEM"]
includes = ["dll", "ingame_overlay/deps/ImGui/backends", "overlay_experimental", "ingame_overlay/include/ingame_overlay", "ingame_overlay/include", "ingame_overlay/deps", "ingame_overlay/deps/ImGui", "ingame_overlay/deps/mini_detour/include", "ingame_overlay/src", "ingame_overlay/deps/System/include", "ingame_overlay/src/glad2/include", "ingame_overlay/src/vulkan_sdk/include", "ingame_overlay/deps/mini_detour/deps/capstone/include", "ingame_overlay/deps/System/include", "ingame_overlay/deps/System/deps/utfcpp/include"]
includes_32 = list(map(lambda a: '/I{}'.format(a), ["%PROTOBUF_X86_DIRECTORY%\\include\\"] + includes))
includes_64 = list(map(lambda a: '/I{}'.format(a), ["%PROTOBUF_X64_DIRECTORY%\\include\\"] + includes))
debug_build_args = []
release_build_args = ["/DEMU_RELEASE_BUILD", "/DNDEBUG"]
steamclient_build_args = ["/DSTEAMCLIENT_DLL"]
experimental_build_args = ["/DEMU_EXPERIMENTAL_BUILD", "/DCONTROLLER_SUPPORT", "/DEMU_OVERLAY", "/DCAPSTONE_HAS_X86"]
steamclient_experimental_build_args = experimental_build_args + steamclient_build_args
normal_linker_libs = ["Iphlpapi.lib", "Ws2_32.lib", "Shell32.lib"]
experimental_linker_libs = ["opengl32.lib", "Winmm.lib"] + normal_linker_libs
linker_32 = ['"%PROTOBUF_X86_LIBRARY%"']
linker_64 = ['"%PROTOBUF_X64_LIBRARY%"']
controller_deps = ["controller/gamepad.c"]
imgui_deps = files_from_dir("ingame_overlay/deps/ImGui", ".cpp") + ["ingame_overlay/deps/ImGui/backends/imgui_impl_dx9.cpp", "ingame_overlay/deps/ImGui/backends/imgui_impl_dx10.cpp", "ingame_overlay/deps/ImGui/backends/imgui_impl_dx11.cpp", "ingame_overlay/deps/ImGui/backends/imgui_impl_dx12.cpp", "ingame_overlay/deps/ImGui/backends/imgui_impl_win32.cpp", "ingame_overlay/deps/ImGui/backends/imgui_impl_opengl3.cpp", "ingame_overlay/deps/ImGui/backends/imgui_win_shader_blobs.cpp"]
proto_deps = list(map(lambda a: a.replace(".proto", ".pb.cc"), files_from_dir("dll", ".proto")))
all_deps = proto_deps + files_from_dir("detours", ".cpp") + controller_deps + imgui_deps + files_from_dir("ingame_overlay/deps/System", ".cpp")
sc_different_deps = ["flat.cpp", "dll.cpp"]
steam_deps = files_from_dir("dll", ".cpp", sc_different_deps)
overlay_deps = files_from_dir("overlay_experimental", ".cpp") + files_from_dir("ingame_overlay/src/windows", ".cpp", "Vulkan_Hook.cpp") + files_from_dir("ingame_overlay/src", ".cpp") + files_from_dir("ingame_overlay/deps/mini_detour/src", ".cpp") + files_from_dir("ingame_overlay/deps/mini_detour/deps/capstone", ".c") + files_from_dir("ingame_overlay/deps/System/src", ".cpp") + files_from_dir("ingame_overlay/deps/mini_detour/deps/capstone/arch/X86", ".c")
experimental_steam_deps = steam_deps + overlay_deps
sc_different_deps = list(map(lambda a: "dll/" + a, sc_different_deps))
regular_files = []
head = """@echo off
cd /d "%~dp0"
rmdir /S /Q release
mkdir release
mkdir release\experimental
mkdir release\experimental_steamclient
mkdir release\debug_experimental
mkdir release\debug_experimental_steamclient
call build_set_protobuf_directories.bat
"""
head_32bit = """"%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\\net.proto
call build_env_x86.bat
"""
head_64bit = """"%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\\net.proto
call build_env_x64.bat
"""
footer = """
copy Readme_release.txt release\Readme.txt
xcopy /s files_example\* release\\
copy Readme_experimental.txt release\experimental\Readme.txt
copy Readme_debug.txt release\debug_experimental\Readme.txt
copy steamclient_loader\ColdClientLoader.ini release\experimental_steamclient\\
call build_win_lobby_connect.bat
call build_win_find_interfaces.bat
"""
x86 = head_32bit
deps_folder = "deps"
sc_deps_folder = "deps_sc"
def generate_common(include_arch, linker_arch, steam_api_name, steamclient_name):
out = ""
out += cl_line_obj(normal_build_args + release_build_args + include_arch + all_deps, deps_folder)
out += cl_line_link(normal_build_args + release_build_args + include_arch + steam_deps + sc_different_deps + ["deps/net.pb.obj"] + linker_arch + normal_linker_libs, ["/debug:none", "/OUT:release\\{}".format(steam_api_name)])
debug_full_args = normal_build_args + debug_build_args + experimental_build_args + include_arch
out += cl_line_obj(debug_full_args + experimental_steam_deps, sc_deps_folder)
debug_full_dll_args = debug_full_args + sc_different_deps + convert_to_obj(all_deps, deps_folder) + convert_to_obj(experimental_steam_deps, sc_deps_folder) + linker_arch + experimental_linker_libs
out += cl_line_link(debug_full_dll_args, ["/OUT:release\debug_experimental\\{}".format(steam_api_name)])
out += cl_line_link(steamclient_build_args + debug_full_dll_args, ["/OUT:release\debug_experimental_steamclient\\{}".format(steamclient_name)])
release_full_args = normal_build_args + release_build_args + experimental_build_args + include_arch
out += cl_line_obj(release_full_args + experimental_steam_deps, sc_deps_folder)
release_full_dll_args = release_full_args + sc_different_deps + convert_to_obj(all_deps, deps_folder) + convert_to_obj(experimental_steam_deps, sc_deps_folder) + linker_arch + experimental_linker_libs
out += cl_line_link(release_full_dll_args, ["/debug:none", "/OUT:release\experimental\\{}".format(steam_api_name)])
out += cl_line_link(steamclient_build_args + release_full_dll_args, ["/debug:none", "/OUT:release\experimental_steamclient\\{}".format(steamclient_name)])
out += cl_line_link(release_build_args + experimental_build_args + ["steamclient.cpp"] + normal_build_args, ["/debug:none", "/OUT:release\experimental\\{}".format(steamclient_name)])
return out
x86 += generate_common(includes_32, linker_32, "steam_api.dll", "steamclient.dll")
x86 += cl_line_exe(files_from_dir("steamclient_loader", ".cpp") + ["advapi32.lib", "user32.lib"] + normal_build_args, ["/debug:none", "/OUT:release\experimental_steamclient\steamclient_loader.exe"])
x64 = head_64bit
x64 += generate_common(includes_64, linker_64, "steam_api64.dll", "steamclient64.dll")
#out = localise(out)
out = head + localise(x86) + localise(x64) + footer
with open("build_win_release_test.bat", "w") as f:
f.write(out)