xen-troops / moulin

Moulin is meta build system that is capable of building multiple images at once
Apache License 2.0
2 stars 15 forks source link

Zephyr builder: Add escaping for the 'vars' parameter #89

Closed Mishytca closed 11 months ago

Mishytca commented 11 months ago

Fix the issue with passing the "vars" parameters from the configuration moulin YAML file to the build.ninja context.

The 'vars' parameter of the Zephyr builder is placed into the bash -c "... cmd ..." context. It requires an additional level of escaping to be added to the 'vars' parameter.

But that is not enough. The 'vars' parameter is passed to the 'west build' call. West, in turn, passes those 'vars' parameter to CMake.

On the CMake level, Zephyr splits all incoming CMake parameters into 2 parts:

  1. Those, which start with the "CONFIG_" prefix
  2. All the others

The first group of parameters is stored in the KConfig file. When users pass a string to Kconfig through CMake, they are expected to pass it so that quotes are correct seen from Kconfig, that is:

cmake -DCONFIG_A_STRING=\"foo bar\"

In this case, to obtain the required level of escaping:

As a result of this patch, the user can specify the 'vars' on the yaml level in the following way:

    vars:
      - "CONFIG_KERNEL_BIN_NAME=\"%{KERNEL_BIN_NAME}\""
      - "MY_VARIABLE=\"1234567890\""