This repository has been archived by the owner on Sep 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
buildloader.py
71 lines (47 loc) · 1.8 KB
/
buildloader.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
import os
import shutil
import subprocess
import sys
from pathlib import Path
def err(message: str):
print(f"Error: {message}")
sys.exit(1)
def dep(path, name):
path = Path(path)
if not os.path.exists(path):
err(f"{name} not found!")
return path
def prepare_bin():
if os.path.exists("bin"):
shutil.rmtree("bin")
os.makedirs("bin")
REGIONS = ["PAL", "USA", "JPN", "TWN", "KOR"]
MWCCEPPC = dep("deps/CodeWarrior/mwcceppc.exe", "CodeWarrior compiler")
KAMEK = dep("deps/Kamek/Kamek.exe", "Kamek linker")
SYMBOLS = dep("symbols", "Symbols folder")
def build(region: str):
compile_cmd = f"{MWCCEPPC} -c -Cpp_exceptions off -nodefaults -proc gekko -fp hard -lang=c++ -O4,s -inline on " \
f"-rtti off -sdata 0 -sdata2 0 -align powerpc -func_align 4 -str pool -enum int -DGEKKO " \
f"-i include -I- -i loader -D{region} loader/loader.cpp -o loader/loader.o"
kamek_cmd = f"{KAMEK} loader/loader.o -static=0x80001800 -externals={SYMBOLS}/{region}.txt " \
f"-output-riiv=bin/riivo_{region}.xml"
print(f"Building target {region}!")
if os.path.exists(f"deps/{region}.dol"):
kamek_cmd += f" -input-dol=deps/{region}.dol -output-dol=bin/{region}.dol"
if subprocess.call(compile_cmd, shell=True) != 0:
err("Compiling failed.")
if subprocess.call(kamek_cmd, shell=True) != 0:
err("Linking failed.")
print("Done!")
if __name__ == '__main__':
if len(sys.argv) < 2:
print("Did not specify a target region, building all targets!")
prepare_bin()
for region in REGIONS:
build(region)
else:
region = sys.argv[1]
if region not in REGIONS:
err(f"Invalid build target found: {region}")
prepare_bin()
build(region)