diff options
author | Nicholas Vinson <nvinson234@gmail.com> | 2023-09-04 13:04:00 -0400 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2023-09-09 07:30:56 -0400 |
commit | b51bce070eead2b65e56f087acf23829a6304ae2 (patch) | |
tree | 57ce789fe3fce4ddb8fbd98d33d2cf1d697166f2 /mesonbuild/interpreter | |
parent | 3c47216fe945a45834daa38f71e287dcfaf345c7 (diff) | |
download | meson-b51bce070eead2b65e56f087acf23829a6304ae2.zip meson-b51bce070eead2b65e56f087acf23829a6304ae2.tar.gz meson-b51bce070eead2b65e56f087acf23829a6304ae2.tar.bz2 |
Add macro_name option to configure_file
Allow macro_name to be speficied as a parameter to configure_file().
This allows C macro-style include guards to be added to
configure_file()'s output when a template file is not given. This change
simplifies the creation of configure files that define macros with
dynamic names and want the C-style include guards.
Diffstat (limited to 'mesonbuild/interpreter')
-rw-r--r-- | mesonbuild/interpreter/interpreter.py | 4 | ||||
-rw-r--r-- | mesonbuild/interpreter/kwargs.py | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index d9a260c..9b005cb 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -2585,6 +2585,7 @@ class Interpreter(InterpreterBase, HoldableObject): OUTPUT_KW, KwargInfo('output_format', str, default='c', since='0.47.0', since_values={'json': '1.3.0'}, validator=in_set_validator({'c', 'json', 'nasm'})), + KwargInfo('macro_name', (str, NoneType), default=None, since='1.3.0'), ) def func_configure_file(self, node: mparser.BaseNode, args: T.List[TYPE_var], kwargs: kwtypes.ConfigureFile): @@ -2676,7 +2677,8 @@ class Interpreter(InterpreterBase, HoldableObject): 'copy a file to the build dir, use the \'copy:\' keyword ' 'argument added in 0.47.0', location=node) else: - mesonlib.dump_conf_header(ofile_abs, conf, output_format) + macro_name = kwargs['macro_name'] + mesonlib.dump_conf_header(ofile_abs, conf, output_format, macro_name) conf.used = True elif kwargs['command'] is not None: if len(inputs) > 1: diff --git a/mesonbuild/interpreter/kwargs.py b/mesonbuild/interpreter/kwargs.py index 0aee164..1aee414 100644 --- a/mesonbuild/interpreter/kwargs.py +++ b/mesonbuild/interpreter/kwargs.py @@ -296,6 +296,7 @@ class ConfigureFile(TypedDict): command: T.Optional[T.List[T.Union[build.Executable, ExternalProgram, Compiler, File, str]]] input: T.List[FileOrString] configuration: T.Optional[T.Union[T.Dict[str, T.Union[str, int, bool]], build.ConfigurationData]] + macro_name: T.Optional[str] class Subproject(ExtractRequired): |