Move Memtest86+ version number to an external file (along with the the latest GIT commit hash) (#75)

This commit is contained in:
Sam Demeulemeester 2023-01-03 00:39:10 +01:00
parent 036922ab26
commit da7b9b955d
4 changed files with 19 additions and 14 deletions

View File

@ -22,7 +22,7 @@
#include "config.h"
#include "error.h"
#include "githash.h"
#include "build_version.h"
#include "tests.h"
@ -103,7 +103,7 @@ void display_init(void)
set_foreground_colour(BLACK);
set_background_colour(WHITE);
clear_screen_region(0, 0, 0, 27);
prints(0, 0, " Memtest86+ v6.01");
prints(0, 0, " Memtest86+ v" MT_VERSION);
set_foreground_colour(RED);
printc(0, 15, '+');
set_foreground_colour(WHITE);
@ -137,8 +137,7 @@ void display_init(void)
set_background_colour(WHITE);
clear_screen_region(ROW_FOOTER, 0, ROW_FOOTER, SCREEN_WIDTH - 1);
prints(ROW_FOOTER, 0, " <ESC> Exit <F1> Configuration <Space> Scroll Lock");
prints(ROW_FOOTER, 64, "6.01.");
prints(ROW_FOOTER, 69, GIT_HASH);
prints(ROW_FOOTER, 64, MT_VERSION "." GIT_HASH);
#if TESTWORD_WIDTH > 32
prints(ROW_FOOTER, 76, ".x64");
#else

2
app/version.h Normal file
View File

@ -0,0 +1,2 @@
#define MT_VERSION "6.01"
#define GIT_HASH "unknown"

View File

@ -106,20 +106,22 @@ 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/githash.h
app/%.o: ../app/%.c app/build_version.h
@mkdir -p app
$(CC) -c $(CFLAGS) -Os $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d)
app/githash.h: FORCE
app/build_version.h: FORCE
@mkdir -p app
@( \
cp -f ../app/version.h $@.tmp; \
if $(GIT_AVAILABLE) && test -d ../.git ; then \
hash=`git rev-parse HEAD | cut -c1-7`; \
sed -i 's/GIT_HASH\s\".*"/GIT_HASH "'$$hash'"/' $@.tmp; \
else \
hash="unknown"; \
sed -i 's/GIT_HASH\s\".*"/GIT_HASH "unknown"/' $@.tmp; \
fi; \
define=`echo "#define GIT_HASH \"$$hash\""`; \
echo $$define | diff - $@ > /dev/null 2>&1 || echo $$define > $@; \
cmp $@ $@.tmp 2>/dev/null || cp -f $@.tmp $@; \
rm -f $@.tmp; \
)
FORCE:

View File

@ -105,20 +105,22 @@ 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/githash.h
app/%.o: ../app/%.c app/build_version.h
@mkdir -p app
$(CC) -c $(CFLAGS) -Os $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d)
app/githash.h: FORCE
app/build_version.h: FORCE
@mkdir -p app
@( \
cp -f ../app/version.h $@.tmp; \
if $(GIT_AVAILABLE) && test -d ../.git ; then \
hash=`git rev-parse HEAD | cut -c1-7`; \
sed -i 's/GIT_HASH\s\".*"/GIT_HASH "'$$hash'"/' $@.tmp; \
else \
hash="unknown"; \
sed -i 's/GIT_HASH\s\".*"/GIT_HASH "unknown"/' $@.tmp; \
fi; \
define=`echo "#define GIT_HASH \"$$hash\""`; \
echo $$define | diff - $@ > /dev/null 2>&1 || echo $$define > $@; \
cmp $@ $@.tmp 2>/dev/null || cp -f $@.tmp $@; \
rm -f $@.tmp; \
)
FORCE: