zephyr/cmake/modules
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
..
arch.cmake infrastructure: Remove hwmv1 support 2025-03-13 16:53:07 +00:00
basic_settings.cmake
boards.cmake infrastructure: Remove hwmv1 support 2025-03-13 16:53:07 +00:00
ccache.cmake
configuration_files.cmake cmake: Remove build type 2025-01-30 16:19:57 +01:00
doc.cmake
dts.cmake cmake: modules: dts: print error message if DTC fails 2025-03-24 19:33:18 +01:00
extensions.cmake cmake: yaml: improve escaping of strings with backslashes and quotes 2025-04-10 10:11:47 +02:00
Findarmclang.cmake
FindBabbleSim.cmake
FindDeprecated.cmake cmake: Remove previously deprecated look-ups 2025-03-24 07:53:31 +01:00
FindDtc.cmake
FindGnuLd.cmake cmake: modules/FindGnuLd: support an additional obselete version format 2025-01-27 13:24:52 +01:00
FindHostTools.cmake cmake: Remove previously deprecated look-ups 2025-03-24 07:53:31 +01:00
FindLlvmLld.cmake
FindoneApi.cmake
FindScaTools.cmake
FindTargetTools.cmake cmake: improve Zephyr link phase 2024-10-04 16:34:35 +01:00
FindThreads.cmake
FindZephyr-sdk.cmake cmake: support range for find_package(Zephyr-sdk) 2024-10-24 14:06:45 +02:00
generated_file_directories.cmake
git.cmake cmake: Create git module 2024-09-12 10:04:05 +02:00
hwm_v2.cmake cmake: scripts: support SoC extension 2024-10-26 17:14:06 +02:00
kconfig.cmake infrastructure: Remove hwmv1 support 2025-03-13 16:53:07 +00:00
kernel.cmake cmake: modules: Refer to log file based on CMake version 2025-03-14 01:01:43 +01:00
pre_dt.cmake infrastructure: Remove hwmv1 support 2025-03-13 16:53:07 +00:00
python.cmake cmake: Remove previously deprecated look-ups 2025-03-24 07:53:31 +01:00
root.cmake sysbuild: Add support for snippets 2024-12-27 07:18:13 +01:00
shields.cmake
snippets.cmake cmake: snippets: Add snippet help message 2025-02-13 16:43:20 +01:00
soc.cmake infrastructure: Remove hwmv1 support 2025-03-13 16:53:07 +00:00
unittest.cmake cmake: Remove previously deprecated look-ups 2025-03-24 07:53:31 +01:00
user_cache.cmake
version.cmake cmake: Added "-" support to EXTRAVERSION 2025-01-21 15:13:36 +01:00
west.cmake
yaml.cmake cmake: yaml: improve escaping of strings with backslashes and quotes 2025-04-10 10:11:47 +02:00
zephyr_default.cmake infrastructure: Remove hwmv1 support 2025-03-13 16:53:07 +00:00
zephyr_module.cmake cmake: fix Zephyr module ext order 2025-04-03 13:16:56 +02:00