Skip to content

Commit a9ef5f3

Browse files
committed
Use class instead of string for BuildVariants
1 parent cbaf278 commit a9ef5f3

File tree

1 file changed

+60
-31
lines changed

1 file changed

+60
-31
lines changed

build.py

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,63 +17,92 @@
1717
GIT_TAG = GIT_REF.split("/")[-1]
1818
print(f"--- Git Ref: {GIT_REF} Git Tag: {GIT_TAG} ---")
1919

20+
chapter_to_chapter_number = {
21+
"onikakushi": 1,
22+
"watanagashi": 2,
23+
"tatarigoroshi": 3,
24+
"himatsubushi": 4,
25+
"meakashi": 5,
26+
"tsumihoroboshi": 6,
27+
"minagoroshi": 7,
28+
"matsuribayashi": 8,
29+
"rei": 9,
30+
}
31+
32+
class BuildVariant:
33+
def __init__(self,chapter, unity, system, target_crc32=None):
34+
self.chapter = chapter
35+
self.unity = unity
36+
self.system = system
37+
self.target_crc32 = target_crc32
38+
self.chapter_number = chapter_to_chapter_number[chapter]
39+
self.data_dir = f"HigurashiEp{self.chapter_number}_Data"
40+
41+
def get_build_command(self) -> str:
42+
args = [self.chapter, self.unity, self.system]
43+
44+
if self.target_crc32 is not None:
45+
args.append(self.target_crc32)
46+
47+
return " ".join(args)
48+
2049
# List of build variants for any given chapter
2150
#
2251
# There must be a corresponding vanilla sharedassets0.assets file located at:
2352
# assets\vanilla\{CHAPTER_NAME}[-{CRC32}]\{OS}-{UNITY_VERSION}\sharedassets0.assets
2453
# for each entry.
2554
chapter_to_build_variants = {
2655
"onikakushi": [
27-
"onikakushi 5.2.2f1 win",
28-
"onikakushi 5.2.2f1 unix",
56+
BuildVariant("onikakushi", "5.2.2f1", "win"),
57+
BuildVariant("onikakushi", "5.2.2f1", "unix"),
2958
],
3059
"watanagashi": [
31-
"watanagashi 5.2.2f1 win",
32-
"watanagashi 5.2.2f1 unix"
60+
BuildVariant("watanagashi", "5.2.2f1", "win"),
61+
BuildVariant("watanagashi", "5.2.2f1", "unix"),
3362
],
3463
"tatarigoroshi": [
35-
"tatarigoroshi 5.4.0f1 win",
36-
"tatarigoroshi 5.4.0f1 unix",
37-
"tatarigoroshi 5.3.5f1 win",
38-
"tatarigoroshi 5.3.4p1 win",
39-
"tatarigoroshi 5.3.4p1 unix",
64+
BuildVariant("tatarigoroshi", "5.4.0f1", "win"),
65+
BuildVariant("tatarigoroshi", "5.4.0f1", "unix"),
66+
BuildVariant("tatarigoroshi", "5.3.5f1", "win"),
67+
BuildVariant("tatarigoroshi", "5.3.4p1", "win"),
68+
BuildVariant("tatarigoroshi", "5.3.4p1", "unix"),
4069
],
4170
"himatsubushi": [
42-
"himatsubushi 5.4.1f1 win",
43-
"himatsubushi 5.4.1f1 unix"
71+
BuildVariant("himatsubushi", "5.4.1f1", "win"),
72+
BuildVariant("himatsubushi", "5.4.1f1", "unix"),
4473
],
4574
"meakashi": [
46-
"meakashi 5.5.3p3 win",
47-
"meakashi 5.5.3p3 unix",
48-
"meakashi 5.5.3p1 win",
49-
"meakashi 5.5.3p1 unix",
75+
BuildVariant("meakashi", "5.5.3p3", "win"),
76+
BuildVariant("meakashi", "5.5.3p3", "unix"),
77+
BuildVariant("meakashi", "5.5.3p1", "win"),
78+
BuildVariant("meakashi", "5.5.3p1", "unix"),
5079
],
5180
"tsumihoroboshi": [
52-
"tsumihoroboshi 5.5.3p3 win",
53-
"tsumihoroboshi 5.5.3p3 unix"
81+
BuildVariant("tsumihoroboshi", "5.5.3p3", "win"),
82+
BuildVariant("tsumihoroboshi", "5.5.3p3", "unix"),
5483
# While GOG Windows is ver 5.6.7f1, we actually downgrade back to 5.5.3p3 in the installer, so we don't need this version.
5584
#'tsumihoroboshi 5.6.7f1 win'
5685
],
5786
"minagoroshi": [
58-
"minagoroshi 5.6.7f1 win",
59-
"minagoroshi 5.6.7f1 unix"
87+
BuildVariant("minagoroshi", "5.6.7f1", "win"),
88+
BuildVariant("minagoroshi", "5.6.7f1", "unix"),
6089
# While GOG Windows is ver 5.6.7f1, we actually downgrade back to 5.5.3p3 in the installer, so we don't need this version.
6190
# 'matsuribayashi 5.6.7f1 win'
6291
# 'matsuribayashi 5.6.7f1 unix'
6392
],
6493
"matsuribayashi": [
65-
"matsuribayashi 2017.2.5 unix",
94+
BuildVariant("matsuribayashi", "2017.2.5", "unix"),
6695
# Special version for GOG/Mangagamer Linux with SHA256:
6796
# A200EC2A85349BC03B59C8E2F106B99ED0CBAAA25FC50928BB8BA2E2AA90FCE9
6897
# CRC32L 51100D6D
69-
"matsuribayashi 2017.2.5 unix 51100D6D",
70-
"matsuribayashi 2017.2.5 win",
98+
BuildVariant("matsuribayashi", "2017.2.5", "unix", "51100D6D"),
99+
BuildVariant("matsuribayashi", "2017.2.5", "win"),
71100
],
72101
'rei': [
73-
'rei 2019.4.3 win',
74-
'rei 2019.4.4 win',
75-
'rei 2019.4.3 unix',
76-
'rei 2019.4.4 unix',
102+
BuildVariant("rei", "2019.4.3", "win"),
103+
BuildVariant("rei", "2019.4.4", "win"),
104+
BuildVariant("rei", "2019.4.3", "unix"),
105+
BuildVariant("rei", "2019.4.4", "unix"),
77106
],
78107
}
79108

@@ -122,7 +151,7 @@ def get_chapter_name_from_git_tag():
122151
return None
123152

124153

125-
def get_build_variants(selected_chapter: str) -> List[str]:
154+
def get_build_variants(selected_chapter: str) -> List[BuildVariant]:
126155
if selected_chapter == "all":
127156
commands = []
128157
for command in chapter_to_build_variants.values():
@@ -275,9 +304,9 @@ def save(self):
275304
)
276305

277306
# Build all the requested variants
278-
for command in build_variants:
279-
print(f"Building .assets for {command}...")
307+
for build_variant in build_variants:
308+
print(f"Building .assets for {build_variant.get_build_command()}...")
280309
if working_cargo:
281-
call(f"cargo run {command}")
310+
call(f"cargo run {build_variant.get_build_command()}")
282311
else:
283-
call(f"ui-compiler.exe {command}")
312+
call(f"ui-compiler.exe {build_variant.get_build_command()}")

0 commit comments

Comments
 (0)