git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/9] GIT-VERSION-GEN: move default version into a separate file

From
Patrick Steinhardt <ps@pks.im>
Date
Jan 13, 2025, 08:33 UTC
Message-ID
<20250113-b4-pks-meson-additions-v1-2-97f6a93f691d@pks.im>
In-Reply-To
<20250113-b4-pks-meson-additions-v1-0-97f6a93f691d@pks.im>

The Git version for Meson is currently wired up manually. It can thus grow (and alread has grown) stale quite easily, as having multiple sources of truth is never a good idea. This issue is mostly of cosmetic nature as we don't use the project version anywhere, and instead use the GIT-VERSION-GEN script to propagate the correct version into our build. But it is somewhat puzzling when `meson setup` announces to build an old Git release.

There are a couple of alternatives for how to solve this:
  - We can keep the version undefined, but this makes Meson output
    "undefined" for the version, as well.
  - We can adapt GIT-VERSION-GEN so that it knows to print a version to
    stdout with a specific invocation and then use `run_command()`. At
    the point of configuring the project we haven't yet figured out host
    details though, and thus we didn't yet set up the shell environment.
    While not an issue for Unix-based systems, this would be an issue in
    Windows, where the shell typically gets provided via Git for Windows
    and thus requires some special setup.
  - We can pull the default version out of GIT-VERSION-GEN and move it
    into its own file. This likely requires some adjustments for scripts
    that bump the version, but allows Meson to read the version from
    that file trivially.

The last option is a proper solution and quite trivial to implement, and adapting scripts should be a one-time event. Refactor GIT-VERSION-GEN accordingly.

This refactoring also prepares for a planned consolidation of all build scripts into a separate folder. This should reduce clutter and make it easier to find all scripts part of the build process.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 GIT-VERSION     | 1 +
 GIT-VERSION-GEN | 4 ++--
 meson.build     | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/GIT-VERSION b/GIT-VERSION
new file mode 100644
index 0000000000000000000000000000000000000000..ed39430ff189488182bc6d651bdb88a531498baa
--- /dev/null
+++ b/GIT-VERSION
@@ -0,0 +1 @@
+v2.48.0
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 754b8ca9eedaa2f7e3b61c83c1cc763538394fe6..95d7d41d233450774a6580c0de332e7b8f69eb4e 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -1,7 +1,5 @@
 #!/bin/sh
 
-DEF_VER=v2.48.0
-
 LF='
 '
 
@@ -21,6 +19,8 @@ then
 	exit 1
 fi
 
+DEF_VER=$(cat "$SOURCE_DIR"/GIT-VERSION)
+
 # Protect us from reading Git version information outside of the Git directory
 # in case it is not a repository itself, but embedded in an unrelated
 # repository.
diff --git a/meson.build b/meson.build
index 7361eb2eaad422e7a6c6ed95d275615836c21cdb..87755537d2aff84a9d8e86f0f5b025ef8dd23292 100644
--- a/meson.build
+++ b/meson.build
@@ -170,7 +170,7 @@
 
 project('git', 'c',
   meson_version: '>=0.61.0',
-  version: 'v2.47.GIT',
+  version: files('GIT-VERSION'),
 )
 
 fs = import('fs')
-- 
2.48.0.257.gd3603152ad.dirty
Previous: Patrick SteinhardtNext: Junio C Hamano
Message 3 of 35 in “meson: a couple of additions”
  1. 0/9 meson: a couple of additionsPatrick Steinhardt, Jan 13, 2025
  2. 1/9 GIT-VERSION-GEN: simplify computing the dirty markerPatrick Steinhardt, Jan 13, 2025
  3. 2/9 GIT-VERSION-GEN: move default version into a separate filePatrick Steinhardt, Jan 13, 2025
  4. Junio C HamanoJan 13, 2025
  5. Eli SchwartzJan 13, 2025
  6. Patrick SteinhardtJan 14, 2025
  7. 3/9 meson: fix dependencies for generated headersPatrick Steinhardt, Jan 13, 2025
  8. 4/9 meson: wire up development environmentsPatrick Steinhardt, Jan 13, 2025
  9. 6/9 meson: wire up fuzzersPatrick Steinhardt, Jan 13, 2025
  10. Junio C HamanoJan 13, 2025
  11. Patrick SteinhardtJan 14, 2025
  12. 5/9 meson: wire up generation of distribution archivePatrick Steinhardt, Jan 13, 2025
  13. Junio C HamanoJan 13, 2025
  14. Patrick SteinhardtJan 14, 2025
  15. 7/9 meson: make the CSPRNG backend configurablePatrick Steinhardt, Jan 13, 2025
  16. Patrick SteinhardtJan 13, 2025
  17. Junio C HamanoJan 13, 2025
  18. Patrick SteinhardtJan 14, 2025
  19. Junio C HamanoJan 14, 2025
  20. 8/9 meson: fix compilation with Visual StudioPatrick Steinhardt, Jan 13, 2025
  21. M HickfordJan 13, 2025
  22. 9/9 ci: wire up Visual Studio build with MesonPatrick Steinhardt, Jan 13, 2025
  23. 00/11 meson: a couple of additionsPatrick Steinhardt, Jan 22, 2025
  24. 01/11 GIT-VERSION-GEN: simplify computing the dirty markerPatrick Steinhardt, Jan 22, 2025
  25. 02/11 GIT-VERSION-GEN: allow running without input and output filesPatrick Steinhardt, Jan 22, 2025
  26. 03/11 meson: populate project version via GIT-VERSION-GENPatrick Steinhardt, Jan 22, 2025
  27. 04/11 meson: fix dependencies for generated headersPatrick Steinhardt, Jan 22, 2025
  28. 05/11 meson: wire up development environmentsPatrick Steinhardt, Jan 22, 2025
  29. 06/11 meson: wire up generation of distribution archivePatrick Steinhardt, Jan 22, 2025
  30. 07/11 meson: wire up fuzzersPatrick Steinhardt, Jan 22, 2025
  31. 08/11 meson: make the CSPRNG backend configurablePatrick Steinhardt, Jan 22, 2025
  32. 09/11 meson: fix compilation with Visual StudioPatrick Steinhardt, Jan 22, 2025
  33. 10/11 ci: raise error when Meson generates warningsPatrick Steinhardt, Jan 22, 2025
  34. 11/11 ci: wire up Visual Studio build with MesonPatrick Steinhardt, Jan 22, 2025
  35. Junio C HamanoJan 22, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.