Skip to content

Commit

Permalink
Require pigment64, use it to build most standalone images
Browse files Browse the repository at this point in the history
  • Loading branch information
ethteck committed Jul 17, 2023
1 parent c2c5f15 commit d71c9fd
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 12 deletions.
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pipeline {
sh 'curl -L "https://github.com/decompals/mips-gcc-2.7.2/releases/download/main/gcc-2.7.2-linux.tar.gz" | tar zx -C tools/build/cc/gcc2.7.2'
sh 'curl -L "https://github.com/decompals/mips-binutils-2.6/releases/download/main/binutils-2.6-linux.tar.gz" | tar zx -C tools/build/cc/gcc2.7.2'
sh 'pip install -U -r requirements.txt'
sh 'cargo install pigment64'
sh './configure'
}
}
Expand Down
51 changes: 39 additions & 12 deletions tools/build/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@
YAY0_COMPRESS_TOOL = f"{BUILD_TOOLS}/yay0/Yay0compress"
CRC_TOOL = f"{BUILD_TOOLS}/rom/n64crc"

PIGMENT = "pigment64"
PIGMENT_REQ_VERSION = "0.2.2"


def exec_shell(command: List[str]) -> str:
ret = subprocess.run(command, stdout=subprocess.PIPE, text=True)
ret = subprocess.run(
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True
)
return ret.stdout


Expand Down Expand Up @@ -181,6 +186,12 @@ def write_ninja_rules(
command=f"$python {BUILD_TOOLS}/img/build.py $img_type $in $out $img_flags",
)

ninja.rule(
"pigment",
description="img($img_type) $in",
command=f"{PIGMENT} $img_flags $in $img_type -o $out",
)

ninja.rule(
"img_header",
description="img_header $in",
Expand Down Expand Up @@ -620,7 +631,7 @@ def build(
build(
bin_path,
src_paths,
"img",
"pigment",
variables={
"img_type": seg.type,
"img_flags": flags,
Expand Down Expand Up @@ -660,7 +671,7 @@ def build(
build(
bin_path,
src_paths,
"img",
"pigment",
variables={
"img_type": seg.type,
"img_flags": "",
Expand Down Expand Up @@ -700,7 +711,7 @@ def build(
build(
bin_path,
entry.src_paths,
"img",
"pigment",
variables={
"img_type": seg.type,
"img_flags": flags,
Expand All @@ -719,7 +730,7 @@ def build(
build(
bin_path,
entry.src_paths,
"img",
"pigment",
variables={
"img_type": seg.type,
"img_flags": "",
Expand Down Expand Up @@ -839,7 +850,7 @@ def build(
build(
logotype_path,
[src_dir / "title/logotype.png"],
"img",
"pigment",
variables={
"img_type": "rgba32",
"img_flags": "",
Expand All @@ -848,7 +859,7 @@ def build(
build(
press_start_path,
[src_dir / "title/press_start.png"],
"img",
"pigment",
variables={
"img_type": "ia8",
"img_flags": "",
Expand All @@ -859,7 +870,7 @@ def build(
build(
copyright_path,
[src_dir / "title/copyright.png"],
"img",
"pigment",
variables={
"img_type": "ci4",
"img_flags": "",
Expand All @@ -868,7 +879,7 @@ def build(
build(
copyright_pal_path,
[src_dir / "title/copyright.png"],
"img",
"pigment",
variables={
"img_type": "palette",
"img_flags": "",
Expand All @@ -884,7 +895,7 @@ def build(
build(
copyright_path,
[src_dir / "title/copyright.png"],
"img",
"pigment",
variables={
"img_type": "ia8",
"img_flags": "",
Expand Down Expand Up @@ -975,7 +986,7 @@ def build(
build(
out_path,
[src_path],
"img",
"pigment",
variables={
"img_type": "ci4",
"img_flags": "",
Expand All @@ -999,7 +1010,7 @@ def build(
build(
out_path,
[src_path],
"img",
"pigment",
variables={
"img_type": "palette",
"img_flags": "",
Expand Down Expand Up @@ -1181,6 +1192,22 @@ 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()

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:
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}")
exit(1)

# default version behaviour is to only do those that exist
if len(args.version) > 0:
versions = args.version
Expand Down

0 comments on commit d71c9fd

Please sign in to comment.