-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
59 lines (51 loc) · 1.73 KB
/
build.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
import os
from pathlib import Path
from shutil import copy, move
from subprocess import run
HERE = Path(os.getcwd())
VANILLA = HERE / "Vanilla"
PATCHED = HERE / "Patched"
BUILD = ("dotnet", "build")
BINARIES = HERE / "Engine/bin/Debug/net452"
MONOMOD = BINARIES / "MonoMod.exe"
HOOKGEN = BINARIES / "MonoMod.RuntimeDetour.HookGen.exe"
GENARGS = ("--private",)
BACKUP = ".bak"
ENGINE = "Engine"
ENGINEDLL = "Engine.dll"
ENGINEMM = "Engine.mm.dll"
MMHOOK = "MMHOOK_Engine.dll"
MONOMODDED = "MONOMODDED_"
MONO = "Mono"
EXE = ".exe"
GAMEEXES = {"Bastion.exe"}
GAMEDATA = ENGINEDLL
SGGNL = "SGGNL.dll"
if not PATCHED.exists():
os.mkdir(PATCHED)
if m := tuple(filter(lambda x: (VANILLA / x).exists(), GAMEEXES)):
GAMEDATA = m[0]
BACKUPDATA = GAMEDATA + BACKUP
VBACKUPDATA = VANILLA / BACKUPDATA
VGAMEDATA = VANILLA / GAMEDATA
if VBACKUPDATA.is_file():
copy(VBACKUPDATA, VGAMEDATA)
copy(VGAMEDATA, PATCHED / BACKUPDATA)
run(BUILD)
for path in os.scandir(VANILLA):
if path.is_file():
copy(path, BINARIES / path.name)
if GAMEDATA in GAMEEXES:
game = GAMEDATA.replace(EXE, "")
copy(BINARIES / ENGINEMM, BINARIES / ENGINEMM.replace(ENGINE, game))
MMHOOK = MMHOOK.replace(ENGINE, game)
run((MONOMOD, BINARIES / GAMEDATA))
for path in os.scandir(BINARIES):
if path.is_file() and MONOMODDED in path.name:
move(path, BINARIES / path.name.replace(MONOMODDED,""))
run((HOOKGEN,) + GENARGS + (BINARIES / GAMEDATA,), cwd=BINARIES)
copy(BINARIES / MMHOOK, PATCHED / MMHOOK)
copy(BINARIES / GAMEDATA, PATCHED / GAMEDATA)
for path in os.scandir(BINARIES):
if path.is_file() and (path.name == SGGNL or path.name[:4] == MONO):
copy(path, PATCHED / path.name)