Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vcs_tag: Add install kwargs #13871

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/markdown/snippets/vcs_tag.md
Original file line number Diff line number Diff line change
@@ -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.
31 changes: 31 additions & 0 deletions docs/yaml/functions/vcs_tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,34 @@ kwargs:
type: str
default: "'@VCS_TAG@'"
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.
15 changes: 15 additions & 0 deletions mesonbuild/interpreter/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1954,6 +1954,10 @@ def func_build_target(self, node: mparser.BaseNode,
),
KwargInfo('fallback', (str, NoneType)),
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:
if kwargs['fallback'] is None:
Expand Down Expand Up @@ -1994,6 +1998,13 @@ def func_vcs_tag(self, node: mparser.BaseNode, args: T.List['TYPE_var'], kwargs:
replace_string,
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(
kwargs['output'][0],
self.subdir,
Expand All @@ -2004,6 +2015,10 @@ def func_vcs_tag(self, node: mparser.BaseNode, args: T.List['TYPE_var'], kwargs:
kwargs['output'],
build_by_default=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)
return tg
Expand Down
4 changes: 3 additions & 1 deletion test cases/common/66 vcstag/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ tagprog = executable('tagprog', 'tagprog.c', version_src)

version_src_executable = vcs_tag(input : 'vcstag.c.in',
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-fallback', 'tagprog.c', version_src_fallback)
Expand Down
8 changes: 8 additions & 0 deletions test cases/common/66 vcstag/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"installed": [
{
"type": "file",
"file": "usr/include/vcstag-executable.c"
}
]
}
Loading