cmake: yaml: add support for generator expressions
This commit adds support for generator expressions in values and lists
to the yaml module.
Generator expressions can only be expanded by CMake after all
configuration code has been executed and the final values of the project
properties are defined. This means that contexts that contain generator
expressions are written twice:
- immediately, during the 'yaml_save()' call, a comment with the raw
unexpanded string is saved instead of the key that uses generator
expressions in the YAML file;
- after the configuration step, a custom command updates the YAML file
contents with the fully expanded values.
This two-step process also allows to overcome the issue of lists that
are extracted from generator expressions, whose elements would be
expanded into a single string if written directly to the YAML file.
Instead, the lists are stored in their CMake string format with a
special marker, expanded by CMake into a temporary JSON file, and the
conversion to a proper list is performed during the build step.
If the saved YAML file for context <name> is needed by further build
steps in this project, the target '<name>_yaml_saved' must be added as a
dependency to ensure the final contents are ready.
Note that when generator expressions are used in the context, the GENEX
keyword must be provided to yaml_set(). This is necessary to avoid
storing the genexes as raw strings in the YAML.
Signed-off-by:
Luca Burelli <l.burelli@arduino.cc>
Loading
Please sign in to comment