From: Lasse Collin Date: Mon, 7 Apr 2025 14:38:32 +0000 (+0300) Subject: Use git_commit_info.h if it has been generated X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=577d497cca985258b39aa0ce48bb068d1bc91dbf;p=thirdparty%2Fxz.git Use git_commit_info.h if it has been generated Only files that need the commit info #include "git_commit_info.h". This way only those files are rebuilt after git_commit_info.h has been updated. Now lzma_version_string() and xz --version show the commit date and commit ID of the latest commit if the .git directory and the "git" tool were available when building the package. --- diff --git a/src/common/common_w32res.rc b/src/common/common_w32res.rc index 8114ee31..614ab276 100644 --- a/src/common/common_w32res.rc +++ b/src/common/common_w32res.rc @@ -8,6 +8,11 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif +#ifdef HAVE_GIT_COMMIT_INFO_H +# include "git_commit_info.h" +#else +# define GIT_COMMIT_INFO "" +#endif #define LZMA_H_INTERNAL #define LZMA_H_INTERNAL_RC #include "lzma/version.h" @@ -38,11 +43,11 @@ BEGIN BEGIN VALUE "CompanyName", MY_COMPANY VALUE "FileDescription", MY_DESC - VALUE "FileVersion", LZMA_VERSION_STRING + VALUE "FileVersion", LZMA_VERSION_STRING GIT_COMMIT_INFO VALUE "InternalName", MY_NAME VALUE "OriginalFilename", MY_FILENAME VALUE "ProductName", MY_PRODUCT - VALUE "ProductVersion", LZMA_VERSION_STRING + VALUE "ProductVersion", LZMA_VERSION_STRING GIT_COMMIT_INFO END END BLOCK "VarFileInfo" diff --git a/src/liblzma/common/common.c b/src/liblzma/common/common.c index 6e031a56..9f111d08 100644 --- a/src/liblzma/common/common.c +++ b/src/liblzma/common/common.c @@ -11,6 +11,12 @@ #include "common.h" +#ifdef HAVE_GIT_COMMIT_INFO_H +# include "git_commit_info.h" +#else +# define GIT_COMMIT_INFO "" +#endif + ///////////// // Version // @@ -26,7 +32,7 @@ lzma_version_number(void) extern LZMA_API(const char *) lzma_version_string(void) { - return LZMA_VERSION_STRING; + return LZMA_VERSION_STRING GIT_COMMIT_INFO; } diff --git a/src/lzmainfo/lzmainfo.c b/src/lzmainfo/lzmainfo.c index 0b0b0d3d..b9143f1c 100644 --- a/src/lzmainfo/lzmainfo.c +++ b/src/lzmainfo/lzmainfo.c @@ -26,6 +26,12 @@ # include #endif +#ifdef HAVE_GIT_COMMIT_INFO_H +# include "git_commit_info.h" +#else +# define GIT_COMMIT_INFO "" +#endif + tuklib_attr_noreturn static void @@ -70,7 +76,8 @@ tuklib_attr_noreturn static void version(void) { - puts("lzmainfo (" PACKAGE_NAME ") " LZMA_VERSION_STRING); + puts("lzmainfo (" PACKAGE_NAME ") " + LZMA_VERSION_STRING GIT_COMMIT_INFO); tuklib_exit(EXIT_SUCCESS, EXIT_FAILURE, true); } diff --git a/src/xz/message.c b/src/xz/message.c index 7657e856..f92d39be 100644 --- a/src/xz/message.c +++ b/src/xz/message.c @@ -14,6 +14,12 @@ #include "tuklib_mbstr_wrap.h" #include +#ifdef HAVE_GIT_COMMIT_INFO_H +# include "git_commit_info.h" +#else +# define GIT_COMMIT_INFO "" +#endif + /// Number of the current file static unsigned int files_pos = 0; @@ -930,7 +936,8 @@ message_version(void) printf("XZ_VERSION=%" PRIu32 "\nLIBLZMA_VERSION=%" PRIu32 "\n", LZMA_VERSION, lzma_version_number()); } else { - printf("xz (" PACKAGE_NAME ") " LZMA_VERSION_STRING "\n"); + printf("xz (" PACKAGE_NAME ") " + LZMA_VERSION_STRING GIT_COMMIT_INFO "\n"); printf("liblzma %s\n", lzma_version_string()); } diff --git a/src/xzdec/xzdec.c b/src/xzdec/xzdec.c index 96e24444..ea400b27 100644 --- a/src/xzdec/xzdec.c +++ b/src/xzdec/xzdec.c @@ -48,6 +48,12 @@ # endif #endif +#ifdef HAVE_GIT_COMMIT_INFO_H +# include "git_commit_info.h" +#else +# define GIT_COMMIT_INFO "" +#endif + #ifdef LZMADEC # define TOOL_FORMAT "lzma" @@ -108,7 +114,8 @@ tuklib_attr_noreturn static void version(void) { - printf(TOOL_FORMAT "dec (" PACKAGE_NAME ") " LZMA_VERSION_STRING "\n" + printf(TOOL_FORMAT "dec (" PACKAGE_NAME ") " + LZMA_VERSION_STRING GIT_COMMIT_INFO "\n" "liblzma %s\n", lzma_version_string()); tuklib_exit(EXIT_SUCCESS, EXIT_FAILURE, display_errors);