Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use crunch64 for compression #1189

Merged
merged 2 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,4 @@ build/
*.backup
*.crash

/tools/Yay0compress
/tools/n64crc
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pipeline {
sh 'curl -L "https://github.com/decompals/mips-gcc-egcs-2.91.66/releases/latest/download/mips-gcc-egcs-2.91.66-linux.tar.gz" | tar zx -C tools/build/cc/egcs'
sh 'pip install -U -r requirements.txt'
sh 'cargo install pigment64'
sh 'cargo install crunch64-cli'
sh './configure'
}
}
Expand Down
54 changes: 36 additions & 18 deletions tools/build/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@
ROOT = ROOT.relative_to(Path.cwd())

BUILD_TOOLS = Path("tools/build")
YAY0_COMPRESS_TOOL = f"{BUILD_TOOLS}/yay0/Yay0compress"
CRC_TOOL = f"{BUILD_TOOLS}/rom/n64crc"

PIGMENT = "pigment64"
PIGMENT_REQ_VERSION = "0.4.2"
PIGMENT64 = "pigment64"
CRUNCH64 = "crunch64"

RUST_TOOLS = [
(PIGMENT64, "pigment64", "0.4.2"),
(CRUNCH64, "crunch64-cli", "0.3.1"),
]


def exec_shell(command: List[str]) -> str:
Expand Down Expand Up @@ -212,7 +216,7 @@ def write_ninja_rules(
ninja.rule(
"pigment",
description="img($img_type) $in",
command=f"{PIGMENT} to-bin $img_flags -f $img_type -o $out $in",
command=f"{PIGMENT64} to-bin $img_flags -f $img_type -o $out $in",
)

ninja.rule(
Expand All @@ -224,7 +228,7 @@ def write_ninja_rules(
ninja.rule(
"yay0",
description="yay0 $in",
command=f"{BUILD_TOOLS}/yay0/Yay0compress $in $out",
command=f"crunch64 compress yay0 $in $out",
)

ninja.rule(
Expand Down Expand Up @@ -354,7 +358,6 @@ def write_ninja_for_tools(ninja: ninja_syntax.Writer):
command=f"cc -w $in -O3 -o $out",
)

ninja.build(YAY0_COMPRESS_TOOL, "cc_tool", f"{BUILD_TOOLS}/yay0/Yay0compress.c")
ninja.build(CRC_TOOL, "cc_tool", f"{BUILD_TOOLS}/rom/n64crc.c")


Expand Down Expand Up @@ -549,9 +552,7 @@ def build(
implicit = []
order_only = []

if task == "yay0":
implicit.append(YAY0_COMPRESS_TOOL)
elif task in ["cc", "cxx", "cc_modern"]:
if task in ["cc", "cxx", "cc_modern"]:
order_only.append("generated_code_" + self.version)
order_only.append("inc_img_bins_" + self.version)

Expand Down Expand Up @@ -1334,16 +1335,33 @@ def make_current(self, ninja: ninja_syntax.Writer):
print(f" ./configure --cpp {gcc_cpps[0]}")
exit(1)

try:
version = exec_shell([PIGMENT, "--version"]).split(" ")[1].strip()
version_err_msg = ""
missing_tools = []
version_old_tools = []
for tool, crate_name, req_version in RUST_TOOLS:
try:
version = exec_shell([tool, "--version"]).split(" ")[1].strip()

if version < PIGMENT_REQ_VERSION:
print(f"error: {PIGMENT} version {PIGMENT_REQ_VERSION} or newer is required, system version is {version}\n")
exit(1)
except (FileNotFoundError, PermissionError):
print(f"error: {PIGMENT} is not installed\n")
print("To build and install it, obtain cargo:\n\tcurl https://sh.rustup.rs -sSf | sh")
print(f"and then run:\n\tcargo install {PIGMENT}")
if version < req_version:
version_err_msg += (
f"error: {tool} version {req_version} or newer is required, system version is {version}"
)
version_old_tools.append(crate_name)
except (FileNotFoundError, PermissionError):
missing_tools.append(crate_name)

if version_old_tools or missing_tools:
if version_err_msg:
print(version_err_msg)
if missing_tools:
print(f"error: cannot find required Rust tool(s): {', '.join(missing_tools)}")
print()
print("To install/update dependencies, obtain cargo:\n\tcurl https://sh.rustup.rs -sSf | sh")
print(f"and then run:")
for tool in missing_tools:
print(f"\tcargo install {tool}")
for tool in version_old_tools:
print(f"\tcargo install {tool}")
exit(1)

# default version behaviour is to only do those that exist
Expand Down
4 changes: 3 additions & 1 deletion tools/build/sprite/sprites.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,9 @@ def build_player_sprites(sprite_order: List[str], build_dir: Path, asset_stack:

subprocess.run(
[
str(TOOLS_DIR / "build/yay0/Yay0compress"),
str("crunch64"),
"compress",
"yay0",
yay0_in_path,
yay0_out_path,
]
Expand Down
1 change: 0 additions & 1 deletion tools/build/yay0/.gitignore

This file was deleted.

Loading
Loading