Skip to content
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
44 changes: 40 additions & 4 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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
Expand All @@ -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 = [
Expand All @@ -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",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"),
Expand Down
23 changes: 18 additions & 5 deletions tools/download_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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())
Expand All @@ -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")
Expand All @@ -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()
31 changes: 29 additions & 2 deletions tools/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"]),
Expand All @@ -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",
)
Expand Down
Loading