var_options
This field contains a map that controls how variables are flattened into strings during the build process.
Each map key is a variable name. The value is a set of formatting options that are applied when the variable’s list of values is joined into a single string.
options
| Option | Type | Default | Description |
|---|---|---|---|
from | string | - | Read values from another variable instead of this one |
joiner | string | " " | String used to join list elements |
prefix | string | - | String prepended before each element |
suffix | string | - | String appended after each element |
start | string | - | String prepended once before the entire result |
end | string | - | String appended once after the entire result |
Using from creates a new variable from another variable’s values. A variable
cannot have both its own values and a from option.
Examples
Adding a prefix to each element:
builders:
- name: my_builder
var_options:
notify:
prefix: -DMODULE_
env:
notify:
- apple
- banana
This flattens notify to -DMODULE_apple -DMODULE_banana.
Using a custom joiner and wrapping the result:
contexts:
- name: default
var_options:
includes:
joiner: ","
prefix: "-I"
start: "("
end: ")"
env:
includes:
- src
- lib
This flattens includes to (-Isrc,-Ilib).
Creating a new variable from an existing one:
contexts:
- name: default
var_options:
module_defines:
from: modules_used
prefix: -DMODULE_
This creates module_defines by reading the values of modules_used and
prefixing each element with -DMODULE_.