Mario Kart Wii support (#444)

* Added compiler setup for MKW - Untested atm

* Updated download logic for _127

* Changed version _127 name to remove Metroworks 1.0 name

* Fixed compiler options strings

* exception catching for shlex

* cleanup + zbanks xargs fix

* cleanup

* Fix dll casing in download.py, warning filtering improvements, simon suggestion, typo

* Chmod to executable to the separately downloaded _127 compiler

* permit -w

* black and python updates

Co-authored-by: XOlifreX <olivier.luyckx@live.be>
This commit is contained in:
Ethan Roseman
2022-04-26 03:46:08 -04:00
committed by GitHub
parent a72844d8ed
commit 0ba6803e83
5 changed files with 101 additions and 33 deletions

View File

@@ -436,6 +436,10 @@ def download_wii_gc():
if lowercase_lmgr.exists():
shutil.move(lowercase_lmgr, compiler_dir / "LMGR326B.dll")
lowercase_lmgr = compiler_dir / "lmgr8c.dll"
if lowercase_lmgr.exists():
shutil.move(lowercase_lmgr, compiler_dir / "LMGR8C.dll")
# Set +x to allow WSL without wine
exe_path = compiler_dir / "mwcceppc.exe"
exe_path.chmod(exe_path.stat().st_mode | stat.S_IEXEC)
@@ -453,6 +457,20 @@ def download_wii_gc():
dest_path=COMPILERS_DIR / "mwcc_233_163e" / "frank.py",
)
# copy contents of _142 to _127 to prepare for patched version
if not os.path.exists(COMPILERS_DIR / "mwcc_42_127"):
shutil.copytree(COMPILERS_DIR / "mwcc_42_142", COMPILERS_DIR / "mwcc_42_127")
os.remove(COMPILERS_DIR / "mwcc_42_127" / "mwcceppc.exe")
exe_path = COMPILERS_DIR / "mwcc_42_127" / "mwcceppc.exe"
download_file(
url="https://cdn.discordapp.com/attachments/804212941054279722/954854566304833567/mwcceppc_PATCHED.exe",
log_name="mwcc_42_127",
dest_path=exe_path,
)
exe_path.chmod(exe_path.stat().st_mode | stat.S_IEXEC)
def main(args):
def should_download(platform):

View File

@@ -1,5 +1,6 @@
import logging
import os
import re
import subprocess
from dataclasses import dataclass
from functools import lru_cache
@@ -65,7 +66,6 @@ class CompilerWrapper:
"-Xcpluscomm",
"-Wab,-r4300_mul",
"-c",
"-w",
}
skip_next = False
@@ -86,18 +86,16 @@ class CompilerWrapper:
@staticmethod
def filter_compile_errors(input: str) -> str:
return (
input.replace("wine: could not load kernel32.dll, status c0000135\n", "")
.replace(
"wineserver: could not save registry branch to system.reg : Read-only file system\n",
"",
)
.replace(
"wineserver: could not save registry branch to user.reg : Read-only file system\n",
"",
)
.strip()
)
filter_strings = [
r"wine: could not load *\.dll.*\n?",
r"wineserver: could not save registry .*\n?",
r"### mwcceppc.*\.exe Driver Error:\n# Cannot find my executable .*\n?",
]
for str in filter_strings:
input = re.sub(str, "", input)
return input.strip()
@staticmethod
@lru_cache(maxsize=settings.COMPILATION_CACHE_SIZE) # type: ignore
@@ -153,6 +151,10 @@ class CompilerWrapper:
logging.debug("Compilation failed: %s", msg)
raise CompilationError(e.stderr)
except ValueError as e:
# Shlex issue?
logging.debug("Compilation failed: %s", e)
raise CompilationError(str(e))
if not object_path.exists():
raise CompilationError("Compiler did not create an object file")

View File

