fix regression in vcs_tag when the VCS program is not installed

We are supposed to fallback on the fallback when running the vcstagger,
but instead we errored out during configure.

Fixes regression in commit b402817fb6.
Before this, we used shutil.which || relative paths, and in the latter
case if it could not be found we still wrote out that path but it failed
to run in vcstagger. Now, we use find_program under the hood, so it
needs to be run in non-fatal mode, and if it is not found, we simply
keep the original command string. It's a VCS command, so if we magically
end up finding it at runtime because it was installed after running
configure, that is *fine*.
pull/10117/head
Eli Schwartz 3 years ago committed by Jussi Pakkanen
parent 44104e820a
commit 5cb9f2b066
  1. 4
      mesonbuild/interpreter/interpreter.py
  2. 6
      test cases/common/66 vcstag/meson.build

@ -1728,7 +1728,9 @@ external dependencies (including libraries) must go to "dependencies".''')
vcs_cmd = kwargs['command']
source_dir = os.path.normpath(os.path.join(self.environment.get_source_dir(), self.subdir))
if vcs_cmd:
vcs_cmd[0] = self.find_program_impl(vcs_cmd[0])
maincmd = self.find_program_impl(vcs_cmd[0], required=False)
if maincmd.found():
vcs_cmd[0] = maincmd
else:
vcs = mesonlib.detect_vcs(source_dir)
if vcs:

@ -9,9 +9,15 @@ output : 'vcstag-custom.c',
command : ['git', 'show-ref', '-s', 'refs/heads/master'],
fallback : '1.0.0')
version_src_notfound_fallback = vcs_tag(input : 'vcstag.c.in',
output : 'vcstag-notfound-fallback.c',
command : ['git-but-not-found-sorry', 'show-ref', '-s', 'refs/heads/master'],
fallback : '1.0.0')
version_src_fallback = vcs_tag(input : 'vcstag.c.in',
output : 'vcstag-fallback.c')
executable('tagprog', 'tagprog.c', version_src)
executable('tagprog-custom', 'tagprog.c', version_src_custom)
executable('tagprog-fallback', 'tagprog.c', version_src_fallback)
executable('tagprog-notfound-fallback', 'tagprog.c', version_src_notfound_fallback)

Loading…
Cancel
Save