Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

OptionTypeDefaultDescription
fromstring-Read values from another variable instead of this one
joinerstring" "String used to join list elements
prefixstring-String prepended before each element
suffixstring-String appended after each element
startstring-String prepended once before the entire result
endstring-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_.