Skip to content
Closed
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
50 changes: 42 additions & 8 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
ROOT = Path(__file__).parent
TOOLS_DIR = ROOT / "tools"



P3_YAML_FILE = "config/p3.jul12.yaml"
P3_BASENAME = "SCPS_150.17"
P3_LD_PATH = f"{P3_BASENAME}.ld"
Expand Down Expand Up @@ -51,6 +53,14 @@
IOP_COMPILER_FLAGS = f"-B {TOOLS_DIR}/toolchain/iop-gcc281/lib/gcc-lib/mipsel-scei-elfl/2.8.1/ -O0 -G0 -g -Wa,-Iinclude"
DVP_COMPILER_FLAGS = "" # None (at the moment)

nomatch = False

# NOMATCH_FLAGS = '-DPRD_SHIFTABLE'
if nomatch:
SHIFTABLE_FLAG = '-DPRD_SHIFTABLE'
else:
SHIFTABLE_FLAG = ''

EE_COMPILE_CMD = f"{EE_COMPILER_DIR}/ee-gcc -c {EE_COMMON_INCLUDES} {EE_COMPILER_FLAGS}"
EE_COMPILE_CMD_CXX = f"{EE_COMPILER_DIR}/ee-gcc -c {EE_COMMON_INCLUDES} {EE_COMPILER_FLAGS_CXX}"
IOP_COMPILE_CMD = f"{IOP_COMPILER_DIR}/iop-gcc -c {IOP_COMMON_INCLUDES} {IOP_COMPILER_FLAGS}"
Expand Down Expand Up @@ -262,7 +272,7 @@ def build(
ninja.rule(
"ee_cc",
description="ee_cc $in",
command=f"{EE_COMPILE_CMD} $in -o $out && {CROSS}strip $out -N dummy-symbol-name",
command=f"{EE_COMPILE_CMD} {SHIFTABLE_FLAG} $in -o $out && {CROSS}strip $out -N dummy-symbol-name",
)

ninja.rule(
Expand Down Expand Up @@ -391,12 +401,16 @@ def build(

checksum_path = "config/p3.jul12.checksum.sha1" if not is_irx else "config/irx.wave2ps2.jul12.checksum.sha1"

ninja.build(
rom_path + ".ok",
"sha1sum",
checksum_path,
implicit=[rom_path],
)
if nomatch:
ninja.build(
rom_path + ".ok",
"sha1sum",
checksum_path,
implicit=[rom_path],
)
else:
return


def generate_objdiff_configuration(config: dict[str, Any]):
"""
Expand Down Expand Up @@ -633,6 +647,9 @@ def fix_compile_commands():
with open("compile_commands.json", "w") as f:
json.dump(data, f, indent=2)

def checkDid():
return 0

def prepare_rom_from_elfs(elfs: list[Path]):
for elf in elfs:
assert elf.exists(), f"{elf} must exist!"
Expand Down Expand Up @@ -669,14 +686,31 @@ def prepare_rom_from_elfs(elfs: list[Path]):
help="Do not patch branch instructions on specific functions to combat an assembler bug",
action="store_true",
)
parser.add_argument(
"-no_match",
"--no-match",
help="Build a shiftable, non-matching executable",
action="store_false",
)
parser.add_argument(
"-objdiff",
"--objdiff",
help="Output objdiff JSONs (requires existing build)",
action="store_true"
)


args = parser.parse_args()

if args.no_match:
SHIFTABLE_FLAG = '-DPRD_SHIFTABLE'
nomatch = True
else:
#there's probably a better way to do this but it works
SHIFTABLE_FLAG = ''
nomatch = False


if not args.noclean:
if args.objdiff:
# No clean with objdiff
Expand All @@ -686,7 +720,7 @@ def prepare_rom_from_elfs(elfs: list[Path]):

if args.cleansrc:
shutil.rmtree("src", ignore_errors=True)

prepare_rom_from_elfs(TARGET_ELFS)

split.main([Path(P3_YAML_FILE)], modes=["all"], verbose=False)
Expand Down
Loading