Browse Source
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>pull/88410/head
3 changed files with 109 additions and 25 deletions
Loading…
Reference in new issue