diff --git a/configure.py b/configure.py index 4c984a72e..c112a5782 100644 --- a/configure.py +++ b/configure.py @@ -102,6 +102,12 @@ type=Path, help="path to sjiswrap.exe (optional)", ) +parser.add_argument( + "--ninja", + metavar="BINARY", + type=Path, + help="path to ninja binary (optional)", +) parser.add_argument( "--verbose", action="store_true", @@ -113,6 +119,13 @@ action="store_true", help="builds equivalent (but non-matching) or modded objects", ) +parser.add_argument( + "--warn", + dest="warn", + type=str, + choices=["all", "off", "error"], + help="how to handle warnings", +) parser.add_argument( "--no-progress", dest="progress", @@ -134,6 +147,7 @@ config.generate_map = args.map config.non_matching = args.non_matching config.sjiswrap_path = args.sjiswrap +config.ninja_path = args.ninja config.progress = args.progress if not is_windows(): config.wrapper = args.wrapper @@ -150,7 +164,6 @@ config.wibo_tag = "1.0.0-beta.5" # Project -config.shift_jis = False config.config_path = Path("config") / config.version / "config.yml" config.check_sha_path = Path("config") / config.version / "build.sha1" config.asflags = [ @@ -159,7 +172,6 @@ "-I include", f"-I build/{config.version}/include", f"--defsym BUILD_VERSION={version_num}", - f"--defsym VERSION_={config.version}", ] config.ldflags = [ "-fp hardware", @@ -216,6 +228,14 @@ else: cflags_base.append("-DNDEBUG=1") + # Warning flags +if args.warn == "all": + cflags_base.append("-W all") +elif args.warn == "off": + cflags_base.append("-W off") +elif args.warn == "error": + cflags_base.append("-W error") + # Metrowerks library flags cflags_runtime = [ *cflags_base, @@ -250,6 +270,22 @@ "-use_lmw_stmw on" ] +# Bink was compiled with ProDG +cflags_bink = [ + "-O3", + "-mcpu=750", + "-fno-exceptions", + "-Wno-inline", + "-nostdinc", + "-I src/dolphin/src", + "-I include", + "-I src/dolphin/include", + "-D__GEKKO__", + "-I src/bink/include", + "-I src/PowerPC_EABI_Support/include", + "-G4", +] + # Renderware library flags cflags_renderware = [ *cflags_base, @@ -598,8 +634,8 @@ def MatchingFor(*versions): }, { "lib": "binkngc", - "mw_version": "GC/1.3.2", - "cflags": cflags_runtime, + "mw_version": "ProDG/3.5", + "cflags": cflags_bink, "progress_category": "bink", "objects": [ Object(NonMatching, "bink/src/sdk/decode/ngc/binkngc.c"), diff --git a/tools/download_tool.py b/tools/download_tool.py index eecb7ab53..d9b9f2564 100644 --- a/tools/download_tool.py +++ b/tools/download_tool.py @@ -78,8 +78,14 @@ def sjiswrap_url(tag: str) -> str: def wibo_url(tag: str) -> str: + uname = platform.uname() + arch = uname.machine.lower() + system = uname.system.lower() + if system == "darwin": + arch = "macos" + repo = "https://github.com/decompals/wibo" - return f"{repo}/releases/download/{tag}/wibo" + return f"{repo}/releases/download/{tag}/wibo-{arch}" def ok_url(tag: str) -> str: repo = "https://github.com/bfbbdecomp/OK" @@ -96,6 +102,7 @@ def ok_url(tag: str) -> str: "OK": ok_url } + def download(url, response, output) -> None: if url.endswith(".zip"): data = io.BytesIO(response.read()) @@ -112,6 +119,7 @@ def download(url, response, output) -> None: st = os.stat(output) os.chmod(output, st.st_mode | stat.S_IEXEC) + def main() -> None: parser = argparse.ArgumentParser() parser.add_argument("tool", help="Tool name") @@ -133,12 +141,17 @@ def main() -> None: try: import certifi import ssl - except: - print("\"certifi\" module not found. Please install it using \"python -m pip install certifi\".") + except ImportError: + print( + '"certifi" module not found. Please install it using "python -m pip install certifi".' + ) return - - with urllib.request.urlopen(req, context=ssl.create_default_context(cafile=certifi.where())) as response: + + with urllib.request.urlopen( + req, context=ssl.create_default_context(cafile=certifi.where()) + ) as response: download(url, response, output) + if __name__ == "__main__": main() diff --git a/tools/project.py b/tools/project.py index f5144a223..811b57c6a 100644 --- a/tools/project.py +++ b/tools/project.py @@ -606,6 +606,17 @@ def write_cargo_rule(): ### compiler_path = compilers / "$mw_version" + # NGCCC + ngccc = compiler_path / "ngccc.exe" + if is_windows(): + ngccc_cmd = f"cmd /c \"set SN_NGC_PATH={os.path.abspath(compiler_path)}&& {ngccc} $cflags -c -o $out $in\"" + else: + ngccc_cmd = f"env SN_NGC_PATH={os.path.abspath(compiler_path)} {wrapper_cmd}{ngccc} $cflags -c -o $out $in" + ngccc_implicit: List[Optional[Path]] = [ + compilers_implicit or ngccc, + wrapper_implicit, + ] + # MWCC mwcc = compiler_path / "mwcceppc.exe" mwcc_cmd = f"{wrapper_cmd}{mwcc} $cflags -MMD -c $in -o $basedir" @@ -663,6 +674,16 @@ def write_cargo_rule(): ) n.newline() + n.comment("ProDG build") + n.rule( + name="prodg", + command=ngccc_cmd, + description="ProDG $out", + depfile="$basefile.d", + deps="gcc", + ) + n.newline() + n.comment("MWCC build (with UTF-8 to Shift JIS wrapper)") n.rule( name="mwcc_sjis", @@ -877,12 +898,18 @@ def c_build(obj: Object, src_path: Path) -> Optional[Path]: cflags_str = make_flags_str(all_cflags) used_compiler_versions.add(obj.options["mw_version"]) + # Add MWCC build rule + fakerule = "mwcc_sjis" if obj.options["shift_jis"] else "mwcc" + fakeimplicit = mwcc_sjis_implicit if obj.options["shift_jis"] else mwcc_implicit + if ("prodg" in obj.options["mw_version"].lower()): + fakerule = "prodg" + fakeimplicit = ngccc_implicit lib_name = obj.options["lib"] n.comment(f"{obj.name}: {lib_name} (linked {obj.completed})") n.build( outputs=obj.src_obj_path, - rule="mwcc_sjis" if obj.options["shift_jis"] else "mwcc", + rule=fakerule, inputs=src_path, variables={ "mw_version": Path(obj.options["mw_version"]), @@ -891,7 +918,7 @@ def c_build(obj: Object, src_path: Path) -> Optional[Path]: "basefile": obj.src_obj_path.with_suffix(""), }, implicit=( - mwcc_sjis_implicit if obj.options["shift_jis"] else mwcc_implicit + fakeimplicit ), order_only="pre-compile", )