Merge pull request #153 from ricfehr3/feature/add-version
Add git hash baked into ROM for bug reports
This commit is contained in:
@@ -38,17 +38,23 @@ GRAPHICS := graphics
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -mthumb -mthumb-interwork
|
||||
|
||||
GIT_DIRTY := $(shell git diff-index --quiet HEAD -- || echo "-dirty")
|
||||
GIT_HASH := $(shell git rev-parse --short HEAD || echo "undef")
|
||||
GIT_C_FLAGS := -DGIT_HASH=\"$(GIT_HASH)\" -DGIT_DIRTY=\"$(GIT_DIRTY)\"
|
||||
|
||||
CFLAGS := -g -O3 -Wall -Werror\
|
||||
-mcpu=arm7tdmi -mtune=arm7tdmi \
|
||||
-ffast-math -fomit-frame-pointer -funroll-loops \
|
||||
$(ARCH)
|
||||
|
||||
CFLAGS += $(GIT_C_FLAGS)
|
||||
|
||||
CFLAGS += $(INCLUDE)
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map),--undefined=balatro_version
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import re
|
||||
|
||||
def grep_binary_offsets(path, pattern):
|
||||
with open(path, "rb") as f:
|
||||
data = f.read()
|
||||
|
||||
results = []
|
||||
for match in re.finditer(rb"[ -~]{4,}", data):
|
||||
s = match.group()
|
||||
if re.search(pattern.encode(), s):
|
||||
results.append((match.start(), s.decode("utf-8", errors="ignore")))
|
||||
return results
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: python script.py <file>")
|
||||
sys.exit(1)
|
||||
|
||||
file_path = sys.argv[1]
|
||||
pattern = "GBALATRO_VERSION"
|
||||
|
||||
for offset, text in grep_binary_offsets(file_path, pattern):
|
||||
version = text.split(":")[1]
|
||||
print(f"git hash: {version}")
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef GIT_HASH
|
||||
#define GIT_HASH "undef"
|
||||
#endif
|
||||
|
||||
#ifndef GIT_DIRTY
|
||||
#define GIT_DIRTY "-dirty"
|
||||
#endif
|
||||
|
||||
__attribute__((section(".version"), used))
|
||||
const char balatro_version[] = "GBALATRO_VERSION:" GIT_HASH GIT_DIRTY;
|
||||
Reference in New Issue
Block a user