[Testing] Use the same binutils on windows and linux

This commit is contained in:
Herman S.
2025-10-19 18:35:20 +09:00
parent 92b341e50c
commit b2ba98ade7
3 changed files with 29 additions and 18 deletions

3
.gitmodules vendored
View File

@@ -4,9 +4,6 @@
[submodule "third_party/imgui"] [submodule "third_party/imgui"]
path = third_party/imgui path = third_party/imgui
url = https://github.com/ocornut/imgui.git url = https://github.com/ocornut/imgui.git
[submodule "third_party/binutils-ppc-cygwin"]
path = third_party/binutils-ppc-cygwin
url = https://github.com/benvanik/binutils-ppc-cygwin.git
[submodule "third_party/catch"] [submodule "third_party/catch"]
path = third_party/catch path = third_party/catch
url = https://github.com/catchorg/Catch2.git url = https://github.com/catchorg/Catch2.git

View File

@@ -1262,8 +1262,6 @@ class GenTestsCommand(Command):
*args, **kwargs) *args, **kwargs)
def process_src_file(test_bin, ppc_as, ppc_objdump, ppc_ld, ppc_nm, src_file): def process_src_file(test_bin, ppc_as, ppc_objdump, ppc_ld, ppc_nm, src_file):
print(f"- {src_file}")
def make_unix_path(p): def make_unix_path(p):
"""Forces a unix path separator style, as required by binutils. """Forces a unix path separator style, as required by binutils.
""" """
@@ -1317,26 +1315,43 @@ class GenTestsCommand(Command):
make_unix_path(obj_file), make_unix_path(obj_file),
], stdout_path=f"{os.path.join(test_bin, src_name)}.map") ], stdout_path=f"{os.path.join(test_bin, src_name)}.map")
return src_file
def execute(self, args, pass_args, cwd): def execute(self, args, pass_args, cwd):
print("Generating test binaries...\n") print("Generating test binaries...\n")
if sys.platform == "win32": # Use the same binutils path on all platforms
binutils_path = os.path.join("third_party", "binutils-ppc-cygwin") binutils_path = os.path.join("third_party", "binutils", "bin")
else:
binutils_path = os.path.join("third_party", "binutils", "bin")
ppc_as = os.path.join(binutils_path, "powerpc-none-elf-as") ppc_as = os.path.join(binutils_path, "powerpc-none-elf-as")
ppc_ld = os.path.join(binutils_path, "powerpc-none-elf-ld") ppc_ld = os.path.join(binutils_path, "powerpc-none-elf-ld")
ppc_objdump = os.path.join(binutils_path, "powerpc-none-elf-objdump") ppc_objdump = os.path.join(binutils_path, "powerpc-none-elf-objdump")
ppc_nm = os.path.join(binutils_path, "powerpc-none-elf-nm") ppc_nm = os.path.join(binutils_path, "powerpc-none-elf-nm")
if not os.path.exists(ppc_as) and sys.platform == "linux": # Check if binutils exists (with .exe on Windows)
ppc_as_check = ppc_as + (".exe" if sys.platform == "win32" else "")
if not os.path.exists(ppc_as_check):
print("Binaries are missing, binutils build required\n") print("Binaries are missing, binutils build required\n")
shell_script = os.path.join("third_party", "binutils", "build.sh") binutils_dir = os.path.join("third_party", "binutils")
# Set executable bit for build script before running it shell_script = "build.sh"
os.chmod(shell_script, stat.S_IRUSR | stat.S_IWUSR |
stat.S_IXUSR | stat.S_IRGRP | stat.S_IROTH) # Save current directory
shell_call([shell_script]) original_dir = os.getcwd()
if sys.platform == "linux":
# Set executable bit for build script before running it
os.chdir(binutils_dir)
os.chmod(shell_script, stat.S_IRUSR | stat.S_IWUSR |
stat.S_IXUSR | stat.S_IRGRP | stat.S_IROTH)
shell_call([f"./{shell_script}"])
os.chdir(original_dir)
elif sys.platform == "win32":
# On Windows, add Cygwin to PATH and run bash
cygwin_bin = r"C:\cygwin64\bin"
os.environ["PATH"] = f"{cygwin_bin}{os.pathsep}{os.environ['PATH']}"
os.chdir(binutils_dir)
shell_call(["bash", shell_script])
os.chdir(original_dir)
test_src = os.path.join("src", "xenia", "cpu", "ppc", "testing") test_src = os.path.join("src", "xenia", "cpu", "ppc", "testing")
test_bin = os.path.join(test_src, "bin") test_bin = os.path.join(test_src, "bin")
@@ -1355,8 +1370,8 @@ class GenTestsCommand(Command):
pool_func = partial(GenTestsCommand.process_src_file, test_bin, ppc_as, ppc_objdump, ppc_ld, ppc_nm) pool_func = partial(GenTestsCommand.process_src_file, test_bin, ppc_as, ppc_objdump, ppc_ld, ppc_nm)
with Pool() as pool: with Pool() as pool:
pool.map(pool_func, src_files) for src_file in pool.imap_unordered(pool_func, src_files):
print(f"- {src_file}")
if any_errors: if any_errors:
print_error("failed to build one or more tests.") print_error("failed to build one or more tests.")