]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
Use git_commit_info.h if it has been generated
authorLasse Collin <lasse.collin@tukaani.org>
Mon, 7 Apr 2025 14:38:32 +0000 (17:38 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Mon, 7 Apr 2025 14:38:32 +0000 (17:38 +0300)
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.

src/common/common_w32res.rc
src/liblzma/common/common.c
src/lzmainfo/lzmainfo.c
src/xz/message.c
src/xzdec/xzdec.c

index 8114ee311e6367bc9b613b6cd2ec51b3ede7f5ee..614ab276e9ea7c9e27fc38bb3718e1a9875b9391 100644 (file)
@@ -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"
index 6e031a56c888c21be1a4577bb1b84abf57315e53..9f111d08433bc6785a94b926ec15c3ebb65830e9 100644 (file)
 
 #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;
 }
 
 
index 0b0b0d3d09a4d59ac5472b84a26b032f23b93d5d..b9143f1ce07aabd8d4e268a97805aa2f27cd8410 100644 (file)
 #      include <io.h>
 #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);
 }
 
index 7657e85648dadd9ecd32059418502d7c82335470..f92d39be301119995ca283c3bfde8fba9ad7774f 100644 (file)
 #include "tuklib_mbstr_wrap.h"
 #include <stdarg.h>
 
+#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());
        }
 
index 96e2444438c203e18f9b2577ec3423b40a08ffba..ea400b272698abe3cd27291c6b434ec102b5d434 100644 (file)
 #      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);