Skip to content

Commit

Permalink
Add ability to build without comparing to original
Browse files Browse the repository at this point in the history
  • Loading branch information
hensldm committed Dec 13, 2023
1 parent eddcfcd commit 81ee07b
Show file tree
Hide file tree
Showing 30 changed files with 80 additions and 11 deletions.
42 changes: 31 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
NON_MATCHING ?= 0
COMPARE ?= 1

# One of:
# libgultra_rom, libgultra_d, libgultra
Expand Down Expand Up @@ -44,6 +45,12 @@ else
$(error Invalid Target)
endif

ifeq ($(NON_MATCHING),1)
CFLAGS += -DNON_MATCHING
CPPFLAGS += -DNON_MATCHING
COMPARE := 0
endif

ifeq ($(findstring _rom,$(TARGET)),_rom)
CPPFLAGS += -D_FINALROM
endif
Expand Down Expand Up @@ -71,7 +78,7 @@ S_MARKER_FILES := $(S_O_FILES:.o=.marker)
S_MARKER_FILES := $(filter-out $(MDEBUG_FILES),$(S_MARKER_FILES))
MARKER_FILES := $(C_MARKER_FILES) $(S_MARKER_FILES)

ifneq ($(NON_MATCHING),1)
ifneq ($(COMPARE),0)
COMPARE_OBJ = cmp $(BASE_DIR)/$(@F:.marker=.o) $(@:.marker=.o) && echo "$(@:.marker=.o): OK"
COMPARE_AR = cmp $(BASE_AR) $@ && echo "$@: OK"
ifeq ($(COMPILER),ido)
Expand All @@ -88,7 +95,7 @@ endif
BASE_OBJS := $(wildcard $(BASE_DIR)/*.o)

# Check to make sure the current version has been set up
ifneq ($(NON_MATCHING),1)
ifneq ($(COMPARE),0)
ifeq ($(BASE_OBJS),)
# Ignore this check if the user is currently running setup, clean or distclean
ifeq ($(filter $(MAKECMDGOALS),setup clean distclean),)
Expand All @@ -97,8 +104,10 @@ endif
endif
endif

AR_OBJECTS := $(shell cat base/$(VERSION)/$(TARGET).txt)

# Try to find a file corresponding to an archive file in any of src/ asm/ or the base directory, prioritizing src then asm then the original file
AR_ORDER = $(foreach f,$(shell $(AR) t $(BASE_AR)),$(shell find $(BUILD_DIR)/src $(BUILD_DIR)/asm $(BASE_DIR) -iname $f -type f -print -quit))
AR_ORDER = $(foreach f,$(AR_OBJECTS),$(shell find $(BUILD_DIR)/src $(BUILD_DIR)/asm $(BASE_DIR) -iname $f -type f -print -quit))
MATCHED_OBJS = $(filter-out $(BASE_DIR)/%,$(AR_ORDER))
UNMATCHED_OBJS = $(filter-out $(MATCHED_OBJS),$(AR_ORDER))
NUM_OBJS = $(words $(AR_ORDER))
Expand All @@ -112,7 +121,7 @@ all: $(BUILD_AR)

$(BUILD_AR): $(MARKER_FILES)
$(AR_OLD) rcs $@ $(AR_ORDER)
ifneq ($(NON_MATCHING),1)
ifneq ($(COMPARE),0)
# patch archive creation time and individual files' ownership & permissions
dd bs=1 skip=24 seek=24 count=12 conv=notrunc if=$(BASE_AR) of=$@ status=none
python3 tools/patch_ar_meta.py $@ $(BASE_AR) $(PATCH_AR_FLAGS)
Expand All @@ -129,15 +138,17 @@ distclean:

setup:
$(MAKE) -C tools
ifneq ($(COMPARE),0)
cd $(BASE_DIR) && $(AR) xo $(WORKING_DIR)/$(BASE_AR)
chmod -R +rw $(BASE_DIR)
ifeq ($(COMPILER),ido)
export CROSS=$(CROSS) && ./tools/strip_debug.sh $(BASE_DIR)
endif
endif

$(BUILD_DIR)/$(BASE_DIR)/%.marker: $(BASE_DIR)/%.o
cp $< $(@:.marker=.o)
ifneq ($(NON_MATCHING),1)
ifneq ($(COMPARE),0)
# change file timestamps to match original
@touch -r $(BASE_DIR)/$(@F:.marker=.o) $(@:.marker=.o)
@$(COMPARE_OBJ)
Expand All @@ -157,7 +168,7 @@ $(BUILD_DIR)/src/voice/%.marker: CC := tools/compile_sjis.py -D__CC=$(WORKING_DI

$(C_MARKER_FILES): $(BUILD_DIR)/%.marker: %.c
cd $(<D) && $(WORKING_DIR)/$(CC) $(CFLAGS) $(MIPS_VERSION) $(CPPFLAGS) $(OPTFLAGS) $(<F) $(IINC) -o $(WORKING_DIR)/$(@:.marker=.o)
ifneq ($(NON_MATCHING),1)
ifneq ($(COMPARE),0)
# check if this file is in the archive; patch corrupted bytes and change file timestamps to match original if so
@$(if $(findstring $(BASE_DIR)/$(@F:.marker=.o), $(BASE_OBJS)), \
python3 tools/fix_objfile.py $(@:.marker=.o) $(BASE_DIR)/$(@F:.marker=.o) $(STRIP) && \
Expand All @@ -166,12 +177,15 @@ ifneq ($(NON_MATCHING),1)
echo "Object file $(@F:.marker=.o) is not in the current archive" \
)
# create or update the marker file
@touch $@
else
tools/set_o32abi_bit.py $(WORKING_DIR)/$(@:.marker=.o)
$(CROSS)strip $(WORKING_DIR)/$(@:.marker=.o) -N asdasdasdasd
endif
@touch $@

$(S_MARKER_FILES): $(BUILD_DIR)/%.marker: %.s
cd $(<D) && $(WORKING_DIR)/$(CC) $(ASFLAGS) $(MIPS_VERSION) $(CPPFLAGS) $(ASOPTFLAGS) $(<F) $(IINC) -o $(WORKING_DIR)/$(@:.marker=.o)
ifneq ($(NON_MATCHING),1)
ifneq ($(COMPARE),0)
# check if this file is in the archive; patch corrupted bytes and change file timestamps to match original if so
@$(if $(findstring $(BASE_DIR)/$(@F:.marker=.o), $(BASE_OBJS)), \
python3 tools/fix_objfile.py $(@:.marker=.o) $(BASE_DIR)/$(@F:.marker=.o) $(STRIP) && \
Expand All @@ -180,16 +194,19 @@ ifneq ($(NON_MATCHING),1)
echo "Object file $(@F:.marker=.o) is not in the current archive" \
)
# create or update the marker file
@touch $@
else
tools/set_o32abi_bit.py $(WORKING_DIR)/$(@:.marker=.o)
$(CROSS)strip $(WORKING_DIR)/$(@:.marker=.o) -N asdasdasdasd
endif
@touch $@

# Rule for building files that require specific file paths in the mdebug section
$(MDEBUG_FILES): $(BUILD_DIR)/src/%.marker: src/%.s
cp $(<:.marker=.s) $(dir $@)
mkdir -p $(@:.marker=)
export USR_INCLUDE=$(WORKING_DIR)/include && cd $(@:.marker=) && $(WORKING_DIR)/$(CC) $(ASFLAGS) $(CPPFLAGS) ../$(<F) -I/usr/include -o $(notdir $(<:.s=.o))
mv $(@:.marker=)/$(<F:.s=.o) $(@:.marker=)/..
ifneq ($(NON_MATCHING),1)
ifneq ($(COMPARE),0)
# check if this file is in the archive; patch corrupted bytes and change file timestamps to match original if so
@$(if $(findstring $(BASE_DIR)/$(@F:.marker=.o), $(BASE_OBJS)), \
python3 tools/fix_objfile.py $(@:.marker=.o) $(BASE_DIR)/$(@F:.marker=.o) && \
Expand All @@ -198,8 +215,11 @@ ifneq ($(NON_MATCHING),1)
echo "Object file $(@F:.marker=.o) is not in the current archive" \
)
# create or update the marker file
@touch $@
else
tools/set_o32abi_bit.py $(WORKING_DIR)/$(@:.marker=.o)
$(CROSS)strip $(WORKING_DIR)/$(@:.marker=.o) -N asdasdasdasd
endif
@touch $@

# Disable built-in rules
.SUFFIXES:
Expand Down
Empty file removed base/I/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions base/I/libgultra.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ackramromread.o ackramromwrite.o aigetlen.o aigetstat.o ai.o aisetfreq.o aisetnextbuf.o align.o assertbreak.o assert.o atomic.o auxbus.o bcmp.o bcopy.o bnkf.o bzero.o cartrominit.o cents2ratio.o clearattribute.o color.o conteeplongread.o conteeplongwrite.o conteepprobe.o conteepread.o conteepwrite.o contpfs.o contquery.o contramread.o contramwrite.o contreaddata.o contreset.o controller.o contsetch.o copy.o cosf.o coss.o crc.o createmesgqueue.o createthread.o cseq.o cspdelete.o cspgetchlvol.o cspgetfxmix.o cspgetpan.o cspgetpriority.o cspgetprogram.o cspgetseq.o cspgetstate.o cspgettempo.o cspgetvol.o csplayer.o cspplay.o cspsendmidi.o cspsetbank.o cspsetchlvol.o cspsetfxmix.o cspsetpan.o cspsetpriority.o cspsetprogram.o cspsetseq.o cspsettempo.o cspsetvol.o cspstop.o delay.o destroythread.o devmgr.o dpctr.o dpgetstat.o dp.o dpsetnextbuf.o dpsetstat.o driverominit.o drvrnew.o dump_gbi.o dumpturbo.o env.o epidma.o epigettype.o epilinkhandle.o epirawdma.o epirawread.o epirawwrite.o epiread.o epiwrite.o errorasm.o error.o event.o exceptasm.o exit.o filter.o free.o frustum.o getactivequeue.o getbufcount.o getcause.o getcompare.o getconfig.o getcount.o getcurrfaultthread.o getfpccsr.o getintmask.o getmemsize.o getnextfaultthread.o getsize.o getsr.o getthreadid.o getthreadpri.o gettime.o gettlbasid.o gettlbhi.o gettlblo0.o gettlblo1.o gettlbpagemask.o giointerrupt.o giorawinterrupt.o gt.o guloadtile_bug.o heapalloc.o heapcheck.o heapinit.o hide.o host_ptn64.o initialize.o initrdb.o interrupt.o invaldcache.o invalicache.o jammesg.o kdebugserver.o ldiv.o leodiskinit.o leointerrupt.o libm_vals.o llbit.o llcvt.o ll.o load.o loadtextureblockmipmap.o logfloat.o log.o lookathil.o lookat.o lookatref.o lookatstereo.o mainbus.o malloc.o maptlb.o maptlbrdb.o motor.o mtxcatf.o mtxcatl.o mtxutil.o normalize.o ortho.o parameters.o parse_abi.o parse_gbi.o parse_rdp.o parse_string.o perspective.o pfsallocatefile.o pfschecker.o pfsdeletefile.o pfsfilestate.o pfsfreeblocks.o pfsgetlabel.o pfsgetstatus.o pfsinit.o pfsinitpak.o pfsisplug.o pfsnumfiles.o pfsreadwritefile.o pfsreformat.o pfsrepairid.o pfssearchfile.o pfssetlabel.o physicaltovirtual.o piacs.o pidma.o pigetcmdq.o pigetstat.o pigettype.o pimgr.o pi.o pirawdma.o pirawread.o pirawwrite.o piread.o piwrite.o position.o poslighthil.o poslight.o printregion.o probetlb.o profile.o random.o rdbsend.o readhost.o recvmesg.o region.o resample.o resetglobalintmask.o reverb.o rmonbrk.o rmoncmds.o rmonmain.o rmonmem.o rmonmisc.o rmonprint.o rmonrcp.o rmonregs.o rmonsio.o rmontask.o rotate.o rotaterpy.o save.o scale.o sched.o sendmesg.o seq.o seqpdelete.o seqpgetchlvol.o seqpgetfxmix.o seqpgetpan.o seqpgetpriority.o seqpgetprogram.o seqpgetseq.o seqpgetstate.o seqpgettempo.o seqpgetvol.o seqplayer.o seqploop.o seqpplay.o seqpsendmidi.o seqpsetbank.o seqpsetchlvol.o seqpsetfxmix.o seqpsetpan.o seqpsetpriority.o seqpsetprogram.o seqpsetseq.o seqpsettempo.o seqpsetvol.o seqpstop.o setattribute.o setcause.o setcompare.o setconfig.o setcount.o seterrorhandler.o seteventmesg.o setfpccsr.o setglobalintmask.o sethwinterrupt.o setintmask.o setsr.o setthreadpri.o settime.o settimer.o settlbasid.o show.o siacs.o sigetstat.o sinf.o sins.o si.o sirawdma.o sirawread.o sirawwrite.o sl.o sndpallocate.o sndpdeallocate.o sndpdelete.o sndpgetsound.o sndpgetstate.o sndplayer.o sndpplayat.o sndpplay.o sndpsetfxmix.o sndpsetpan.o sndpsetpitch.o sndpsetpriority.o sndpsetsound.o sndpsetvol.o sndpstop.o spgetstat.o sp.o sprawdma.o sprawread.o sprawwrite.o sprintf.o sprite.o spscale.o spsetpc.o spsetstat.o sptask.o sptaskyielded.o sptaskyield.o sqrtf.o startthread.o stopthread.o stoptimer.o string.o synaddplayer.o synallocfx.o synallocvoice.o syncprintf.o syncputchars.o syndelete.o synfreefx.o synfreevoice.o syngetfxref.o syngetpriority.o synremoveplayer.o synsetfxmix.o synsetfxparam.o synsetpan.o synsetpitch.o synsetpriority.o synsetvol.o synstartvoice.o synstartvoiceparam.o synstopvoice.o synthesizer.o testhost.o thread.o timerintr.o translate.o unmaptlball.o unmaptlb.o us2dex_emu.o us2dex.o usprite.o viblack.o vifade.o vigetcurrcontext.o vigetcurrframebuf.o vigetfield.o vigetline.o vigetmode.o vigetnextcontext.o vigetnextframebuf.o vigetstat.o vimgr.o vimodempalhaf1.o vimodempalhan1.o vimodempalhpf1.o vimodempalhpf2.o vimodempalhpn1.o vimodempalhpn2.o vimodempallaf1.o vimodempallaf2.o vimodempallan1.o vimodempallan2.o vimodempallpf1.o vimodempallpf2.o vimodempallpn1.o vimodempallpn2.o vimodentschaf1.o vimodentschan1.o vimodentschpf1.o vimodentschpf2.o vimodentschpn1.o vimodentschpn2.o vimodentsclaf1.o vimodentsclaf2.o vimodentsclan1.o vimodentsclan2.o vimodentsclpf1.o vimodentsclpf2.o vimodentsclpn1.o vimodentsclpn2.o vimodepalhaf1.o vimodepalhan1.o vimodepalhpf1.o vimodepalhpf2.o vimodepalhpn1.o vimodepalhpn2.o vimodepallaf1.o vimodepallaf2.o vimodepallan1.o vimodepallan2.o vimodepallpf1.o vimodepallpf2.o vimodepallpn1.o vimodepallpn2.o vi.o virepeatline.o virtualtophysical.o visetevent.o visetmode.o visetspecial.o visetxscale.o visetyscale.o viswapbuf.o viswapcontext.o vitbl.o writebackdcacheall.o writebackdcache.o writehost.o xldtob.o xlitob.o xprintf.o yieldthread.o
1 change: 1 addition & 0 deletions base/I/libgultra_d.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ackramromread.o ackramromwrite.o aigetlen.o aigetstat.o ai.o aisetfreq.o aisetnextbuf.o align.o assertbreak.o assert.o atomic.o auxbus.o bcmp.o bcopy.o bnkf.o bzero.o cartrominit.o cents2ratio.o clearattribute.o color.o conteeplongread.o conteeplongwrite.o conteepprobe.o conteepread.o conteepwrite.o contpfs.o contquery.o contramread.o contramwrite.o contreaddata.o contreset.o controller.o contsetch.o copy.o cosf.o coss.o crc.o createmesgqueue.o createthread.o cseq.o cspdelete.o cspgetchlvol.o cspgetfxmix.o cspgetpan.o cspgetpriority.o cspgetprogram.o cspgetseq.o cspgetstate.o cspgettempo.o cspgetvol.o csplayer.o cspplay.o cspsendmidi.o cspsetbank.o cspsetchlvol.o cspsetfxmix.o cspsetpan.o cspsetpriority.o cspsetprogram.o cspsetseq.o cspsettempo.o cspsetvol.o cspstop.o delay.o destroythread.o devmgr.o dpctr.o dpgetstat.o dp.o dpsetnextbuf.o dpsetstat.o driverominit.o drvrnew.o dump_gbi.o dumpturbo.o env.o epidma.o epigettype.o epilinkhandle.o epirawdma.o epirawread.o epirawwrite.o epiread.o epiwrite.o errorasm.o error.o event.o exceptasm.o exit.o filter.o free.o frustum.o getactivequeue.o getbufcount.o getcause.o getcompare.o getconfig.o getcount.o getcurrfaultthread.o getfpccsr.o getintmask.o getmemsize.o getnextfaultthread.o getsize.o getsr.o getthreadid.o getthreadpri.o gettime.o gettlbasid.o gettlbhi.o gettlblo0.o gettlblo1.o gettlbpagemask.o giointerrupt.o giorawinterrupt.o gt.o guloadtile_bug.o heapalloc.o heapcheck.o heapinit.o hide.o host_ptn64.o initialize.o initrdb.o interrupt.o invaldcache.o invalicache.o jammesg.o kdebugserver.o ldiv.o leodiskinit.o leointerrupt.o libm_vals.o llbit.o llcvt.o ll.o load.o loadtextureblockmipmap.o logfloat.o log.o lookathil.o lookat.o lookatref.o lookatstereo.o mainbus.o malloc.o maptlb.o maptlbrdb.o motor.o mtxcatf.o mtxcatl.o mtxutil.o normalize.o ortho.o parameters.o parse_abi.o parse_gbi.o parse_rdp.o parse_string.o perspective.o pfsallocatefile.o pfschecker.o pfsdeletefile.o pfsfilestate.o pfsfreeblocks.o pfsgetlabel.o pfsgetstatus.o pfsinit.o pfsinitpak.o pfsisplug.o pfsnumfiles.o pfsreadwritefile.o pfsreformat.o pfsrepairid.o pfssearchfile.o pfssetlabel.o physicaltovirtual.o piacs.o pidma.o pigetcmdq.o pigetstat.o pigettype.o pimgr.o pi.o pirawdma.o pirawread.o pirawwrite.o piread.o piwrite.o position.o poslighthil.o poslight.o printregion.o probetlb.o profile.o random.o rdbsend.o readhost.o recvmesg.o region.o resample.o resetglobalintmask.o reverb.o rmonbrk.o rmoncmds.o rmonmain.o rmonmem.o rmonmisc.o rmonprint.o rmonrcp.o rmonregs.o rmonsio.o rmontask.o rotate.o rotaterpy.o save.o scale.o sched.o sendmesg.o seq.o seqpdelete.o seqpgetchlvol.o seqpgetfxmix.o seqpgetpan.o seqpgetpriority.o seqpgetprogram.o seqpgetseq.o seqpgetstate.o seqpgettempo.o seqpgetvol.o seqplayer.o seqploop.o seqpplay.o seqpsendmidi.o seqpsetbank.o seqpsetchlvol.o seqpsetfxmix.o seqpsetpan.o seqpsetpriority.o seqpsetprogram.o seqpsetseq.o seqpsettempo.o seqpsetvol.o seqpstop.o setattribute.o setcause.o setcompare.o setconfig.o setcount.o seterrorhandler.o seteventmesg.o setfpccsr.o setglobalintmask.o sethwinterrupt.o setintmask.o setsr.o setthreadpri.o settime.o settimer.o settlbasid.o show.o siacs.o sigetstat.o sinf.o sins.o si.o sirawdma.o sirawread.o sirawwrite.o sl.o sndpallocate.o sndpdeallocate.o sndpdelete.o sndpgetsound.o sndpgetstate.o sndplayer.o sndpplayat.o sndpplay.o sndpsetfxmix.o sndpsetpan.o sndpsetpitch.o sndpsetpriority.o sndpsetsound.o sndpsetvol.o sndpstop.o spgetstat.o sp.o sprawdma.o sprawread.o sprawwrite.o sprintf.o sprite.o spscale.o spsetpc.o spsetstat.o sptask.o sptaskyielded.o sptaskyield.o sqrtf.o startthread.o stopthread.o stoptimer.o string.o synaddplayer.o synallocfx.o synallocvoice.o syncprintf.o syncputchars.o syndelete.o synfreefx.o synfreevoice.o syngetfxref.o syngetpriority.o synremoveplayer.o synsetfxmix.o synsetfxparam.o synsetpan.o synsetpitch.o synsetpriority.o synsetvol.o synstartvoice.o synstartvoiceparam.o synstopvoice.o synthesizer.o testhost.o thread.o timerintr.o translate.o unmaptlball.o unmaptlb.o us2dex_emu.o us2dex.o usprite.o viblack.o vifade.o vigetcurrcontext.o vigetcurrframebuf.o vigetfield.o vigetline.o vigetmode.o vigetnextcontext.o vigetnextframebuf.o vigetstat.o vimgr.o vimodempalhaf1.o vimodempalhan1.o vimodempalhpf1.o vimodempalhpf2.o vimodempalhpn1.o vimodempalhpn2.o vimodempallaf1.o vimodempallaf2.o vimodempallan1.o vimodempallan2.o vimodempallpf1.o vimodempallpf2.o vimodempallpn1.o vimodempallpn2.o vimodentschaf1.o vimodentschan1.o vimodentschpf1.o vimodentschpf2.o vimodentschpn1.o vimodentschpn2.o vimodentsclaf1.o vimodentsclaf2.o vimodentsclan1.o vimodentsclan2.o vimodentsclpf1.o vimodentsclpf2.o vimodentsclpn1.o vimodentsclpn2.o vimodepalhaf1.o vimodepalhan1.o vimodepalhpf1.o vimodepalhpf2.o vimodepalhpn1.o vimodepalhpn2.o vimodepallaf1.o vimodepallaf2.o vimodepallan1.o vimodepallan2.o vimodepallpf1.o vimodepallpf2.o vimodepallpn1.o vimodepallpn2.o vi.o virepeatline.o virtualtophysical.o visetevent.o visetmode.o visetspecial.o visetxscale.o visetyscale.o viswapbuf.o viswapcontext.o vitbl.o writebackdcacheall.o writebackdcache.o writehost.o xldtob.o xlitob.o xprintf.o yieldthread.o
Loading

0 comments on commit 81ee07b

Please sign in to comment.