From 1298b5f0e1b3e010657ffba41d2e775fab028e08 Mon Sep 17 00:00:00 2001 From: Ryszard Knop Date: Tue, 23 Aug 2022 14:41:57 +0200 Subject: igt: Allow overriding the commit hash in the version string 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 Reviewed-by: Petri Latvala --- 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 98c2803b9..6910c061e 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 bed63efa8..d978813b4 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)') -- cgit v1.2.3