diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-12-20 20:44:26 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-12-20 21:36:46 +0100 |
commit | 1bc815c3d0eff054c7a032130206d16839bb331a (patch) | |
tree | 46d7918e7dafb7e35de7893c730729b1c021e0be /meson.build | |
parent | GIT-VERSION-GEN: fix overriding GIT_BUILT_FROM_COMMIT and GIT_DATE (diff) | |
download | git-1bc815c3d0eff054c7a032130206d16839bb331a.tar.xz git-1bc815c3d0eff054c7a032130206d16839bb331a.zip |
meson: add options to override build information
We inject various different kinds of build information into build
artifacts, like the version string or the commit from which Git was
built. Add options to let users explicitly override this information
with Meson.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/meson.build b/meson.build index 0dccebcdf1..be32d60e84 100644 --- a/meson.build +++ b/meson.build @@ -201,6 +201,16 @@ if get_option('sane_tool_path') != '' script_environment.prepend('PATH', get_option('sane_tool_path')) endif +# The environment used by GIT-VERSION-GEN. Note that we explicitly override +# environment variables that might be set by the user. This is by design so +# that we always use whatever Meson has configured instead of what is present +# in the environment. +version_gen_environment = script_environment +version_gen_environment.set('GIT_BUILT_FROM_COMMIT', get_option('built_from_commit')) +version_gen_environment.set('GIT_DATE', get_option('build_date')) +version_gen_environment.set('GIT_USER_AGENT', get_option('user_agent')) +version_gen_environment.set('GIT_VERSION', get_option('version')) + compiler = meson.get_compiler('c') libgit_sources = [ @@ -1485,6 +1495,7 @@ git_version_file = custom_target( ], input: meson.current_source_dir() / 'GIT-VERSION-FILE.in', output: 'GIT-VERSION-FILE', + env: version_gen_environment, build_always_stale: true, ) @@ -1501,6 +1512,7 @@ version_def_h = custom_target( # Depend on GIT-VERSION-FILE so that we don't always try to rebuild this # target for the same commit. depends: [git_version_file], + env: version_gen_environment, ) # Build a separate library for "version.c" so that we do not have to rebuild @@ -1544,6 +1556,7 @@ if host_machine.system() == 'windows' input: meson.current_source_dir() / 'git.rc.in', output: 'git.rc', depends: [git_version_file], + env: version_gen_environment, ) common_main_sources += import('windows').compile_resources(git_rc, |