vcs_tag()

This command detects revision control commit information at build time and places it in the specified output file. This file is guaranteed to be up to date on every build. Keywords are similar to custom_target().

Meson will read the contents of input, substitute the replace_string with the detected revision number, and write the result to output. This method returns a custom_tgt object that (as usual) should be used to signal dependencies if other targets use the file outputted by this.

For example, if you generate a header with this and want to use that in a build target, you must add the return value to the sources of that build target. Without that, Meson will not know the order in which to build the targets.

If you desire more specific behavior than what this command provides, you should use custom_target().

Signature

# This command detects revision control commit information at build time
custom_tgt vcs_tag(
  command        : array[exe | external_program | custom_tgt | file | str]              # The command to execute, see custom_target() for details
  fallback       : str                                                                  # Version number to use when no revision control information is present,
  input          : str                                                      [required]  # File to modify (e
  install        : bool                                                                 # When true, this generated file is installed during
  install_dir    : str                                                                  # The subdirectory to install the generated file to (e
  install_mode   : array[str | int]                                                     # Specify the file mode in symbolic format
  install_tag    : str                                                                  # A string used by the `meson install --tags` command
  output         : str                                                      [required]  # File to write the results to (e
  replace_string : str                                                                  # String in the input file to substitute with the commit information
)

Arguments

The function vcs_tag() accepts the following keyword arguments:

Name Type Description Tags
command array[exe | external_program | custom_tgt | file | str]

The command to execute, see custom_target() for details on how this command must be specified.

This parameter is optional. If it is absent, Meson will try its best to find a suitable default command.

(since 0.62.0) file is accepted.

(since 0.63.0) custom_tgt, exe, and external_program are accepted.

fallback str

Version number to use when no revision control information is present, such as when building from a release tarball.

input str

File to modify (e.g. version.c.in).

install bool

When true, this generated file is installed during the install step, and install_dir must be set and not empty.

(since 1.7.0)

default = false

install_dir str

The subdirectory to install the generated file to (e.g. share/myproject).

(since 1.7.0)

install_mode array[str | int]

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.

(since 1.7.0)

install_tag str

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.

(since 1.7.0)

output str

File to write the results to (e.g. version.c).

replace_string str

String in the input file to substitute with the commit information.

default = '@VCS_TAG@'

The results of the search are