aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Isakov <bootctl@gmail.com>2022-04-20 11:28:21 +0600
committerEli Schwartz <eschwartz93@gmail.com>2022-04-20 20:53:19 -0400
commit39dd1ff9e83acfdc8c532604b20cb7b774727334 (patch)
tree6ba62dc2cbb2bc0ba98547b123c55352a93c8a0d
parent33aa803521b2aa62688833842ea7eddb828e0e25 (diff)
downloadmeson-39dd1ff9e83acfdc8c532604b20cb7b774727334.zip
meson-39dd1ff9e83acfdc8c532604b20cb7b774727334.tar.gz
meson-39dd1ff9e83acfdc8c532604b20cb7b774727334.tar.bz2
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.
-rw-r--r--docs/yaml/functions/vcs_tag.yaml4
-rw-r--r--mesonbuild/interpreter/interpreter.py13
-rw-r--r--test cases/common/66 vcstag/meson.build16
3 files changed, 26 insertions, 7 deletions
diff --git a/docs/yaml/functions/vcs_tag.yaml b/docs/yaml/functions/vcs_tag.yaml
index 29ef7ea..b4aad12 100644
--- a/docs/yaml/functions/vcs_tag.yaml
+++ b/docs/yaml/functions/vcs_tag.yaml
@@ -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
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index 0d5dd39..d5e7dbd 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -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:
diff --git a/test cases/common/66 vcstag/meson.build b/test cases/common/66 vcstag/meson.build
index 9eba4c6..38fa590 100644
--- a/test cases/common/66 vcstag/meson.build
+++ b/test cases/common/66 vcstag/meson.build
@@ -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)