[igt-dev] [PATCH i-g-t] igt: Allow overriding the commit hash in the version string

Ryszard Knop ryszard.knop at intel.com
Tue Aug 23 12:41:57 UTC 2022


By default, the latest Git commit hash is always used to create the
version string embedded in libigt - if libigt changes, most targets are
marked as "dirty" and need to be relinked. This makes it difficult to
easily compare two IGT builds on binaries alone.

This commit introduces a new Meson option, -Dversion_hash="your text!",
which allows overriding this hash, for instance under CI builds.

Signed-off-by: Ryszard Knop <ryszard.knop at intel.com>
---
 lib/meson.build   | 8 +++++++-
 meson_options.txt | 4 ++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/meson.build b/lib/meson.build
index 98c2803b..6910c061 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -168,9 +168,15 @@ else
     srcdir = join_paths(meson.source_root(), 'tests')
 endif
 
+if get_option('version_hash') != ''
+    vcs_command = ['echo', get_option('version_hash')]
+else
+    vcs_command = [ 'git', 'log', '-n1', '--pretty=format:g%h' ]
+endif
+
 lib_version = vcs_tag(input : 'version.h.in', output : 'version.h',
 		      fallback : 'NO-GIT',
-		      command : [ 'git', 'log', '-n1', '--pretty=format:g%h' ] )
+		      command : vcs_command )
 
 lib_intermediates = []
 foreach f: lib_sources
diff --git a/meson_options.txt b/meson_options.txt
index bed63efa..d978813b 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -51,6 +51,10 @@ option('use_rpath',
        value : false,
        description : 'Set runpath on installed executables for libigt.so')
 
+option('version_hash',
+       type : 'string',
+       description : 'Override the Git commit hash embedded in the binaries')
+
 option('srcdir',
        type : 'string',
        description : 'Override the source code path embedded inside target binaries (optional)')
-- 
2.37.2



More information about the igt-dev mailing list