zephyr/cmake
Luca Burelli a90870da4c cmake: yaml: improve escaping of strings with backslashes and quotes
Switching the intermediate file format from JSON to YAML has a very
significant benefit: the file is now loaded via yaml_load(), which
internally calls Python to parse the file into the JSON format that
CMake expects. This means that the file contents are now automatically
escaped properly for JSON; it is a huge improvement over the previous
implementation, which was escaping everything given as input to
to_yaml().

With the removal of the now-redundant call in to_yaml(), escaping is
applied exactly once per value or list, when it is passed to yaml_set().
This allows to convert the logic in zephyr_string(ESCAPE ...) to a more
robust "escape everything" approach.

These changes fix the handling of strings with backslashes and different
types of quotes passed either directly or via generator expression. The
existing tests are updated to cover these cases.

Two other small changes are made in this commit:

- a small check in internal_yaml_list_append() is removed, as the same
  issue is already detected by the caller yaml_set() logic.

- the to_yaml() function is modified to initialize the YAML output
  variable at the top level, which is the expected behavior. This
  resulted in genex temp files sometimes having duplicate lines.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-04-10 10:11:47 +02:00
..
app
bintools toolchain: iar: Add experimental IAR support 2025-02-14 19:12:44 +00:00
compiler cmake clang/compiler_flags.cmake: Re-enable Wunused-function for clang 2025-04-08 10:50:08 +02:00
emu cmake: emu: armfvp: Only add the -a argument if not already present 2025-03-31 11:30:55 +02:00
flash cmake: flash: update cmake to support rtt target 2024-11-21 11:01:55 +00:00
ide
linker cmake: linker generator: ld: Files for section input patterns 2025-03-27 17:17:03 +01:00
linker_script cmake: linker_script: keep .symbol_to_keep 2025-03-31 14:31:57 +02:00
makefile_exports
modules cmake: yaml: improve escaping of strings with backslashes and quotes 2025-04-10 10:11:47 +02:00
reports cmake: reports: Fix file prefix for tfm/bl2 2025-02-24 15:36:45 +00:00
sca sca: gcc: add support for additional analyzer options 2025-03-13 16:53:26 +00:00
toolchain iar: toolchain: Enable TOOLCHAIN_HAS_BUILTIN_FFS 2025-04-01 11:51:41 +02:00
usage cmake: targets: usage: add missing custom targets 2024-08-31 06:46:44 -04:00
util
cfb.cmake
extra_flags.cmake
gcc-m-cpu.cmake arch: arm: Add Cortex-A7 support 2025-04-04 09:35:03 +02:00
gcc-m-fpu.cmake arch: arm: Add Cortex-A7 support 2025-04-04 09:35:03 +02:00
gen_version_h.cmake cmake: Create git module 2024-09-12 10:04:05 +02:00
kobj.cmake
llext-edk.cmake llext-edk: fix BOARD_TARGET variable generation to be Zephyr-compatible 2025-04-02 19:02:45 +02:00
mcuboot.cmake mcuboot: Kconfig options for single app slot RAM loading mode 2025-04-08 16:12:33 +02:00
package_helper.cmake cmake: move script mode handling from package helper to extensions.cmake 2024-10-08 17:00:30 +02:00
pristine.cmake
target_toolchain_flags.cmake cmake: source dedicated linker library properties for native builds 2024-11-16 15:28:20 -05:00
verify-toolchain.cmake
vif.cmake
yaml-filter.cmake cmake: yaml: switch to yaml for intermediate file 2025-04-10 10:11:47 +02:00