@@ -251,7 +251,9 @@ GCC281 = GCCCompiler(
)
# GC_WII
MWCCEPPC_CC = '${WINE} "${COMPILER_DIR}/mwcceppc.exe" -c -proc gekko -nostdinc -stderr ${COMPILER_FLAGS} -o "${OUTPUT}" "${INPUT}"'
# Thanks to Gordon Davisson for the xargs trick:
# https://superuser.com/questions/1529226/get-bash-to-respect-quotes-when-word-splitting-subshell-output/1529316#1529316
MWCCEPPC_CC = 'printf "%s" "${COMPILER_FLAGS}" | xargs -x -- ${WINE} "${COMPILER_DIR}/mwcceppc.exe" -c -proc gekko -nostdinc -stderr -o "${OUTPUT}" "${INPUT}"'
MWCC_233_144 = MWCCCompiler(
id="mwcc_233_144",
@@ -318,6 +320,12 @@ MWCC_41_60126 = MWCCCompiler(
cc=MWCCEPPC_CC,
)
MWCC_42_127 = MWCCCompiler(
id="mwcc_42_127",
platform=GC_WII,
cc=MWCCEPPC_CC,
)
MWCC_42_142 = MWCCCompiler(
id="mwcc_42_142",
platform=GC_WII,
@@ -520,6 +528,7 @@ _all_compilers: List[Compiler] = [
MWCC_247_108,
MWCC_41_60831,
MWCC_41_60126,
MWCC_42_127,
MWCC_42_142,
MWCC_43_151,
MWCC_43_172,
@@ -550,6 +559,9 @@ _all_compilers: List[Compiler] = [
MWCC_40_1051,
]
# MKWII Common flags
MKW_SHARED = "-nodefaults -align powerpc -enc SJIS -proc gekko -enum int -O4,p -inline auto -W all -fp hardware -W noimplicitconv -w notinlined -w nounwanted -DREVOKART -Cpp_exceptions off -RTTI off -nostdinc -msgstyle gcc -lang=c99 -func_align 4 -sym dwarf-2"
_all_presets = [
# GBA
Preset(
@@ -676,6 +688,41 @@ _all_presets = [
MWCC_242_81,
"-O0,p -str pool -fp hard -Cpp_exceptions off",
),
Preset(
"Mario Kart Wii (DOL)",
MWCC_42_127,
f"{MKW_SHARED} -ipa file -rostr -sdata 0 -sdata2 0",
),
Preset(
"Mario Kart Wii (RVL_SDK)",
MWCC_41_60831,
f"{MKW_SHARED} -ipa file",
),
Preset(
"Mario Kart Wii (MSL)",
MWCC_42_127,
f"{MKW_SHARED} -ipa file",
),
Preset(
"Mario Kart Wii (NintendoWare)",
MWCC_42_127,
f'{MKW_SHARED} -ipa file -inline auto -O4,p -pragma "legacy_struct_alignment on"',
),
Preset(
"Mario Kart Wii (DWC/GameSpy)",
MWCC_41_60831,
f"{MKW_SHARED} -ipa file -w nounusedexpr -w nounusedarg",
),
Preset(
"Mario Kart Wii (EGG)",
MWCC_42_127,
f"{MKW_SHARED} -ipa function -rostr",
),
Preset(
"Mario Kart Wii (REL)",
MWCC_42_127,
f'{MKW_SHARED} -ipa file -rostr -sdata 0 -sdata2 0 -pragma "legacy_struct_alignment on"',
),
Preset(
"Metroid Prime (USA)",
MWCC_247_108,

38
backend/poetry.lock generated
View File

@@ -404,15 +404,15 @@ python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7"
[[package]]
name = "platformdirs"
version = "2.5.1"
version = "2.5.2"
description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"."
category = "dev"
optional = false
python-versions = ">=3.7"
[package.extras]
docs = ["Sphinx (>=4)", "furo (>=2021.7.5b38)", "proselint (>=0.10.2)", "sphinx-autodoc-typehints (>=1.12)"]
test = ["appdirs (==1.4.4)", "pytest (>=6)", "pytest-cov (>=2.7)", "pytest-mock (>=3.6)"]
docs = ["furo (>=2021.7.5b38)", "proselint (>=0.10.2)", "sphinx-autodoc-typehints (>=1.12)", "sphinx (>=4)"]
test = ["appdirs (==1.4.4)", "pytest-cov (>=2.7)", "pytest-mock (>=3.6)", "pytest (>=6)"]
[[package]]
name = "psycopg2-binary"
@@ -611,7 +611,7 @@ python-versions = "*"
[[package]]
name = "types-pyyaml"
version = "6.0.5"
version = "6.0.7"
description = "Typing stubs for PyYAML"
category = "dev"
optional = false
@@ -619,7 +619,7 @@ python-versions = "*"
[[package]]
name = "types-requests"
version = "2.27.16"
version = "2.27.20"
description = "Typing stubs for requests"
category = "dev"
optional = false
@@ -630,7 +630,7 @@ types-urllib3 = "<1.27"
[[package]]
name = "types-urllib3"
version = "1.26.11"
version = "1.26.13"
description = "Typing stubs for urllib3"
category = "dev"
optional = false
@@ -638,11 +638,11 @@ python-versions = "*"
[[package]]
name = "typing-extensions"
version = "4.1.1"
description = "Backported and Experimental Type Hints for Python 3.6+"
version = "4.2.0"
description = "Backported and Experimental Type Hints for Python 3.7+"
category = "main"
optional = false
python-versions = ">=3.6"
python-versions = ">=3.7"
[[package]]
name = "typing-inspect"
@@ -1029,8 +1029,8 @@ pathspec = [
{file = "pathspec-0.9.0.tar.gz", hash = "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"},
]
platformdirs = [
{file = "platformdirs-2.5.1-py3-none-any.whl", hash = "sha256:bcae7cab893c2d310a711b70b24efb93334febe65f8de776ee320b517471e227"},
{file = "platformdirs-2.5.1.tar.gz", hash = "sha256:7535e70dfa32e84d4b34996ea99c5e432fa29a708d0f4e394bbcb2a8faa4f16d"},
{file = "platformdirs-2.5.2-py3-none-any.whl", hash = "sha256:027d8e83a2d7de06bbac4e5ef7e023c02b863d7ea5d079477e722bb41ab25788"},
{file = "platformdirs-2.5.2.tar.gz", hash = "sha256:58c8abb07dcb441e6ee4b11d8df0ac856038f944ab98b7be6b27b2a3c7feef19"},
]
psycopg2-binary = [
{file = "psycopg2-binary-2.9.3.tar.gz", hash = "sha256:761df5313dc15da1502b21453642d7599d26be88bff659382f8f9747c7ebea4e"},
@@ -1197,20 +1197,20 @@ types-pytz = [
{file = "types_pytz-2021.3.6-py3-none-any.whl", hash = "sha256:6805c72d51118923c5bf98633c39593d5b464d2ab49a803440e2d7ab6b8920df"},
]
types-pyyaml = [
{file = "types-PyYAML-6.0.5.tar.gz", hash = "sha256:464e050914f3d1d83a8c038e1cf46da5cb96b7cd02eaa096bcaa03675edd8a2e"},
{file = "types_PyYAML-6.0.5-py3-none-any.whl", hash = "sha256:2fd21310870addfd51db621ad9f3b373f33ee3cbb81681d70ef578760bd22d35"},
{file = "types-PyYAML-6.0.7.tar.gz", hash = "sha256:59480cf44595d836aaae050f35e3c39f197f3a833679ef3978d97aa9f2fb7def"},
{file = "types_PyYAML-6.0.7-py3-none-any.whl", hash = "sha256:7b273a34f32af9910cf9405728c9d2ad3afc4be63e4048091a1a73d76681fe67"},
]
types-requests = [
{file = "types-requests-2.27.16.tar.gz", hash = "sha256:c8010c18b291a7efb60b1452dbe12530bc25693dd657e70c62803fcdc4bffe9b"},
{file = "types_requests-2.27.16-py3-none-any.whl", hash = "sha256:2437a5f4d16c0c8bd7539a8126d492b7aeb41e6cda670d76b286c7f83a658d42"},
{file = "types-requests-2.27.20.tar.gz", hash = "sha256:63344573cde6c4efd44d867c0158d9fb7e6beb95721cbe9882f3f857ee8a5398"},
{file = "types_requests-2.27.20-py3-none-any.whl", hash = "sha256:68b8de86552116424ec23b77afc925e111afb6496d3821b183b7d151b3b834d4"},
]
types-urllib3 = [
{file = "types-urllib3-1.26.11.tar.gz", hash = "sha256:24d64e441168851eb05f1d022de18ae31558f5649c8f1117e384c2e85e31315b"},
{file = "types_urllib3-1.26.11-py3-none-any.whl", hash = "sha256:bd0abc01e9fb963e4fddd561a56d21cc371b988d1245662195c90379077139cd"},
{file = "types-urllib3-1.26.13.tar.gz", hash = "sha256:40f8fb5e8cd7d57e8aefdee3fdd5e930aa1a1bb4179cdadd55226cea588af790"},
{file = "types_urllib3-1.26.13-py3-none-any.whl", hash = "sha256:ff7500641824f881b2c7bde4cc57e6c3abf03d1e005bae83aca752e77213a5da"},
]
typing-extensions = [
{file = "typing_extensions-4.1.1-py3-none-any.whl", hash = "sha256:21c85e0fe4b9a155d0799430b0ad741cdce7e359660ccbd8b530613e8df88ce2"},
{file = "typing_extensions-4.1.1.tar.gz", hash = "sha256:1a9462dcc3347a79b1f1c0271fbe79e844580bb598bafa1ed208b94da3cdcd42"},
{file = "typing_extensions-4.2.0-py3-none-any.whl", hash = "sha256:6657594ee297170d19f67d55c05852a874e7eb634f4f753dbd667855e07c1708"},
{file = "typing_extensions-4.2.0.tar.gz", hash = "sha256:f1c24655a0da0d1b67f07e17a5e6b2a105894e6824b92096378bb3668ef02376"},
]
typing-inspect = [
{file = "typing_inspect-0.7.1-py2-none-any.whl", hash = "sha256:b1f56c0783ef0f25fb064a01be6e5407e54cf4a4bf4f3ba3fe51e0bd6dcea9e5"},

View File

@@ -47,6 +47,7 @@
"mwcc_40_1051": "4.0 build 1051 (MW 1.6sp1)",
"mwcc_41_60126": "4.1 build 60126 (GC MW 3.0a3)",
"mwcc_41_60831": "4.1 build 60831 (GC MW 3.0)",
"mwcc_42_127": "4.2 build 127 (Patched 142 build)",
"mwcc_42_142": "4.2 build 142 (Wii MW 1.0)",
"mwcc_43_151": "4.3 build 151 (Wii MW 1.1)",
"mwcc_43_172": "4.3 build 172 (Wii MW 1.3)",