configure_file()
This function can run in three modes depending on the keyword arguments passed to it.
When a cfg_data object is passed
to the configuration: keyword argument, it takes a template file as
the input: (optional) and produces the output: (required) by
substituting values from the configuration data as detailed in the
configuration file documentation. (since 0.49.0)
A dictionary can be passed instead of a
cfg_data object.
When an array of strings is passed to the command: keyword argument,
it takes any source or configured file as the input: and assumes
that the output: is produced when the specified command is run.
You can install the outputted file with the install_dir: kwarg, see below.
(since 0.47.0) When the copy: keyword argument is set to true,
this function will copy the file provided in input: to a file in the
build directory with the name output: in the current directory.
Signature
# This function can run in three modes depending on the keyword arguments
file configure_file(
build_subdir : str # Places the build results in a subdirectory of the given name rather than directly into the build directory
capture : bool # When this argument is set to true,
command : array[str | file] # As explained above, if specified, Meson does not create
configuration : cfg_data | dict[str | int | bool] # As explained above, when passed this will provide the replacement
copy : bool # As explained above, if specified Meson only
depfile : str # A dependency file that the command can write listing
encoding : str # Set the file encoding for the input and output file
format : str # The format of defines
input : str | file # The input file name
install : bool # When true, this generated file is installed during
install_dir : str # The subdirectory to install the generated file to
install_mode : array[str | int] # Specify the file mode in symbolic format
install_tag : str # A string used by the `meson install --tags` command
macro_name : str # When specified, macro guards will be used instead of '#pragma once'
output : str # The output file name
output_format : str # The format of the output to generate when no input
)
Arguments
The function configure_file()
accepts the following keyword arguments:
| Name | Type | Description | Tags |
|---|---|---|---|
build_subdir |
str |
Places the build results in a subdirectory of the given name rather than directly into the build directory. This does not affect the install directory, which uses install_dir. This allows inserting a directory name into the build path, either when needed to use the build result while building other targets or as a way to support multiple targets with the same basename by using unique build_subdir values for each one. To prevent collisions within the build directory, build_subdir is not allowed to match a file or directory in the source directory, nor contain '..' to refer to the parent of the build directory. |
(since 1.10.0) |
capture |
bool |
When this argument is set to true,
Meson captures |
(since 0.41.0)
|
command |
array[str | file] |
As explained above, if specified, Meson does not create
the file itself but rather runs the specified command, which allows
you to do fully custom file generation. (since 0.52.0) The command can contain
file objects and more than one file can be passed to the |
|
configuration |
cfg_data | dict[str | int | bool] |
As explained above, when passed this will provide the replacement data for the input file (if provided) or key value pairs to be written to the output. |
|
copy |
bool |
As explained above, if specified Meson only copies the file from input to output. |
(since 0.47.0)
|
depfile |
str |
A dependency file that the command can write listing all the additional files this target depends on. A change in any one of these files triggers a reconfiguration. |
(since 0.52.0) |
encoding |
str |
Set the file encoding for the input and output file. The supported encodings are those of python3, see standard-encodings. |
(since 0.47.0)
|
format |
str |
The format of defines. It defaults to |
(since 0.46.0)
|
input |
str | file
|
The input file name. If it's not specified in configuration
mode, all the variables in the |
|
install |
bool |
When true, this generated file is installed during
the install step, and |
(since 0.50.0)
|
install_dir |
str |
The subdirectory to install the generated file to
(e.g. |
|
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 |
(since 0.47.0) |
install_tag |
str |
A string used by the |
(since 0.60.0) |
macro_name |
str |
When specified, macro guards will be used instead of '#pragma once'. The macro guard name will be the specified name. |
(since 1.3.0) |
output |
str |
The output file name. (since 0.41.0) may contain
|
|
output_format |
str |
The format of the output to generate when no input
was specified. It defaults to |
(since 0.47.0) |
The results of the search are