From 5f92ff1a6434e2422cfb8d24ff2896e7377bfde8 Mon Sep 17 00:00:00 2001 From: Sam Demeulemeester Date: Thu, 7 Apr 2022 01:48:27 +0200 Subject: [PATCH] Rework first line, add build number based on git hash, move 32/64b info to build number, add githash.h to git ignore. A better implementation of Makefile is needed (check if git is present and avoid rebuild (APP)*.c if hash is the same --- .gitignore | 3 +++ app/display.c | 16 ++++++++++------ build32/Makefile | 7 ++++++- build64/Makefile | 7 ++++++- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index d6800b8..d5ec6a5 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,6 @@ memtest_shared.bin grub-iso html latex + +# hash file +githash.h diff --git a/app/display.c b/app/display.c index 7fe102d..ef2f5c2 100644 --- a/app/display.c +++ b/app/display.c @@ -21,6 +21,7 @@ #include "config.h" #include "error.h" +#include "githash.h" #include "tests.h" @@ -76,13 +77,9 @@ void display_init(void) set_foreground_colour(BLACK); set_background_colour(WHITE); clear_screen_region(0, 0, 0, 27); -#if TESTWORD_WIDTH > 32 - prints(0, 0, " Memtest86+ v6.00pre (64b)"); -#else - prints(0, 0, " Memtest86+ v6.00pre (32b)"); -#endif + prints(0, 0, " Memtest86+ v6.00b1"); set_foreground_colour(RED); - printc(0, 11, '+'); + printc(0, 14, '+'); set_foreground_colour(WHITE); set_background_colour(BLUE); prints(0,28, "| "); @@ -118,6 +115,13 @@ void display_init(void) set_background_colour(WHITE); clear_screen_region(ROW_FOOTER, 0, ROW_FOOTER, SCREEN_WIDTH - 1); prints(ROW_FOOTER, 0, " exit configuration scroll lock"); + prints(ROW_FOOTER, 64, "6.00."); + prints(ROW_FOOTER, 69, GIT_HASH); +#if TESTWORD_WIDTH > 32 + prints(ROW_FOOTER, 76, ".x64"); +#else + prints(ROW_FOOTER, 76, ".x32"); +#endif set_foreground_colour(WHITE); set_background_colour(BLUE); diff --git a/build32/Makefile b/build32/Makefile index f371dc5..cb3070d 100644 --- a/build32/Makefile +++ b/build32/Makefile @@ -95,10 +95,15 @@ tests/%.o: ../tests/%.c @mkdir -p tests $(CC) -c $(CFLAGS) -O3 $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) -app/%.o: ../app/%.c +app/%.o: ../app/%.c githash.h @mkdir -p app $(CC) -c $(CFLAGS) -Os $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) +githash.h: + echo -n '#ifndef GIT_HASH\n#define GIT_HASH "' > ../app/$@ && \ + git rev-parse HEAD | cut -c1-7 | tr -d "\n" >> ../app/$@ && \ + echo '"\n#endif' >> ../app/$@ + # Link it statically once so I know I don't have undefined symbols and # then link it dynamically so I have full relocation information. diff --git a/build64/Makefile b/build64/Makefile index 7127305..5b1f7ed 100644 --- a/build64/Makefile +++ b/build64/Makefile @@ -94,10 +94,15 @@ tests/%.o: ../tests/%.c @mkdir -p tests $(CC) -c $(CFLAGS) -O3 $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) -app/%.o: ../app/%.c +app/%.o: ../app/%.c githash.h @mkdir -p app $(CC) -c $(CFLAGS) -Os $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) +githash.h: + echo -n '#ifndef GIT_HASH\n#define GIT_HASH "' > ../app/$@ && \ + git rev-parse HEAD | cut -c1-7 | tr -d "\n" >> ../app/$@ && \ + echo '"\n#endif' >> ../app/$@ + # Link it statically once so I know I don't have undefined symbols and # then link it dynamically so I have full relocation information.