From af6a53504e925bb068be343f7393975317936ac6 Mon Sep 17 00:00:00 2001 From: shibbo Date: Tue, 27 Aug 2024 18:40:05 -0400 Subject: [PATCH] change scripts to allow for multiple compilers --- .gitignore | 2 +- build.py | 14 ++++++++------ helpers.py | 14 +++++++++++++- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index ec42619..37691bb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -compiler/* +compilers/* *.o .vscode/* .ninja_log diff --git a/build.py b/build.py index e960bfa..8e2681c 100644 --- a/build.py +++ b/build.py @@ -36,7 +36,7 @@ LIBRARIES = ["Game", "ActionLibrary", "agl", "eui", "nn", "sead"] incdirs = " ".join([f'-I {dir}' for dir in INCLUDE_DIRS]) COMPILER_CMD = f"-x c++ -O3 -fno-omit-frame-pointer -mno-implicit-float -fno-cxx-exceptions -fno-strict-aliasing -std=gnu++14 -fno-common -fno-short-enums -ffunction-sections -fdata-sections -fPIC -mcpu=cortex-a57+fp+simd+crypto+crc -g -Wall {nonmatching_str} {incdirs} -c" -OBJDUMP_PATH = pathlib.Path("compiler/nx/aarch64/bin/llvm-objdump.exe") +OBJDUMP_PATH = pathlib.Path("compilers/800/nx/aarch64/bin/llvm-objdump.exe") # if we don't have this file, create it HASHES_BASE_PATH = pathlib.Path("data\\hashes.txt") @@ -65,13 +65,15 @@ def genNinja(compile_tasks): with open('build.ninja', 'w') as ninja_file: ninja_writer = Writer(ninja_file) - cmd = f'{helpers.COMPILER_PATH} {COMPILER_CMD} $in -o $out' - if isNotWindows: - cmd = f'wine {cmd}' - ninja_writer.rule("compile", command=cmd, description='Compiling $in') + # Define a single compile rule with a placeholder for the compiler path + ninja_writer.rule("compile", command='$compiler_path ' + COMPILER_CMD + ' $in -o $out', description='Compiling $in') for source_path, build_path in compile_tasks: - ninja_writer.build(outputs=[build_path], rule="compile", inputs=[source_path]) + # Get the appropriate compiler path for the current file + compiler_path = helpers.getCompilerPath(os.path.basename(source_path)) + + # Build the file with the correct compiler path + ninja_writer.build(outputs=[build_path], rule="compile", inputs=[source_path], variables={'compiler_path': compiler_path}) def compileLibraries(libraries): compile_tasks = [] diff --git a/helpers.py b/helpers.py index e40f931..fad36eb 100644 --- a/helpers.py +++ b/helpers.py @@ -4,7 +4,19 @@ import hashlib import sys import pathlib -COMPILER_PATH = pathlib.Path("compiler/nx/aarch64/bin/clang++.exe") +COMPILER_391_PATH = pathlib.Path("compilers/391/nx/aarch64/bin/clang++.exe") +COMPILER_800_PATH = pathlib.Path("compilers/800/nx/aarch64/bin/clang++.exe") + +# it looks like some files use different compilers...so looks like we have to support these exceptions +EXCEPTION_FILES = { + "NerveAction.cpp": COMPILER_391_PATH +} + +def getCompilerPath(filename): + if filename not in EXCEPTION_FILES: + return COMPILER_800_PATH + + return EXCEPTION_FILES[filename] # gets the "module" (object file) that a symbol is contained in from map files def getModule(map, sym):