This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
forked from SunakazeKun/SMG2-Project-Template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathci.py
142 lines (113 loc) · 3.87 KB
/
ci.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
130
131
132
133
134
135
136
137
138
139
140
141
142
import os
import subprocess
import sys
from pathlib import Path
from zipfile import ZipFile
from glob import glob
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
BUILD = dep("build.py", "Build script")
SYATI = dep("deps\\Syati", "Syati").absolute()
SYATI_SETUP = dep("deps\\syatisetup.exe", "SyatiSetup").absolute()
HOME_DIR = dep(__file__, "ci.py").parent.absolute()
ZIP = Path("PT Debug.zip").absolute()
if os.path.exists("deps") != True:
os.mkdir("deps")
os.chdir("deps")
if os.path.exists("CodeWarrior") != True and os.path.exists("Kamek") != True:
subprocess.call(SYATI_SETUP)
os.chdir("syati")
if os.path.exists("deps") != True:
os.mkdir("deps")
os.chdir("deps")
if os.path.exists("CodeWarrior") != True and os.path.exists("Kamek") != True:
subprocess.call(SYATI_SETUP)
os.chdir(HOME_DIR)
def no_gle():
subprocess.call(f"python {BUILD} --nogle")
bins = glob("*.bin")
# Safety check
if len(bins) == 0 or len(bins) != 5:
print("Some CodeWarrior or Kamek error occured. Check above for it!")
exit(1)
os.chdir(SYATI)
subprocess.call("python buildloader.py")
with ZipFile(ZIP, "w") as w:
os.chdir("loader")
files = glob("*.xml")
for file in files:
p = Path(file)
w.write(p.absolute(), p.name)
files = glob("Loader*.bin")
for file in files:
p = Path(file)
w.write(p.absolute(), p.name)
os.chdir(HOME_DIR)
for entry,_,_ in os.walk("SMG2PTD"):
if entry != "SMG2PTD":
entry = Path(entry)
for file in entry.glob("*.*"):
idx = str(file).index("\\")
name = str(file)[idx+1:]
w.write(file, name)
files = glob("CustomCode*.bin")
for file in files:
p = Path(file)
w.write(p.absolute(), f"CustomCode\\{p.name}")
def with_gle():
subprocess.call(f"python {BUILD} --gle")
bins = glob("*.bin")
# Safety check
if len(bins) == 0 or len(bins) != 5:
print("Some CodeWarrior or Kamek error occured. Check above for it!")
exit(1)
os.chdir(SYATI)
subprocess.call("python buildloader.py")
with ZipFile(ZIP.with_name("PT Debug with GLE.zip"), "w") as w:
os.chdir("loader")
files = glob("*.xml")
for file in files:
# GLE does not currently support Korean or Tiawan regions.
if "KOR" in file or "TWN" in file:
continue
p = Path(file)
w.write(p.absolute(), p.name)
files = glob("Loader*.bin")
for file in files:
# GLE does not currently support Korean or Tiawan regions.
if "K" in file or "W" in file:
continue
p = Path(file)
w.write(p.absolute(), p.name)
os.chdir(HOME_DIR)
for entry,_,_ in os.walk("SMG2PTD"):
if entry != "SMG2PTD":
entry = Path(entry)
for file in entry.glob("*.*"):
# GLE does not currently support Korean or Tiawan regions.
if "K" in file.name or "W" in file.name:
continue
idx = str(file).index("\\")
name = str(file)[idx+1:]
w.write(file, name)
files = glob("CustomCode*.bin")
for file in files:
# GLE does not currently support Korean or Tiawan regions.
if "KOR" in file or "TWN" in file:
continue
p = Path(file)
w.write(p.absolute(), f"CustomCode\\{p.name}")
no_gle()
files = glob("*.bin")
for file in files:
os.remove(file)
with_gle()
files = glob("*.bin")
for file in files:
os.remove(file)