vcs_tag: Add install kwargs

Fixes: #4893
pull/13837/head
Xavier Claessens 3 weeks ago committed by Jussi Pakkanen
parent 41dbfd93e4
commit bfce1450ac
  1. 4
      docs/markdown/snippets/vcs_tag.md
  2. 31
      docs/yaml/functions/vcs_tag.yaml
  3. 15
      mesonbuild/interpreter/interpreter.py
  4. 4
      test cases/common/66 vcstag/meson.build
  5. 8
      test cases/common/66 vcstag/test.json

@ -0,0 +1,4 @@
## Install vcs_tag() output
[[vcs_tag]] now has `install`, `install_dir`, `install_tag` and `install_mode`
keyword arguments to install the generated file.

@ -55,3 +55,34 @@ kwargs:
type: str type: str
default: "'@VCS_TAG@'" default: "'@VCS_TAG@'"
description: String in the input file to substitute with the commit information. description: String in the input file to substitute with the commit information.
install:
type: bool
default: false
since: 1.7.0
description: |
When true, this generated file is installed during
the install step, and `install_dir` must be set and not empty.
install_dir:
type: str
since: 1.7.0
description: |
The subdirectory to install the generated file to (e.g. `share/myproject`).
install_mode:
type: list[str | int]
since: 1.7.0
description: |
Specify the file mode in symbolic format
and optionally the owner/uid and group/gid for the installed files.
See the `install_mode` kwarg of [[install_data]] for more information.
install_tag:
type: str
since: 1.7.0
description: |
A string used by the `meson install --tags` command
to install only a subset of the files. By default the file has no install
tag which means it is not being installed when `--tags` argument is specified.

@ -1954,6 +1954,10 @@ class Interpreter(InterpreterBase, HoldableObject):
), ),
KwargInfo('fallback', (str, NoneType)), KwargInfo('fallback', (str, NoneType)),
KwargInfo('replace_string', str, default='@VCS_TAG@'), KwargInfo('replace_string', str, default='@VCS_TAG@'),
INSTALL_KW.evolve(since='1.7.0'),
INSTALL_DIR_KW.evolve(since='1.7.0'),
INSTALL_TAG_KW.evolve(since='1.7.0'),
INSTALL_MODE_KW.evolve(since='1.7.0'),
) )
def func_vcs_tag(self, node: mparser.BaseNode, args: T.List['TYPE_var'], kwargs: 'kwtypes.VcsTag') -> build.CustomTarget: def func_vcs_tag(self, node: mparser.BaseNode, args: T.List['TYPE_var'], kwargs: 'kwtypes.VcsTag') -> build.CustomTarget:
if kwargs['fallback'] is None: if kwargs['fallback'] is None:
@ -1994,6 +1998,13 @@ class Interpreter(InterpreterBase, HoldableObject):
replace_string, replace_string,
regex_selector] + vcs_cmd regex_selector] + vcs_cmd
install = kwargs['install']
install_mode = self._warn_kwarg_install_mode_sticky(kwargs['install_mode'])
install_dir = [] if kwargs['install_dir'] is None else [kwargs['install_dir']]
install_tag = [] if kwargs['install_tag'] is None else [kwargs['install_tag']]
if install and not install_dir:
raise InvalidArguments('vcs_tag: "install_dir" keyword argument must be set when "install" is true.')
tg = build.CustomTarget( tg = build.CustomTarget(
kwargs['output'][0], kwargs['output'][0],
self.subdir, self.subdir,
@ -2004,6 +2015,10 @@ class Interpreter(InterpreterBase, HoldableObject):
kwargs['output'], kwargs['output'],
build_by_default=True, build_by_default=True,
build_always_stale=True, build_always_stale=True,
install=install,
install_dir=install_dir,
install_mode=install_mode,
install_tag=install_tag,
) )
self.add_target(tg.name, tg) self.add_target(tg.name, tg)
return tg return tg

@ -32,7 +32,9 @@ tagprog = executable('tagprog', 'tagprog.c', version_src)
version_src_executable = vcs_tag(input : 'vcstag.c.in', version_src_executable = vcs_tag(input : 'vcstag.c.in',
output : 'vcstag-executable.c', output : 'vcstag-executable.c',
command : [tagprog]) command : [tagprog],
install: true,
install_dir: get_option('includedir'))
executable('tagprog-custom', 'tagprog.c', version_src_custom) executable('tagprog-custom', 'tagprog.c', version_src_custom)
executable('tagprog-fallback', 'tagprog.c', version_src_fallback) executable('tagprog-fallback', 'tagprog.c', version_src_fallback)

@ -0,0 +1,8 @@
{
"installed": [
{
"type": "file",
"file": "usr/include/vcstag-executable.c"
}
]
}
Loading…
Cancel
Save