Skip to content

Commit 8a23be3

Browse files
pillo79facchinm
authored andcommitted
cmake: yaml: (cosmetic) avoid referring to file type in variable names
To move away from the JSON/YAML terminology, rename the variables that refer to the intermediate files to "expanded" and "output" files. Also, clean up a few "C-style" function calls and a typo in a variable name in the same files. No functional change introduced in this commit. Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
1 parent 60dafe5 commit 8a23be3

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

cmake/modules/yaml.cmake

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@ function(internal_yaml_list_append var genex key)
129129
endif()
130130
list(POP_FRONT ARG_YAML_LIST map_value)
131131
string(REGEX REPLACE "([^\\])," "\\1;" pair_list "${map_value}")
132-
set(qouted_map_value)
132+
set(quoted_map_value)
133133
foreach(pair ${pair_list})
134134
if(NOT pair MATCHES "[^ ]*:[^ ]*")
135135
message(FATAL_ERROR "yaml_set(MAP ${map_value} ) is malformed.\n"
136136
"Syntax is 'LIST MAP \"key1: value1.1, ...\" MAP \"key1: value1.2, ...\"\n"
137-
"If value contains comma ',' then ensure the value field is properly qouted "
137+
"If value contains comma ',' then ensure the value field is properly quoted "
138138
"and escaped"
139139
)
140140
endif()
@@ -145,10 +145,10 @@ function(internal_yaml_list_append var genex key)
145145
message(FATAL_ERROR "value: ${value} is not properly quoted")
146146
endif()
147147
string(REGEX REPLACE "\\\\," "," value "${value}")
148-
list(APPEND qouted_map_value "\"${map_key}\": \"${value}\"")
148+
list(APPEND quoted_map_value "\"${map_key}\": \"${value}\"")
149149
endforeach()
150-
list(JOIN qouted_map_value "," qouted_map_value)
151-
string(JSON json_content SET "${json_content}" ${key} ${i} "{${qouted_map_value}}")
150+
list(JOIN quoted_map_value "," quoted_map_value)
151+
string(JSON json_content SET "${json_content}" ${key} ${i} "{${quoted_map_value}}")
152152
endforeach()
153153
else()
154154
math(EXPR stop "${index} + ${length} - 1")
@@ -499,7 +499,7 @@ function(yaml_save)
499499
FILE(WRITE ${yaml_file} "${yaml_out}")
500500

501501
set(save_target ${ARG_YAML_NAME}_yaml_saved)
502-
if (NOT TARGET ${save_target})
502+
if(NOT TARGET ${save_target})
503503
# Create a target for the completion of the YAML save operation.
504504
# This will be a dummy unless genexes are used.
505505
add_custom_target(${save_target} ALL DEPENDS ${yaml_file})
@@ -509,16 +509,16 @@ function(yaml_save)
509509
)
510510
endif()
511511

512-
if (genex)
512+
if(genex)
513513
get_property(genex_save_count TARGET ${save_target} PROPERTY genex_save_count)
514-
if (${genex_save_count} EQUAL 0)
514+
if(${genex_save_count} EQUAL 0)
515515
# First yaml_save() for this context with genexes enabled
516516
add_custom_command(
517517
OUTPUT ${yaml_file}
518-
DEPENDS $<TARGET_PROPERTY:${save_target},json_file>
518+
DEPENDS $<TARGET_PROPERTY:${save_target},expanded_file>
519519
COMMAND ${CMAKE_COMMAND}
520-
-DJSON_FILE="$<TARGET_PROPERTY:${save_target},json_file>"
521-
-DYAML_FILE="${yaml_file}"
520+
-DEXPANDED_FILE="$<TARGET_PROPERTY:${save_target},expanded_file>"
521+
-DOUTPUT_FILE="${yaml_file}"
522522
-DTEMP_FILES="$<TARGET_PROPERTY:${save_target},temp_files>"
523523
-P ${ZEPHYR_BASE}/cmake/yaml-filter.cmake
524524
)
@@ -529,13 +529,13 @@ function(yaml_save)
529529

530530
cmake_path(SET yaml_path "${yaml_file}")
531531
cmake_path(GET yaml_path STEM yaml_file_no_ext)
532-
set(json_file ${yaml_file_no_ext}_${genex_save_count}.json)
533-
set_property(TARGET ${save_target} PROPERTY json_file ${json_file})
532+
set(expanded_file ${yaml_file_no_ext}_${genex_save_count}.json)
533+
set_property(TARGET ${save_target} PROPERTY expanded_file ${expanded_file})
534534

535-
# comment this to keep the temporary JSON files
536-
set_property(TARGET ${save_target} APPEND PROPERTY temp_files ${json_file})
535+
# comment this to keep the temporary files
536+
set_property(TARGET ${save_target} APPEND PROPERTY temp_files ${expanded_file})
537537

538-
FILE(GENERATE OUTPUT ${json_file}
538+
FILE(GENERATE OUTPUT ${expanded_file}
539539
CONTENT "${json_content}"
540540
)
541541
endif()
@@ -595,7 +595,7 @@ function(to_yaml in_json level yaml genex)
595595
# - with unexpanded generator expressions: save as YAML comment
596596
# - if it matches the special prefix: convert to YAML list
597597
# - otherwise: save as YAML scalar
598-
if (subjson MATCHES "\\$<.*>" AND ${genex})
598+
if(subjson MATCHES "\\$<.*>" AND ${genex})
599599
# Yet unexpanded generator expression: save as comment
600600
string(SUBSTRING ${indent_${level}} 1 -1 short_indent)
601601
set(${yaml} "${${yaml}}#${short_indent}${member}: ${subjson}\n")

cmake/yaml-filter.cmake

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
# YAML needs to happen after cmake has completed processing.
77
#
88
# This scripts expects as input:
9-
# - JSON_FILE: the name of the input file, in JSON format, that contains
9+
# - EXPANDED_FILE: the name of the input file, in JSON format, that contains
1010
# the expanded generator expressions.
11-
# - YAML_FILE: the name of the final output YAML file.
11+
# - OUTPUT_FILE: the name of the final output YAML file.
1212
# - TEMP_FILES: a list of temporary files that need to be removed after
1313
# the conversion is done.
1414
#
@@ -23,13 +23,13 @@ set(ZEPHYR_BASE ${CMAKE_CURRENT_LIST_DIR}/../)
2323
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/modules")
2424
include(yaml)
2525

26-
file(READ ${JSON_FILE} json_content)
26+
file(READ ${EXPANDED_FILE} json_content)
2727
to_yaml("${json_content}" 0 yaml_out TRUE)
28-
file(WRITE ${YAML_FILE} "${yaml_out}")
28+
file(WRITE ${OUTPUT_FILE} "${yaml_out}")
2929

30-
# Remove unused temporary files. JSON_FILE needs to be kept, or the
30+
# Remove unused temporary files. EXPANDED_FILE needs to be kept, or the
3131
# build system will complain there is no rule to rebuild it
32-
list(REMOVE_ITEM TEMP_FILES ${JSON_FILE})
32+
list(REMOVE_ITEM TEMP_FILES ${EXPANDED_FILE})
3333
foreach(file ${TEMP_FILES})
3434
file(REMOVE ${file})
3535
endforeach()

0 commit comments

Comments
 (0)