Generator object (generator)

This object is returned by generator() and contains a generator that is used to transform files from one type to another by an executable (e.g. idl files into source code and headers).

Returned by

Generator object objects are returned by the following functions and methods:

Generator object methods

generator.process()

Takes a list of files, causes them to be processed and returns an object containing the result which can then, for example, be passed into a build target definition.

Signature

# Takes a list of files, causes them to be processed and returns an object containing the result
generated_list process(
  str | file | custom_tgt | custom_idx | generated_list source...,  # List of sources to process

  # Keyword arguments:
  env                : env | list[str] | dict[str]  # environment variables to set, such as
  extra_args         : list[str]                    # If present, will be used to replace an entry `@EXTRA_ARGS@` in the argument list
  preserve_path_from : str                          # If given, specifies that the output files need to maintain their directory structure
)

Arguments

The method accepts between 1 and infinity variadic arguments (source...) of type str | file | custom_tgt | custom_idx | generated_list.

List of sources to process.

The method generator.process() accepts the following keyword arguments:

Name Type Description Tags
env env | list[str] | dict[str]

environment variables to set, such as {'NAME1': 'value1', 'NAME2': 'value2'} or ['NAME1=value1', 'NAME2=value2'], or an env object which allows more sophisticated environment juggling.

(since 1.3.0)

extra_args list[str]

If present, will be used to replace an entry @EXTRA_ARGS@ in the argument list.

preserve_path_from str

If given, specifies that the output files need to maintain their directory structure inside the target temporary directory. The most common value for this is meson.current_source_dir(). With this value when a file called subdir/one.input is processed it generates a file {target private directory}/subdir/one.out as opposed to {target private directory}/one.out.

(since 0.45.0)


The results of the search are