mirror of https://github.com/krallin/tini.git
More robust git version checking
- Check the exit code from git log to check if we have a version. - Add a "-dirty" suffix if the repo is dirty when the build is made.
This commit is contained in:
parent
9b8a8a5764
commit
405eea7941
|
@ -5,7 +5,29 @@ project (tini C)
|
|||
set (tini_VERSION_MAJOR 0)
|
||||
set (tini_VERSION_MINOR 6)
|
||||
set (tini_VERSION_PATCH 0)
|
||||
execute_process (COMMAND git log -n 1 --date=local --pretty=format:"%h" WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" OUTPUT_VARIABLE tini_VERSION_GIT)
|
||||
|
||||
# Extract git version and dirty-ness
|
||||
execute_process (
|
||||
COMMAND git log -n 1 --date=local --pretty=format:%h
|
||||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE git_version_check_ret
|
||||
OUTPUT_VARIABLE tini_VERSION_GIT
|
||||
)
|
||||
|
||||
execute_process(
|
||||
COMMAND git status --porcelain --untracked-files=no
|
||||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE git_dirty_check_out
|
||||
)
|
||||
|
||||
if("${git_version_check_ret}" EQUAL 0)
|
||||
set(tini_VERSION_GIT " - git.${tini_VERSION_GIT}")
|
||||
if(NOT "${git_dirty_check_out}" STREQUAL "")
|
||||
set(tini_VERSION_GIT "${tini_VERSION_GIT}-dirty")
|
||||
endif()
|
||||
else()
|
||||
set(tini_VERSION_GIT "")
|
||||
endif()
|
||||
|
||||
# Flags
|
||||
add_definitions (-D_FORTIFY_SOURCE=2)
|
||||
|
|
|
@ -81,7 +81,7 @@ int spawn(const sigset_t* const child_sigset_ptr, char* const argv[], int* const
|
|||
|
||||
|
||||
void print_usage(char* const name, FILE* const file) {
|
||||
fprintf(file, "%s (version %s - %s)\n", basename(name), TINI_VERSION, TINI_GIT);
|
||||
fprintf(file, "%s (version %s%s)\n", basename(name), TINI_VERSION, TINI_GIT);
|
||||
fprintf(file, "Usage: %s [OPTIONS] PROGRAM -- [ARGS]\n\n", basename(name));
|
||||
fprintf(file, "Execute a program under the supervision of a valid init process (%s)\n\n", basename(name));
|
||||
fprintf(file, " -h: Show this help message and exit.\n");
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#define TINI_VERSION "@tini_VERSION_MAJOR@.@tini_VERSION_MINOR@.@tini_VERSION_PATCH@"
|
||||
#define TINI_GIT @tini_VERSION_GIT@
|
||||
#define TINI_GIT "@tini_VERSION_GIT@"
|
||||
|
|
Loading…
Reference in New Issue