vcs_tag: handle non-str / non-file arguments

This makes vcs_tag behave like other commands so it accepts not only
string and file arguments, but also exe, custom_tgt, and
external_program.
pull/10281/head
Kirill Isakov 3 years ago committed by Eli Schwartz
parent 33aa803521
commit 39dd1ff9e8
  1. 4
      docs/yaml/functions/vcs_tag.yaml
  2. 13
      mesonbuild/interpreter/interpreter.py
  3. 16
      test cases/common/66 vcstag/meson.build

@ -22,7 +22,7 @@ description: |
kwargs:
command:
type: list[str | file]
type: list[exe | external_program | custom_tgt | file | str]
description: |
The command to execute, see [[custom_target]] for details
on how this command must be specified.
@ -32,6 +32,8 @@ kwargs:
*(since 0.62.0)* [[@file]] is accepted.
*(since 0.63.0)* [[@custom_tgt]], [[@exe]], and [[@external_program]] are accepted.
input:
type: str
required: true

@ -1752,11 +1752,14 @@ 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:
if isinstance(vcs_cmd[0], mesonlib.File):
FeatureNew.single_use('vcs_tag with file as the first argument', '0.62.0', self.subproject, location=node)
maincmd = self.find_program_impl(vcs_cmd[0], required=False)
if maincmd.found():
vcs_cmd[0] = maincmd
if isinstance(vcs_cmd[0], (str, mesonlib.File)):
if isinstance(vcs_cmd[0], mesonlib.File):
FeatureNew.single_use('vcs_tag with file as the first argument', '0.62.0', self.subproject, location=node)
maincmd = self.find_program_impl(vcs_cmd[0], required=False)
if maincmd.found():
vcs_cmd[0] = maincmd
else:
FeatureNew.single_use('vcs_tag with custom_tgt, external_program, or exe as the first argument', '0.63.0', self.subproject, location=node)
else:
vcs = mesonlib.detect_vcs(source_dir)
if vcs:

@ -17,12 +17,26 @@ fallback : '1.0.0')
version_src_fallback = vcs_tag(input : 'vcstag.c.in',
output : 'vcstag-fallback.c')
git = find_program('git')
version_src_git_program = vcs_tag(input : 'vcstag.c.in',
output : 'vcstag-git-program.c',
command : [git, 'rev-parse', 'HEAD'],
fallback : '1.0.0')
version_src_file = vcs_tag(input : 'vcstag.c.in',
output : 'vcstag-file.c',
command : files('version.py'))
executable('tagprog', 'tagprog.c', version_src)
tagprog = executable('tagprog', 'tagprog.c', version_src)
version_src_executable = vcs_tag(input : 'vcstag.c.in',
output : 'vcstag-executable.c',
command : [tagprog])
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)
executable('tagprog-git-program', 'tagprog.c', version_src_git_program)
executable('tagprog-executable', 'tagprog.c', version_src_executable)
executable('tagprog-file', 'tagprog.c', version_src_file)

Loading…
Cancel
Save