Compress foresta.rel, add in orthrus to tools for future RARC usage

This commit is contained in:
Cuyler36
2024-11-12 15:33:54 -05:00
parent 78e8c6b9f4
commit 0bee7dbc04
4 changed files with 73 additions and 10 deletions
+17
View File
@@ -82,6 +82,22 @@ def wibo_url(tag: str) -> str:
return f"{repo}/releases/download/{tag}/wibo"
def orthrus_url(tag: str) -> str:
uname = platform.uname()
suffix = ""
system = uname.system.lower()
if system == "darwin":
system = "macos"
elif system == "windows":
suffix = ".exe"
arch = uname.machine.lower()
if arch == "amd64":
arch = "x86_64"
repo = "https://github.com/NWPlayer123/Orthrus"
return f"{repo}/releases/download/{tag}/orthrus-{system}-{arch}{suffix}"
TOOLS: Dict[str, Callable[[str], str]] = {
"binutils": binutils_url,
"compilers": compilers_url,
@@ -89,6 +105,7 @@ TOOLS: Dict[str, Callable[[str], str]] = {
"objdiff-cli": objdiff_cli_url,
"sjiswrap": sjiswrap_url,
"wibo": wibo_url,
"orthrus": orthrus_url,
}
+40 -3
View File
@@ -140,6 +140,8 @@ class ProjectConfig:
self.sjiswrap_path: Optional[Path] = None # If None, download
self.objdiff_tag: Optional[str] = None # Git tag
self.objdiff_path: Optional[Path] = None # If None, download
self.orthrus_tag: Optional[str] = None # Git tag
self.orthrus_path: Optional[Path] = None # If None, download
# Project config
self.non_matching: bool = False
@@ -366,6 +368,7 @@ def generate_build_ninja(
build_path = config.out_path()
progress_path = build_path / "progress.json"
report_path = build_path / "report.json"
foresta_szs_path = build_path / "foresta" / "foresta.rel.szs"
build_tools_path = config.build_dir / "tools"
download_tool = config.tools_dir / "download_tool.py"
n.rule(
@@ -473,6 +476,22 @@ def generate_build_ninja(
else:
sys.exit("ProjectConfig.sjiswrap_tag missing")
if config.orthrus_path:
orthrus = config.orthrus_path
elif config.orthrus_tag:
orthrus = build_tools_path / f"orthrus{EXE}"
n.build(
outputs=orthrus,
rule="download_tool",
implicit=download_tool,
variables={
"tool": "orthrus",
"tag": config.orthrus_tag,
},
)
else:
sys.exit("ProjectConfig.orthrus_tag missing")
wrapper = config.compiler_wrapper()
# Only add an implicit dependency on wibo if we download it
wrapper_implicit: Optional[Path] = None
@@ -530,7 +549,7 @@ def generate_build_ninja(
n.build(
outputs="tools",
rule="phony",
inputs=[dtk, sjiswrap, wrapper, compilers, binutils, objdiff],
inputs=[dtk, sjiswrap, wrapper, compilers, binutils, objdiff, orthrus],
)
n.newline()
@@ -1013,6 +1032,11 @@ def generate_build_ninja(
rspfile="$rspfile",
rspfile_content="$in_newline",
)
n.rule(
name="compressrel",
command=f"{dtk} yaz0 compress $in -o $out",
description="Compress REL"
)
generated_rels: List[str] = []
for idx, link in enumerate(build_config["links"]):
# Map module names to link steps
@@ -1041,6 +1065,12 @@ def generate_build_ninja(
rels_to_generate,
)
)
rel_compressed_outputs = list(
map(
lambda step: f"{step.output()}.szs",
rels_to_generate
)
)
rel_names = list(
map(
lambda step: step.name,
@@ -1060,6 +1090,13 @@ def generate_build_ninja(
},
order_only="post-link",
)
n.build(
outputs=rel_compressed_outputs,
rule="compressrel",
inputs=rel_outputs,
implicit=[dtk],
order_only="post-link",
)
n.newline()
# Add all build steps needed post-build (re-building archives and such)
@@ -1239,9 +1276,9 @@ def generate_build_ninja(
if config.non_matching:
n.default(link_outputs)
elif config.progress:
n.default(progress_path)
n.default([progress_path, foresta_szs_path])
else:
n.default(ok_path)
n.default([ok_path, foresta_szs_path])
else:
n.default(build_config_path)