From 578b26547afffb47c7a06992b2462d8aa1a2122d Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Tue, 19 Nov 2024 15:20:44 -0800 Subject: [PATCH 1/2] Updates CMakeLists.txt to avoid recreating vdate.c if nothing has changed Creating vdate.c/vdate.o should not be done unconditionally. It is only necessary to recreate it if one of the input files has changed. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 851d4a2..543edf4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -438,9 +438,9 @@ SET(MAIKO_HDRS inc/z2defs.h ) -ADD_CUSTOM_TARGET(gen-vdate +ADD_CUSTOM_COMMAND(OUTPUT vdate.c COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bin/mkvdate > vdate.c - BYPRODUCTS vdate.c + DEPENDS ${MAIKO_SRCS} ${MAIKO_HDRS} ${MAIKO_DISPLAY_X11_SRCS} ${MAIKO_DISPLAY_X11_HDRS} ${MAIKO_DISPLAY_SDL_SRCS} ${MAIKO_DISPLAY_SDL_HDRS} ) ADD_EXECUTABLE(lde src/ldeboot.c src/unixfork.c) From 96046c01f0b11f8280146c75afe55fcbdbeba0b8 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 20 Nov 2024 11:18:41 -0800 Subject: [PATCH 2/2] Adds MaikoGitVersion string to vdate.o The variable MaikoGitVersion will contain a git revision from the head of the source tree along with an indication if the status was "dirty". If git is not present on the system or the directory that the build happened in was not under git control the version will be "none". --- bin/mkvdate | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bin/mkvdate b/bin/mkvdate index 2c4b514..b440183 100755 --- a/bin/mkvdate +++ b/bin/mkvdate @@ -1,6 +1,22 @@ #!/bin/sh +if command -v "git" >/dev/null 2>&1; then + MAIKO_REV="$(git status --porcelain)" + if [ $? == 0 ]; then + if [ ! -z "$(git status --porcelain)" ]; then + MAIKO_REV="$(git rev-parse --short HEAD)-dirty" + else + MAIKO_REV="$(git rev-parse --short HEAD)" + fi + else + MAIKO_REV="none" + fi +else + MAIKO_REV = "none" +fi cat < extern const time_t MDate; const time_t MDate = $(date +%s); +extern const char *MaikoGitVersion; +const char *MaikoGitVersion = "maiko git version: $MAIKO_REV"; EOF