From 5cb9f2b066a8dc8a89a49186b359842664d33534 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Fri, 11 Mar 2022 15:01:15 -0500 Subject: 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 b402817fb6f0392812bfa272bdbc05c9c30139fa. 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*. --- mesonbuild/interpreter/interpreter.py | 4 +++- test cases/common/66 vcstag/meson.build | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index aac2b97bf..a44d02d91 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -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: diff --git a/test cases/common/66 vcstag/meson.build b/test cases/common/66 vcstag/meson.build index 256d2e951..520f72aa1 100644 --- a/test cases/common/66 vcstag/meson.build +++ b/test cases/common/66 vcstag/meson.build @@ -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) -- cgit v1.3