diff --git a/cube/swiss/Makefile b/cube/swiss/Makefile index c27d5922..69744114 100644 --- a/cube/swiss/Makefile +++ b/cube/swiss/Makefile @@ -54,7 +54,7 @@ INCLUDES := include $(SOURCES) .. # options for code generation #--------------------------------------------------------------------------------- -CFLAGS = -g -O2 -Wall -Wno-format-truncation -fno-strict-aliasing -D_GNU_SOURCE $(MACHDEP) $(INCLUDE) -D'GITREVISION="$(shell git rev-parse --short HEAD)"' -D'GITVERSION="$(shell git rev-list HEAD | wc -l)"' +CFLAGS = -g -O2 -Wall -Wno-format-truncation -fno-strict-aliasing -D_GNU_SOURCE $(MACHDEP) $(INCLUDE) -D'GIT_COMMIT="$(shell git rev-parse --short HEAD)"' -D'GIT_REVISION="$(shell git rev-list HEAD | wc -l)"' CXXFLAGS = $(CFLAGS) ASFLAGS = $(MACHDEP) -mregnames -D_LANGUAGE_ASSEMBLY $(INCLUDE) @@ -110,7 +110,7 @@ export OFILES_BIN := $(addsuffix .o,$(BINFILES)) $(addsuffix .o,$(TPLFILES)) export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(sFILES:.s=.o) $(SFILES:.S=.o) export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) -export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) $(addsuffix .h,$(subst .,_,$(TPLFILES))) +export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) $(addsuffix .h,$(subst .,_,$(TPLFILES))) tags.h #--------------------------------------------------------------------------------- # build a list of include paths @@ -165,6 +165,12 @@ $(OFILES_SOURCES) : $(HFILES) $(SILENTMSG) $(notdir $<) $(bin2o) +#--------------------------------------------------------------------------------- +tags.h : +#--------------------------------------------------------------------------------- + $(SILENTMSG) $(notdir $@) + $(SILENTCMD)git for-each-ref --format='"%(objectname:short)",' refs/tags > $@ + -include $(DEPENDS) #--------------------------------------------------------------------------------- diff --git a/cube/swiss/source/gui/FrameBufferMagic.c b/cube/swiss/source/gui/FrameBufferMagic.c index f9ce8c77..986a9ed4 100644 --- a/cube/swiss/source/gui/FrameBufferMagic.c +++ b/cube/swiss/source/gui/FrameBufferMagic.c @@ -1459,7 +1459,7 @@ static void _DrawTitleBar(uiDrawObj_t *evt) { _DrawSimpleBox(19, 17, 602, 62, 0, fillColor, noColor); drawString(40, 28, "Swiss v0.6", 1.5f, false, defaultColor); - sprintf(fbTextBuffer, "commit: %s rev: %s", GITREVISION, GITVERSION); + sprintf(fbTextBuffer, "commit: %s rev: %s", GIT_COMMIT, GIT_REVISION); drawString(412, 50, fbTextBuffer, 0.55f, false, defaultColor); s8 cputemp = SYS_GetCoreTemperature(); diff --git a/cube/swiss/source/gui/info.c b/cube/swiss/source/gui/info.c index fef6a608..ab6038b4 100644 --- a/cube/swiss/source/gui/info.c +++ b/cube/swiss/source/gui/info.c @@ -168,7 +168,7 @@ uiDrawObj_t * info_draw_page(int page_num) { DrawAddChild(container, DrawLabel(30, 55, "Version Info (3/4):")); DrawAddChild(container, DrawStyledLabel(640/2, 115, "Swiss version 0.6", 1.0f, true, defaultColor)); DrawAddChild(container, DrawStyledLabel(640/2, 140, "by emu_kidid & Extrems, 2024", 0.75f, true, defaultColor)); - sprintf(topStr, "Commit %s Revision %s", GITREVISION, GITVERSION); + sprintf(topStr, "Commit %s Revision %s", GIT_COMMIT, GIT_REVISION); DrawAddChild(container, DrawStyledLabel(640/2, 165, topStr, 0.75f, true, defaultColor)); DrawAddChild(container, DrawStyledLabel(640/2, 220, "Source/Updates/Issues", 0.75f, true, defaultColor)); DrawAddChild(container, DrawStyledLabel(640/2, 244, "github.com/emukidid/swiss-gc", 0.64f, true, defaultColor)); diff --git a/cube/swiss/source/main.c b/cube/swiss/source/main.c index 047e26ef..4ed0cf30 100644 --- a/cube/swiss/source/main.c +++ b/cube/swiss/source/main.c @@ -162,8 +162,8 @@ int main(int argc, char *argv[]) } print_gecko("Arena Size: %iKb\r\n",(SYS_GetArena1Hi()-SYS_GetArena1Lo())/1024); print_gecko("DVD Drive Present? %s\r\n",swissSettings.hasDVDDrive?"Yes":"No"); - print_gecko("GIT Commit: %s\r\n", GITREVISION); - print_gecko("GIT Revision: %s\r\n", GITVERSION); + print_gecko("GIT Commit: %s\r\n", GIT_COMMIT); + print_gecko("GIT Revision: %s\r\n", GIT_REVISION); } // Go through all devices with FEAT_BOOT_DEVICE feature and set it as current if one is available diff --git a/cube/swiss/source/util.c b/cube/swiss/source/util.c index 60cd82a0..da099c7f 100644 --- a/cube/swiss/source/util.c +++ b/cube/swiss/source/util.c @@ -155,10 +155,13 @@ char *stripInvalidChars(char *str) return stripbuffer; } +static const char git_tags[][sizeof(GIT_COMMIT)] = { +#include "tags.h" +}; /* Autoboot DOL from the current device, from the current autoboot_dols list */ char *autoboot_dols[] = {"*/boot.dol", "*/boot2.dol", "*/swiss_r[1-9]*.dol"}; // Keep this list sorted void load_auto_dol() { - u8 rev_buf[sizeof(GITREVISION) - 1]; // Don't include the NUL termination in the comparison + char trailer[sizeof(GIT_COMMIT) - 1]; // Don't include the NUL termination in the comparison memcpy(&curDir, devices[DEVICE_CUR]->initial, sizeof(file_handle)); scanFiles(); @@ -170,9 +173,10 @@ void load_auto_dol() { // Official Swiss releases have the short commit hash appended to // the end of the DOL, compare it to our own to make sure we don't // bootloop the same version - devices[DEVICE_CUR]->seekFile(dirEntries[i], -sizeof(rev_buf), DEVICE_HANDLER_SEEK_END); - devices[DEVICE_CUR]->readFile(dirEntries[i], rev_buf, sizeof(rev_buf)); - if (memcmp(GITREVISION, rev_buf, sizeof(rev_buf)) != 0) { + devices[DEVICE_CUR]->seekFile(dirEntries[i], -sizeof(trailer), DEVICE_HANDLER_SEEK_END); + devices[DEVICE_CUR]->readFile(dirEntries[i], trailer, sizeof(trailer)); + if (memcmp(GIT_COMMIT, trailer, sizeof(trailer)) != 0 && + memmem(git_tags, sizeof(git_tags), trailer, sizeof(trailer)) == NULL) { // Emulate some of the menu's behavior to satisfy boot_dol curSelection = i; memcpy(&curFile, dirEntries[i], sizeof(file_handle));