mirror of https://github.com/PrimeDecomp/prime.git
Add header dependency tracking; add asm-differ config & more
This commit is contained in:
parent
604ef813e4
commit
121b5808c0
34
Makefile
34
Makefile
|
@ -59,6 +59,9 @@ O_FILES := $(INIT_O_FILES) $(EXTAB_O_FILES) $(EXTABINDEX_O_FILES) $(METROTRK_FIL
|
||||||
$(OS_FILES) $(PAD_FILES) $(VI_FILES) $(MSL_PPCEABI_BARE_H) $(MUSYX_FILES) \
|
$(OS_FILES) $(PAD_FILES) $(VI_FILES) $(MSL_PPCEABI_BARE_H) $(MUSYX_FILES) \
|
||||||
$(DTK_FILES) $(CARD_FILES) $(SI_FILES) $(EXI_FILES) $(THP_FILES) \
|
$(DTK_FILES) $(CARD_FILES) $(SI_FILES) $(EXI_FILES) $(THP_FILES) \
|
||||||
$(GBA_FILES) $(CTORS_O_FILES) $(DTORS_O_FILES)
|
$(GBA_FILES) $(CTORS_O_FILES) $(DTORS_O_FILES)
|
||||||
|
DEPENDS := $(O_FILES:.o=.d)
|
||||||
|
# If a specific .o file is passed as a target, also process its deps
|
||||||
|
DEPENDS += $(MAKECMDGOALS:.o=.d)
|
||||||
|
|
||||||
ifeq ($(EPILOGUE_PROCESS),1)
|
ifeq ($(EPILOGUE_PROCESS),1)
|
||||||
E_FILES := $(EPILOGUE_UNSCHEDULED)
|
E_FILES := $(EPILOGUE_UNSCHEDULED)
|
||||||
|
@ -67,7 +70,7 @@ endif
|
||||||
# Tools
|
# Tools
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
MWCC_VERSION := 2.6
|
MWCC_VERSION := 2.7
|
||||||
ifeq ($(EPILOGUE_PROCESS),1)
|
ifeq ($(EPILOGUE_PROCESS),1)
|
||||||
MWCC_EPI_VERSION := 1.2.5
|
MWCC_EPI_VERSION := 1.2.5
|
||||||
MWCC_EPI_EXE := mwcceppc.exe
|
MWCC_EPI_EXE := mwcceppc.exe
|
||||||
|
@ -83,6 +86,7 @@ ifeq ($(WINDOWS),1)
|
||||||
else
|
else
|
||||||
WINE ?= wine
|
WINE ?= wine
|
||||||
DEVKITPPC ?= /opt/devkitpro/devkitPPC
|
DEVKITPPC ?= /opt/devkitpro/devkitPPC
|
||||||
|
DEPENDS := $(DEPENDS:.d=.d.unix)
|
||||||
AS := $(DEVKITPPC)/bin/powerpc-eabi-as
|
AS := $(DEVKITPPC)/bin/powerpc-eabi-as
|
||||||
CPP := $(DEVKITPPC)/bin/powerpc-eabi-cpp -P
|
CPP := $(DEVKITPPC)/bin/powerpc-eabi-cpp -P
|
||||||
endif
|
endif
|
||||||
|
@ -95,10 +99,11 @@ ELF2DOL := tools/elf2dol
|
||||||
SHA1SUM := sha1sum
|
SHA1SUM := sha1sum
|
||||||
PYTHON := python3
|
PYTHON := python3
|
||||||
|
|
||||||
|
TRANSFORM_DEP := tools/transform-dep.py
|
||||||
FRANK := tools/franklite.py
|
FRANK := tools/franklite.py
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
INCLUDES := -i include/ -i include/Kyoto_CWD/ -i include/rstl/
|
INCLUDES := -i include/
|
||||||
ASM_INCLUDES := -I include/
|
ASM_INCLUDES := -I include/
|
||||||
|
|
||||||
ASFLAGS := -mgekko $(ASM_INCLUDES) --defsym version=$(VERSION)
|
ASFLAGS := -mgekko $(ASM_INCLUDES) --defsym version=$(VERSION)
|
||||||
|
@ -110,7 +115,8 @@ ifeq ($(VERBOSE),0)
|
||||||
# this set of LDFLAGS generates no warnings.
|
# this set of LDFLAGS generates no warnings.
|
||||||
LDFLAGS := $(MAPGEN) -fp hard -nodefaults -w off
|
LDFLAGS := $(MAPGEN) -fp hard -nodefaults -w off
|
||||||
endif
|
endif
|
||||||
CFLAGS = -Cpp_exceptions off -enum int -inline auto -proc gekko -RTTI off -fp hard -fp_contract on -str pool -rostr -O4,p -use_lmw_stmw on -sdata 8 -sdata2 8 -nodefaults $(INCLUDES)
|
CFLAGS_1.2 = -Cpp_exceptions off -enum int -inline auto -proc gekko -RTTI off -fp hard -fp_contract on -str pool -rostr -O4,p -use_lmw_stmw on -sdata 8 -sdata2 8 -nodefaults -MMD $(INCLUDES)
|
||||||
|
CFLAGS = $(CFLAGS_1.2) -gccinc
|
||||||
|
|
||||||
ifeq ($(VERBOSE),0)
|
ifeq ($(VERBOSE),0)
|
||||||
# this set of ASFLAGS generates no warnings.
|
# this set of ASFLAGS generates no warnings.
|
||||||
|
@ -118,7 +124,9 @@ ASFLAGS += -W
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(BUILD_DIR)/src/os/__start.o: MWCC_VERSION := 1.2.5
|
$(BUILD_DIR)/src/os/__start.o: MWCC_VERSION := 1.2.5
|
||||||
|
$(BUILD_DIR)/src/os/__start.o: CFLAGS := $(CFLAGS_1.2)
|
||||||
$(BUILD_DIR)/src/Dolphin/PPCArch.o: MWCC_VERSION := 1.2.5
|
$(BUILD_DIR)/src/Dolphin/PPCArch.o: MWCC_VERSION := 1.2.5
|
||||||
|
$(BUILD_DIR)/src/Dolphin/PPCArch.o: CFLAGS := $(CFLAGS_1.2)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Recipes
|
# Recipes
|
||||||
|
@ -152,15 +160,11 @@ $(DOL): $(ELF) | tools
|
||||||
$(QUIET) $(ELF2DOL) $< $@
|
$(QUIET) $(ELF2DOL) $< $@
|
||||||
$(QUIET) $(SHA1SUM) -c sha1/$(NAME).$(VERSION).sha1
|
$(QUIET) $(SHA1SUM) -c sha1/$(NAME).$(VERSION).sha1
|
||||||
ifneq ($(findstring -map,$(LDFLAGS)),)
|
ifneq ($(findstring -map,$(LDFLAGS)),)
|
||||||
$(QUIET) $(PYTHON) tools/calcprogress.py $@
|
$(QUIET) $(PYTHON) tools/calcprogress.py $(DOL) $(MAP)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f -d -r build
|
$(RM) $(O_FILES) $(DEPENDS)
|
||||||
rm -f -d -r epilogue
|
|
||||||
find . -name '*.o' -exec rm {} +
|
|
||||||
find . -name 'ctx.c' -exec rm {} +
|
|
||||||
find ./include -name "*.s" -type f -delete
|
|
||||||
$(MAKE) -C tools clean
|
$(MAKE) -C tools clean
|
||||||
tools:
|
tools:
|
||||||
$(MAKE) -C tools
|
$(MAKE) -C tools
|
||||||
|
@ -178,21 +182,27 @@ $(ELF): $(O_FILES) $(LDSCRIPT)
|
||||||
$(QUIET) $(LD) $(LDFLAGS) -o $@ -lcf $(LDSCRIPT) @build/o_files
|
$(QUIET) $(LD) $(LDFLAGS) -o $@ -lcf $(LDSCRIPT) @build/o_files
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
%.d.unix: %.d $(TRANSFORM_DEP)
|
||||||
|
@echo Processing $<
|
||||||
|
$(QUIET) $(PYTHON) $(TRANSFORM_DEP) $< $@
|
||||||
|
|
||||||
|
-include $(DEPENDS)
|
||||||
|
|
||||||
$(BUILD_DIR)/%.o: %.s
|
$(BUILD_DIR)/%.o: %.s
|
||||||
@echo Assembling $<
|
@echo Assembling $<
|
||||||
$(QUIET) $(AS) $(ASFLAGS) -o $@ $<
|
$(QUIET) $(AS) $(ASFLAGS) -o $@ $<
|
||||||
|
|
||||||
$(BUILD_DIR)/%.o: %.c
|
$(BUILD_DIR)/%.o: %.c
|
||||||
@echo "Compiling " $<
|
@echo "Compiling " $<
|
||||||
$(QUIET) $(CC) $(CFLAGS) -c -o $@ $<
|
$(QUIET) $(CC) $(CFLAGS) -c -o $(dir $@) $<
|
||||||
|
|
||||||
$(BUILD_DIR)/%.o: %.cp
|
$(BUILD_DIR)/%.o: %.cp
|
||||||
@echo "Compiling " $<
|
@echo "Compiling " $<
|
||||||
$(QUIET) $(CC) $(CFLAGS) -c -o $@ $<
|
$(QUIET) $(CC) $(CFLAGS) -c -o $(dir $@) $<
|
||||||
|
|
||||||
$(BUILD_DIR)/%.o: %.cpp
|
$(BUILD_DIR)/%.o: %.cpp
|
||||||
@echo "Compiling " $<
|
@echo "Compiling " $<
|
||||||
$(QUIET) $(CC) $(CFLAGS) -c -o $@ $<
|
$(QUIET) $(CC) $(CFLAGS) -c -o $(dir $@) $<
|
||||||
|
|
||||||
ifeq ($(EPILOGUE_PROCESS),1)
|
ifeq ($(EPILOGUE_PROCESS),1)
|
||||||
$(EPILOGUE_DIR)/%.o: %.c $(BUILD_DIR)/%.o
|
$(EPILOGUE_DIR)/%.o: %.c $(BUILD_DIR)/%.o
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#! /bin/bash
|
#!/bin/bash -e
|
||||||
|
|
||||||
python tools/deincbin.py "$1" > "$1.deincbin.s"
|
python tools/deincbin.py "$1" > "$1.deincbin.s"
|
||||||
mv "$1.deincbin.s" "$1"
|
mv "$1.deincbin.s" "$1"
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
def apply(config, args):
|
||||||
|
config["arch"] = "ppc"
|
||||||
|
config["objdump_executable"] = "/opt/devkitpro/devkitPPC/bin/powerpc-eabi-objdump"
|
||||||
|
config["objdump_flags"] = ["-M", "gekko"]
|
||||||
|
config["source_directories"] = ["."]
|
||||||
|
config["make_flags"] = [
|
||||||
|
"VERBOSE=1",
|
||||||
|
args.objfile.replace("src/", "asm/") # also build asm obj
|
||||||
|
]
|
|
@ -1,2 +1,3 @@
|
||||||
|
#!/bin/bash -e
|
||||||
echo "$1 -> $2"
|
echo "$1 -> $2"
|
||||||
find . -type f -name '*.s' | xargs sed -i "s/$1/$2/g"
|
find . -type f -name '*.s' | xargs sed -i "s/$1/$2/g"
|
||||||
|
|
|
@ -31,8 +31,8 @@ import math
|
||||||
# #
|
# #
|
||||||
###############################################
|
###############################################
|
||||||
|
|
||||||
DOL_PATH = "baserom.dol"
|
DOL_PATH = sys.argv[1]
|
||||||
MAP_PATH = "build/mp1.0/MetroidPrime.MAP"
|
MAP_PATH = sys.argv[2]
|
||||||
|
|
||||||
MEM1_HI = 0x81200000
|
MEM1_HI = 0x81200000
|
||||||
MEM1_LO = 0x80004000
|
MEM1_LO = 0x80004000
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
../asm_differ/diff.py -mwo -f build/mp1.0/src/"$1" "$2" --width 100 -U 20
|
|
@ -0,0 +1,57 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import argparse
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
def import_d_file(in_file) -> str:
|
||||||
|
out_text = ''
|
||||||
|
|
||||||
|
with open(in_file) as file:
|
||||||
|
for idx, line in enumerate(file):
|
||||||
|
if idx == 0:
|
||||||
|
if line.endswith(' \\\n'):
|
||||||
|
out_text += line[:-3].replace('\\', '/') + " \\\n"
|
||||||
|
else:
|
||||||
|
out_text += line.replace('\\', '/')
|
||||||
|
else:
|
||||||
|
suffix = ''
|
||||||
|
if line.endswith(' \\\n'):
|
||||||
|
suffix = ' \\'
|
||||||
|
path = line.lstrip()[:-3]
|
||||||
|
else:
|
||||||
|
path = line.strip()
|
||||||
|
if path.startswith('Z:'):
|
||||||
|
# direct mapping to unix path
|
||||||
|
path = path[2:].replace('\\', '/')
|
||||||
|
else:
|
||||||
|
# use winepath (very slow!)
|
||||||
|
cmd = subprocess.run(['winepath', '-u', path], capture_output=True, env={'WINEDEBUG': '-all'})
|
||||||
|
if cmd.returncode != 0:
|
||||||
|
print("winepath failed with exit code %d:" % cmd.returncode, cmd.stderr)
|
||||||
|
exit(1)
|
||||||
|
path = cmd.stdout.decode('utf-8').rstrip()
|
||||||
|
out_text += "\t" + path + suffix + "\n"
|
||||||
|
|
||||||
|
return out_text
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="""Transform a .d file from Wine paths to normal paths"""
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"d_file",
|
||||||
|
help="""Dependency file in""",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"d_file_out",
|
||||||
|
help="""Dependency file out""",
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
output = import_d_file(args.d_file)
|
||||||
|
|
||||||
|
with open(args.d_file_out, "w", encoding="UTF-8") as f:
|
||||||
|
f.write(output)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in New Issue