configure.py: Add --compilers and --build-dir; cleanup

This commit is contained in:
Luke Street 2023-01-23 19:18:59 -05:00
parent 3417e5c576
commit 3ec17fbf33
2 changed files with 227 additions and 215 deletions

View File

@ -2,7 +2,7 @@
LIBS = [
{
"lib": "TRK_MINNOW_DOLPHIN",
"mwcc_version": "1.2.5",
"mw_version": "1.2.5",
"cflags": "$cflags_base",
"host": False,
"objects": [
@ -12,7 +12,7 @@ LIBS = [
{
"lib": "MetroidPrimeCW",
"cflags": "$cflags_retro",
"mwcc_version": "1.3.2",
"mw_version": "1.3.2",
"host": True,
"objects": [
["MetroidPrime/main", False],
@ -372,7 +372,7 @@ LIBS = [
},
{
"lib": "WorldFormatCW",
"mwcc_version": "1.3.2",
"mw_version": "1.3.2",
"cflags": "$cflags_retro",
"host": True,
"objects": [
@ -392,7 +392,7 @@ LIBS = [
},
{
"lib": "WeaponsCW",
"mwcc_version": "1.3.2",
"mw_version": "1.3.2",
"cflags": "$cflags_retro",
"host": True,
"objects": [
@ -408,14 +408,14 @@ LIBS = [
},
{
"lib": "MetaRenderCW",
"mwcc_version": "1.3.2",
"mw_version": "1.3.2",
"cflags": "$cflags_retro",
"host": True,
"objects": ["MetaRender/CCubeRenderer"],
},
{
"lib": "GuiSysCW",
"mwcc_version": "1.3.2",
"mw_version": "1.3.2",
"cflags": "$cflags_retro",
"host": True,
"objects": [
@ -442,7 +442,7 @@ LIBS = [
},
{
"lib": "CollisionCW",
"mwcc_version": "1.3.2",
"mw_version": "1.3.2",
"cflags": "$cflags_retro",
"host": True,
"objects": [
@ -461,7 +461,7 @@ LIBS = [
},
{
"lib": "Kyoto_CW1",
"mwcc_version": "1.3.2",
"mw_version": "1.3.2",
"cflags": "$cflags_retro",
"host": True,
"objects": [
@ -618,7 +618,7 @@ LIBS = [
},
{
"lib": "zlib",
"mwcc_version": "1.3.2",
"mw_version": "1.3.2",
"cflags": "$cflags_runtime",
"host": True,
"objects": [
@ -636,7 +636,7 @@ LIBS = [
},
{
"lib": "Kyoto_CW2",
"mwcc_version": "1.3.2",
"mw_version": "1.3.2",
"cflags": "$cflags_retro",
"host": True,
"objects": [
@ -698,7 +698,7 @@ LIBS = [
},
{
"lib": "ai",
"mwcc_version": "1.2.5e",
"mw_version": "1.2.5e",
"cflags": "$cflags_base",
"host": False,
"objects": [
@ -707,7 +707,7 @@ LIBS = [
},
{
"lib": "ar",
"mwcc_version": "1.2.5e",
"mw_version": "1.2.5e",
"cflags": "$cflags_base",
"host": False,
"objects": [
@ -717,7 +717,7 @@ LIBS = [
},
{
"lib": "base",
"mwcc_version": "1.2.5",
"mw_version": "1.2.5",
"cflags": "$cflags_base",
"host": False,
"objects": [
@ -726,7 +726,7 @@ LIBS = [
},
{
"lib": "db",
"mwcc_version": "1.2.5",
"mw_version": "1.2.5",
"cflags": "$cflags_base",
"host": False,
"objects": [
@ -735,7 +735,7 @@ LIBS = [
},
{
"lib": "dsp",
"mwcc_version": "1.2.5e",
"mw_version": "1.2.5e",
"cflags": "$cflags_base",
"host": False,
"objects": [
@ -746,7 +746,7 @@ LIBS = [
},
{
"lib": "dvd",
"mwcc_version": "1.2.5e",
"mw_version": "1.2.5e",
"cflags": "$cflags_base",
"host": False,
"objects": [
@ -762,7 +762,7 @@ LIBS = [
},
{
"lib": "gx",
"mwcc_version": "1.2.5",
"mw_version": "1.2.5",
"cflags": "$cflags_base -fp_contract off",
"host": False,
"objects": [
@ -785,7 +785,7 @@ LIBS = [
},
{
"lib": "mtx",
"mwcc_version": "1.2.5",
"mw_version": "1.2.5",
"cflags": "$cflags_base",
"host": False,
"objects": [
@ -798,7 +798,7 @@ LIBS = [
},
{
"lib": "os",
"mwcc_version": "1.2.5e",
"mw_version": "1.2.5e",
"cflags": "$cflags_base",
"host": False,
"objects": [
@ -829,7 +829,7 @@ LIBS = [
},
{
"lib": "pad",
"mwcc_version": "1.2.5e",
"mw_version": "1.2.5e",
"cflags": "$cflags_base",
"host": False,
"objects": [
@ -839,14 +839,14 @@ LIBS = [
},
{
"lib": "vi",
"mwcc_version": "1.2.5",
"mw_version": "1.2.5",
"cflags": "$cflags_base",
"host": False,
"objects": ["Dolphin/vi"],
},
{
"lib": "MSL_C.PPCEABI.bare.H",
"mwcc_version": "1.3.2",
"mw_version": "1.3.2",
"cflags": "$cflags_runtime",
"host": False,
"objects": [
@ -918,7 +918,7 @@ LIBS = [
},
{
"lib": "musyx",
"mwcc_version": "1.3.2",
"mw_version": "1.3.2",
"cflags": "$cflags_musyx",
"host": False,
"objects": [
@ -957,7 +957,7 @@ LIBS = [
},
{
"lib": "dtk",
"mwcc_version": "1.2.5",
"mw_version": "1.2.5",
"cflags": "$cflags_base",
"host": False,
"objects": [
@ -966,7 +966,7 @@ LIBS = [
},
{
"lib": "card",
"mwcc_version": "1.2.5e",
"mw_version": "1.2.5e",
"cflags": "$cflags_base",
"host": False,
"objects": [
@ -990,7 +990,7 @@ LIBS = [
},
{
"lib": "si",
"mwcc_version": "1.2.5e",
"mw_version": "1.2.5e",
"cflags": "$cflags_base",
"host": False,
"objects": [
@ -1000,7 +1000,7 @@ LIBS = [
},
{
"lib": "exi",
"mwcc_version": "1.2.5",
"mw_version": "1.2.5",
"cflags": "$cflags_base",
"host": False,
"objects": [
@ -1010,7 +1010,7 @@ LIBS = [
},
{
"lib": "thp",
"mwcc_version": "1.2.5",
"mw_version": "1.2.5",
"cflags": "$cflags_base",
"host": False,
"objects": [
@ -1020,7 +1020,7 @@ LIBS = [
},
{
"lib": "gba",
"mwcc_version": "1.2.5e",
"mw_version": "1.2.5e",
"cflags": "$cflags_base",
"host": False,
"objects": [
@ -1041,6 +1041,7 @@ if __name__ == "__main__":
import sys
import argparse
from pathlib import Path
from shutil import which
from tools import ninja_syntax
@ -1072,17 +1073,20 @@ if __name__ == "__main__":
parser.add_argument(
"--devkitppc",
dest="devkitppc",
type=Path,
help="path to devkitPPC",
)
if os.name != "nt" and not "_NT-" in os.uname().sysname:
parser.add_argument(
"--wine",
dest="wine",
type=Path,
help="path to wine (or wibo)",
)
parser.add_argument(
"--build-dtk",
dest="build_dtk",
type=Path,
help="path to decomp-toolkit source",
)
parser.add_argument(
@ -1091,10 +1095,24 @@ if __name__ == "__main__":
action="store_true",
help="build with debug info (non-matching)",
)
parser.add_argument(
"--compilers",
dest="compilers",
type=Path,
default=Path("tools/mwcc_compiler"),
help="path to compilers",
)
parser.add_argument(
"--build-dir",
dest="build_dir",
type=Path,
default=Path("build"),
help="base build directory",
)
args = parser.parse_args()
# On Windows, we need this to use && in commands
ALLOW_CHAIN = "cmd /c " if os.name == "nt" else ""
chain = "cmd /c " if os.name == "nt" else ""
out = io.StringIO()
n = ninja_syntax.Writer(out)
@ -1108,34 +1126,36 @@ if __name__ == "__main__":
if os.name != "nt" and "DEVKITPPC" in os.environ and not args.devkitppc:
configure_args.extend(["--devkitppc", os.environ["DEVKITPPC"]])
n.variable("configure_args", configure_args)
n.variable("python", sys.executable)
n.newline()
###
# Variables
###
n.comment("Variables")
n.variable("version", args.version.lower())
version = args.version.lower()
if args.version.lower() == "kor":
n.variable("version_num", "2")
version_num = "2"
elif args.version.isnumeric() and int(args.version) in [0, 1]:
n.variable("version_num", args.version)
version_num = args.version
else:
sys.exit(f'Invalid version "{args.version}"')
n.variable("builddir", "build/mp1.$version")
n.variable("out", args.build_dir / f"mp1.{version}")
build_path = Path("$out")
if args.devkitppc:
n.variable("devkitppc", args.devkitppc)
dkp_path = args.devkitppc
elif os.name == "nt":
n.variable("devkitppc", "C:\devkitPro\devkitPPC")
dkp_path = Path("C:\devkitPro\devkitPPC")
elif "DEVKITPPC" in os.environ:
n.variable("devkitppc", os.environ["DEVKITPPC"])
dkp_path = Path(os.environ["DEVKITPPC"])
else:
n.variable("devkitppc", "/opt/devkitpro/devkitPPC")
cflags_base = "-proc gekko -nodefaults -Cpp_exceptions off -RTTI off -fp hard -fp_contract on -O4,p -maxerrors 1 -enum int -inline auto -str reuse -nosyspath -MMD -DPRIME1 -DVERSION=$version_num -DNONMATCHING=0 -i include/ -i libc/"
dkp_path = Path("/opt/devkitpro/devkitPPC")
cflags_base = f"-proc gekko -nodefaults -Cpp_exceptions off -RTTI off -fp hard -fp_contract on -O4,p -maxerrors 1 -enum int -inline auto -str reuse -nosyspath -MMD -DPRIME1 -DVERSION={version_num} -DNONMATCHING=0 -i include -i libc"
if args.debug:
cflags_base += " -sym on -D_DEBUG"
else:
cflags_base += " -DNDEBUG"
n.variable("cflags_base", cflags_base)
n.variable(
"cflags_retro",
@ -1146,82 +1166,120 @@ if __name__ == "__main__":
"$cflags_base -use_lmw_stmw on -str reuse,pool,readonly -gccinc -inline deferred,auto",
)
n.variable("cflags_musyx", "$cflags_base -str reuse,pool,readonly -fp_contract off")
asflags = "-mgekko -I include/ --defsym version=$version_num -W --strip-local-absolute -gdwarf-2"
asflags = f"-mgekko -I include --defsym version={version_num} -W --strip-local-absolute -gdwarf-2"
n.variable("asflags", asflags)
ldflags = "-fp fmadd -nodefaults -lcf ldscript.lcf"
if args.map:
ldflags += " -map $builddir/MetroidPrime.MAP"
map_path = build_path / "MetroidPrime.MAP"
ldflags += f" -map {map_path}"
if args.debug:
ldflags += " -g"
n.variable("ldflags", ldflags)
n.variable("mwcc_version", "1.3.2")
n.variable("python", sys.executable)
n.variable("mw_version", "1.3.2")
if os.name == "nt":
n.variable("exe", ".exe")
exe = ".exe"
wine = ""
else:
if "_NT-" in os.uname().sysname:
# MSYS2
n.variable("wine", "")
wine = ""
elif args.wine:
n.variable("wine", args.wine + " ")
wine = f"{args.wine} "
elif which("wibo") is not None:
n.variable("wine", "wibo ")
wine = "wibo "
else:
n.variable("wine", "wine ")
n.variable("exe", "")
wine = "wine "
exe = ""
n.newline()
###
# Tooling
###
n.comment("decomp-toolkit")
tools_path = Path("tools")
build_tools_path = args.build_dir / "tools"
def path(input: list[Path] | Path | None) -> list[str] | None:
if input is None:
return None
elif isinstance(input, list):
return list(map(str, input))
else:
return [str(input)]
if args.build_dtk:
dtk = build_tools_path / "release" / f"dtk{exe}"
n.rule(
name="cargo",
command="cargo build --release --manifest-path $in --bin $bin --target-dir $target",
description="CARGO $bin",
depfile=path(Path("$target") / "release" / "$bin.d"),
deps="gcc",
)
n.build(
outputs=path(dtk),
rule="cargo",
inputs=path(args.build_dtk / "Cargo.toml"),
variables={
"bin": "dtk",
"target": build_tools_path,
},
)
else:
dtk = build_tools_path / f"dtk{exe}"
download_dtk = tools_path / "download_dtk.py"
n.rule(
name="download_dtk",
command=f"$python {download_dtk} $in $out",
description="DOWNLOAD $out",
)
n.build(
outputs=path(dtk),
rule="download_dtk",
inputs="dtk_version",
implicit=path([download_dtk]),
)
n.newline()
###
# Rules
###
if os.name == "nt":
mwcc_command = "tools\\mwcc_compiler\\$mwcc_version\\mwcceppc.exe $cflags -c $in -o $basedir"
mwcc_frank_command = (
ALLOW_CHAIN
+ "tools\\mwcc_compiler\\$mwcc_version\\mwcceppc.exe $cflags -c $in -o $basedir && "
+ "$python tools/franklite.py $out $out"
)
link_elf_command = "tools\\mwcc_compiler\\$mwcc_version\\mwldeppc.exe $ldflags -o $out @$out.rsp"
assemble_asm_command = (
ALLOW_CHAIN
+ "$devkitppc\\bin\\powerpc-eabi-as.exe $asflags -o $out $in -MD $out.d"
+ " && $dtk elf fixup $out $out"
)
compiler_path = args.compilers / "$mw_version"
mwcc = compiler_path / "mwcceppc.exe"
mwld = compiler_path / "mwldeppc.exe"
franklite = tools_path / "franklite.py"
gnu_as = dkp_path / "bin" / f"powerpc-eabi-as{exe}"
n.comment("Link ELF file")
n.rule(
name="link",
command=link_elf_command,
description="LINK $out",
rspfile="$out.rsp",
rspfile_content="$in",
)
n.newline()
else:
mwcc_command = "${wine}tools/mwcc_compiler/$mwcc_version/mwcceppc.exe $cflags -c $in -o $basedir && $python tools/transform-dep.py $basefile.d $basefile.d"
mwcc_frank_command = (
"${wine}tools/mwcc_compiler/$mwcc_version/mwcceppc.exe $cflags -c $in -o $basedir && "
+ "$python tools/franklite.py $out $out && "
+ "$python tools/transform-dep.py $basefile.d $basefile.d"
)
link_elf_command = "${wine}tools/mwcc_compiler/$mwcc_version/mwldeppc.exe $ldflags -o $out @$out.rsp"
assemble_asm_command = (
"$devkitppc/bin/powerpc-eabi-as $asflags -o $out $in -MD $out.d"
+ " && $dtk elf fixup $out $out"
)
mwcc_cmd = f"{chain}{wine}{mwcc} $cflags -c $in -o $basedir"
mwcc_frank_cmd = f"{mwcc_cmd} && $python {franklite} $out $out"
mwld_cmd = f"{wine}{mwld} $ldflags -o $out @$out.rsp"
as_cmd = (
f"{chain}{gnu_as} $asflags -o $out $in -MD $out.d"
+ f" && {dtk} elf fixup $out $out"
)
ar_cmd = f"{dtk} ar create $out @$out.rsp"
n.comment("Link ELF file")
n.rule(
name="link",
command=link_elf_command,
description="LINK $out",
rspfile="$out.rsp",
rspfile_content="$in_newline",
)
n.newline()
if os.name != "nt":
transform_dep = tools_path / "transform-dep.py"
transform_dep_cmd = f" && $python {transform_dep} $basefile.d $basefile.d"
mwcc_cmd += transform_dep_cmd
mwcc_frank_cmd += transform_dep_cmd
n.comment("Link ELF file")
n.rule(
name="link",
command=mwld_cmd,
description="LINK $out",
rspfile="$out.rsp",
rspfile_content="$in_newline",
)
n.newline()
n.comment("MWCC build")
n.rule(
name="mwcc",
command=mwcc_command,
command=mwcc_cmd,
description="MWCC $out",
depfile="$basefile.d",
deps="gcc",
@ -1231,7 +1289,7 @@ if __name__ == "__main__":
n.comment("MWCC build with franklite")
n.rule(
name="mwcc_frank",
command=mwcc_frank_command,
command=mwcc_frank_cmd,
description="FRANK $out",
depfile="$basefile.d",
deps="gcc",
@ -1241,7 +1299,7 @@ if __name__ == "__main__":
n.comment("Assemble asm")
n.rule(
name="as",
command=assemble_asm_command,
command=as_cmd,
description="AS $out",
depfile="$out.d",
deps="gcc",
@ -1251,7 +1309,7 @@ if __name__ == "__main__":
n.comment("Create static library")
n.rule(
name="ar",
command="$dtk ar create $out @$out.rsp",
command=ar_cmd,
description="AR $out",
rspfile="$out.rsp",
rspfile_content="$in_newline",
@ -1259,65 +1317,37 @@ if __name__ == "__main__":
n.newline()
n.comment("Host build")
n.variable("host_cflags", "-I include/ -Wno-trigraphs")
n.variable("host_cflags", "-I include -Wno-trigraphs")
n.variable(
"host_cppflags",
"-std=c++98 -I include/ -fno-exceptions -fno-rtti -D_CRT_SECURE_NO_WARNINGS -Wno-trigraphs -Wno-c++11-extensions",
"-std=c++98 -I include -fno-exceptions -fno-rtti -D_CRT_SECURE_NO_WARNINGS -Wno-trigraphs -Wno-c++11-extensions",
)
n.rule(
name="host_cc",
command="clang $host_cflags -c -o $out $in",
description="host_cc $out",
description="CC $out",
)
n.rule(
name="host_cpp",
command="clang++ $host_cppflags -c -o $out $in",
description="host_c++ $out",
description="CXX $out",
)
n.newline()
###
# Tooling
###
n.comment("decomp-toolkit")
if args.build_dtk:
n.variable("dtk", os.path.join("build", "tools", "release", "dtk$exe"))
n.rule(
name="cargo",
command="cargo build --release --manifest-path $in --bin $bin --target-dir $target",
description="CARGO $bin",
depfile="$target/release/$bin.d",
deps="gcc",
)
n.build(
outputs="$dtk",
rule="cargo",
inputs=os.path.join(args.build_dtk, "Cargo.toml"),
variables={
"bin": "dtk",
"target": os.path.join("build", "tools"),
},
)
else:
n.variable("dtk", os.path.join("build", "tools", "dtk$exe"))
n.rule(
name="download_dtk",
command="$python tools/download_dtk.py $in $out",
description="DOWNLOAD $out",
)
n.build(
outputs="$dtk",
rule="download_dtk",
inputs="dtk_version",
implicit=["tools/download_dtk.py"],
)
###
# Rules for source files
###
n.comment("Source files")
all_source_files = []
all_host_source_files = []
src_path = Path("src")
asm_path = Path("asm")
build_src_path = build_path / "src"
build_host_path = build_path / "host"
build_asm_path = build_path / "asm"
build_lib_path = build_path / "lib"
source_inputs = []
host_source_inputs = []
link_inputs = []
for lib in LIBS:
inputs = []
if "lib" in lib:
@ -1325,6 +1355,7 @@ if __name__ == "__main__":
n.comment(f"{lib_name}.a")
else:
n.comment("Loose files")
for object in lib["objects"]:
completed = None
add_to_all = True
@ -1337,104 +1368,85 @@ if __name__ == "__main__":
completed = object[1]
object = object[0]
mwcc_version = lib["mwcc_version"]
mw_version = lib["mw_version"]
c_file = None
if os.path.exists(os.path.join("src", f"{object}.cpp")):
c_file = os.path.join("src", f"{object}.cpp")
elif os.path.exists(os.path.join("src", f"{object}.c")):
c_file = os.path.join("src", f"{object}.c")
if os.path.exists(src_path / f"{object}.cpp"):
c_file = src_path / f"{object}.cpp"
elif os.path.exists(src_path / f"{object}.c"):
c_file = src_path / f"{object}.c"
if c_file is not None:
if completed is None:
print(f"Mark as incomplete: {c_file}")
rule = "mwcc"
if mwcc_version == "1.2.5e":
mwcc_version = "1.2.5"
if mw_version == "1.2.5e":
mw_version = "1.2.5"
if no_frank is False:
rule = "mwcc_frank"
n.build(
outputs=f"$builddir/src/{object}.o",
outputs=path(build_src_path / f"{object}.o"),
rule=rule,
inputs=c_file,
inputs=path(c_file),
variables={
"mwcc_version": mwcc_version,
"mw_version": mw_version,
"cflags": lib["cflags"],
"basedir": os.path.dirname(f"$builddir/src/{object}"),
"basefile": f"$builddir/src/{object}",
"basedir": os.path.dirname(build_src_path / f"{object}"),
"basefile": path(build_src_path / f"{object}"),
},
)
if lib["host"]:
n.build(
outputs=f"$builddir/host/{object}.o",
rule="host_cc" if c_file.endswith(".c") else "host_cpp",
inputs=c_file,
outputs=path(build_host_path / f"{object}.o"),
rule="host_cc" if c_file.suffix == ".c" else "host_cpp",
inputs=path(c_file),
variables={
"basedir": os.path.dirname(f"$builddir/src/{object}"),
"basefile": f"$builddir/src/{object}",
"basedir": os.path.dirname(build_host_path / object),
"basefile": path(build_host_path / object),
},
)
n.build(
outputs=f"host/{c_file}",
rule="phony",
inputs=f"$builddir/host/{object}.o",
)
if add_to_all:
all_host_source_files.append(f"$builddir/host/{object}.o")
host_source_inputs.append(build_host_path / f"{object}.o")
if add_to_all:
all_source_files.append(f"$builddir/src/{object}.o")
if os.path.exists(os.path.join("asm", f"{object}.s")):
source_inputs.append(build_src_path / f"{object}.o")
if os.path.exists(asm_path / f"{object}.s"):
n.build(
outputs=f"$builddir/asm/{object}.o",
outputs=path(build_asm_path / f"{object}.o"),
rule="as",
inputs=f"asm/{object}.s",
implicit="$dtk",
inputs=path(asm_path / f"{object}.s"),
implicit=path(dtk),
)
if completed:
inputs.append(f"$builddir/src/{object}.o")
inputs.append(build_src_path / f"{object}.o")
else:
inputs.append(f"$builddir/asm/{object}.o")
inputs.append(build_asm_path / f"{object}.o")
if args.static_libs and "lib" in lib:
lib_name = lib["lib"]
n.build(
outputs=f"$builddir/lib/{lib_name}.a",
outputs=path(build_lib_path / f"{lib_name}.a"),
rule="ar",
inputs=inputs,
implicit="$dtk",
inputs=path(inputs),
implicit=path(dtk),
)
link_inputs.append(build_lib_path / f"{lib_name}.a")
else:
link_inputs.extend(inputs)
n.newline()
###
# Link
###
n.comment("Link")
inputs = []
for lib in LIBS:
if args.static_libs and "lib" in lib:
lib_name = lib["lib"]
inputs.append(f"$builddir/lib/{lib_name}.a")
else:
for object in lib["objects"]:
completed = False
if type(object) is list:
completed = object[1]
object = object[0]
if completed:
inputs.append(f"$builddir/src/{object}.o")
else:
inputs.append(f"$builddir/asm/{object}.o")
if args.map:
n.build(
outputs="$builddir/main.elf",
outputs=path(build_path / "main.elf"),
rule="link",
inputs=inputs,
implicit_outputs="$builddir/MetroidPrime.MAP",
inputs=path(link_inputs),
implicit_outputs=path(map_path),
)
else:
n.build(
outputs="$builddir/main.elf",
outputs=path(build_path / "main.elf"),
rule="link",
inputs=inputs,
inputs=path(link_inputs),
)
n.newline()
@ -1445,7 +1457,7 @@ if __name__ == "__main__":
n.build(
outputs="all_source",
rule="phony",
inputs=all_source_files,
inputs=path(source_inputs),
)
n.newline()
@ -1456,7 +1468,7 @@ if __name__ == "__main__":
n.build(
outputs="all_source_host",
rule="phony",
inputs=all_host_source_files,
inputs=path(host_source_inputs),
)
n.newline()
@ -1466,16 +1478,16 @@ if __name__ == "__main__":
n.comment("Generate DOL")
n.rule(
name="elf2dol",
command=ALLOW_CHAIN
+ "$dtk elf2dol $in $out && "
+ "$dtk metroidbuildinfo $out buildstrings/mp1.$version.build",
command=chain
+ f"{dtk} elf2dol $in $out && "
+ f"{dtk} metroidbuildinfo $out buildstrings/mp1.{version}.build",
description="DOL $out",
)
n.build(
outputs="$builddir/main.dol",
outputs=path(build_path / "main.dol"),
rule="elf2dol",
inputs="$builddir/main.elf",
implicit="$dtk",
inputs=path(build_path / "main.elf"),
implicit=path(dtk),
)
n.newline()
@ -1486,14 +1498,14 @@ if __name__ == "__main__":
n.comment("Check DOL hash")
n.rule(
name="check",
command="$dtk shasum -c $in -o $out",
command=f"{dtk} shasum -c $in -o $out",
description="CHECK $in",
)
n.build(
outputs="$builddir/main.dol.ok",
outputs=path(build_path / "main.dol.ok"),
rule="check",
inputs="sha1/mp1.$version.sha1",
implicit=["$builddir/main.dol", "$dtk"],
inputs=f"sha1/mp1.{version}.sha1",
implicit=path([build_path / "main.dol", dtk]),
)
n.newline()
@ -1508,9 +1520,9 @@ if __name__ == "__main__":
description="PROGRESS $in",
)
n.build(
outputs="$builddir/main.dol.progress",
outputs=path(build_path / "main.dol.progress"),
rule="progress",
inputs=["$builddir/main.dol", "$builddir/MetroidPrime.MAP"],
inputs=path([build_path / "main.dol", map_path]),
implicit="progress.py",
)
n.newline()
@ -1536,13 +1548,13 @@ if __name__ == "__main__":
###
n.comment("Default rule")
if args.check:
dol_out = "$builddir/main.dol.ok"
dol_out = build_path / "main.dol.ok"
else:
dol_out = "$builddir/main.dol"
dol_out = build_path / "main.dol"
if args.map:
n.default([dol_out, "$builddir/main.dol.progress"])
n.default(path([dol_out, build_path / "main.dol.progress"]))
else:
n.default([dol_out])
n.default(path([dol_out]))
with open("build.ninja", "w") as f:
f.write(out.getvalue())

View File

@ -1,6 +1,6 @@
#!/bin/bash -e
VERSION="${VERSION:=0}"
OBJDUMP="$DEVKITPPC/bin/powerpc-eabi-objdump -D -bbinary -EB -mpowerpc -M gekko"
OBJDUMP="$DEVKITPPC/bin/powerpc-eabi-objdump -Dz -bbinary -EB -mpowerpc -M gekko"
if [ ! -z "$1" ]; then
OPTIONS="--start-address=$(($1)) --stop-address=$(($2))"
fi