Skip to content

Improve cmake vdate depends #517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions bin/mkvdate
Original file line number Diff line number Diff line change
@@ -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 <<EOF
#include <time.h>
extern const time_t MDate;
const time_t MDate = $(date +%s);
extern const char *MaikoGitVersion;
const char *MaikoGitVersion = "maiko git version: $MAIKO_REV";
EOF