diff --git a/common.py b/common.py index 2e73455..5c138b2 100644 --- a/common.py +++ b/common.py @@ -153,9 +153,6 @@ DOL_SRCDIR = "src" # Directory for decompiled rel code REL_SRCDIR = "rel" -# Include directory -INCDIR = "include" - # Build artifacts directory BUILDDIR = "build" @@ -279,20 +276,30 @@ REL_FULL = f"{OUTDIR}/rel.s" ASFLAGS = ' '.join([ "-m gekko", - f"-I {INCDIR}", f"-I {PPCDIS_INCDIR}", f"-I orig" ]) +INCDIRS = [ + PPCDIS_INCDIR, + BUILD_INCDIR, + f"{SPM_HEADERS}/decomp", + f"{SPM_HEADERS}/include" +] +MWCC_INCLUDES = ' '.join(f"-i {d}" for d in INCDIRS) +GCC_INCLUDES = ' '.join(f"-I {d}" for d in INCDIRS) + +DEFINES = [ + "DECOMP", + "SPM_EU0" +] +MWCC_DEFINES = ' '.join(f"-d {d}" for d in DEFINES) +GCC_DEFINES = ' '.join(f"-D {d}" for d in DEFINES) + CPPFLAGS = ' '.join([ "-nostdinc", - "-DDECOMP", - "-DSPM_EU0", - f"-I {INCDIR}", - f"-I {PPCDIS_INCDIR}", - f"-I {BUILD_INCDIR}", - f"-I {SPM_HEADERS}/decomp", - f"-I {SPM_HEADERS}/include" + GCC_DEFINES, + GCC_INCLUDES ]) DOL_SDATA2_SIZE = 4 @@ -310,8 +317,7 @@ CFLAGS = [ "-rostr", "-sym dwarf-2", "-ipa file", - "-d DECOMP", - "-d SPM_EU0", + MWCC_DEFINES ] BASE_DOL_CFLAGS = CFLAGS + [ "-inline all", @@ -330,11 +336,7 @@ LOCAL_CFLAGS = [ "-proc gekko", "-maxerrors 1", "-I-", - f"-i {INCDIR}", - f"-i {PPCDIS_INCDIR}", - f"-i {BUILD_INCDIR}", - f"-i {SPM_HEADERS}/decomp", - f"-i {SPM_HEADERS}/include", + MWCC_INCLUDES ] DOL_CFLAGS = ' '.join(BASE_DOL_CFLAGS + LOCAL_CFLAGS) REL_CFLAGS = ' '.join(BASE_REL_CFLAGS + LOCAL_CFLAGS) diff --git a/diff_settings.py b/diff_settings.py index d89ba4f..02cff5e 100644 --- a/diff_settings.py +++ b/diff_settings.py @@ -6,12 +6,12 @@ def apply(config, args: Namespace): config["mapfile"] = c.REL_MAP config["myimg"] = c.REL_PLF config["baseimg"] = c.REL_EXPECTED - config["source_directories"] = [c.REL_SRCDIR, c.INCDIR] + config["source_directories"] = [c.REL_SRCDIR, *c.INCDIRS] else: config["mapfile"] = c.DOL_MAP config["myimg"] = c.DOL_ELF config["baseimg"] = c.DOL_EXPECTED - config["source_directories"] = [c.DOL_SRCDIR, c.INCDIR] + config["source_directories"] = [c.DOL_SRCDIR, *c.INCDIRS] config["make_command"] = ["ninja"] config["makeflags"] = [] config["arch"] = "ppc" diff --git a/makectx.py b/makectx.py index df50a26..c6f6323 100644 --- a/makectx.py +++ b/makectx.py @@ -45,4 +45,4 @@ def makectx(bases: List[str]): ret += process_header(header, bases) return ret -print(makectx([c.INCDIR, c.PPCDIS_INCDIR])) +print(makectx(c.INCDIRS)) diff --git a/makectx_m2c.py b/makectx_m2c.py index 9662ffb..40d6375 100644 --- a/makectx_m2c.py +++ b/makectx_m2c.py @@ -20,7 +20,7 @@ def make_includes(dirnames: List[str]) -> str: ) # Find all headers -includes = make_includes([c.INCDIR, c.PPCDIS_INCDIR]) +includes = make_includes(c.INCDIRS) # Run mwcc preprocessor with NamedTemporaryFile(suffix=".c", delete=False) as tmp: @@ -28,7 +28,7 @@ with NamedTemporaryFile(suffix=".c", delete=False) as tmp: tmp.write(includes.encode()) tmp.close() out = c.get_cmd_stdout( - f"{c.CC} -I- -i {c.INCDIR} -i {c.PPCDIS}/include -DM2C -stderr -E {tmp.name}" + f"{c.CC} -I- {c.MWCC_INCLUDES} {c.MWCC_DEFINES} -d M2C -stderr -E {tmp.name}" ) finally: unlink(tmp.name)