cmake: extensions: Change zephyr_file() argument parser prefix
Replace `FILE` with `ZFILE` as the prefix for `cmake_parse_arguments()`. This is because `zephyr_file()` accepts `SUFFIX` as function argument, and it should not be accessible as `FILE_SUFFIX` as it would conflict with the CMake cache variable of the same name. Accessing the argument as `ZFILE_SUFFIX` prevents the cached value from slipping into the function scope. Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
This commit is contained in:
parent
438c95458f
commit
50f0454fbd
1 changed files with 48 additions and 48 deletions
|
@ -2535,75 +2535,75 @@ Please provide one of following: APPLICATION_ROOT, CONF_FILES")
|
||||||
set(multi_args CONF_FILES NAMES)
|
set(multi_args CONF_FILES NAMES)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
cmake_parse_arguments(FILE "${options}" "${single_args}" "${multi_args}" ${ARGN})
|
cmake_parse_arguments(ZFILE "${options}" "${single_args}" "${multi_args}" ${ARGN})
|
||||||
if(FILE_UNPARSED_ARGUMENTS)
|
if(ZFILE_UNPARSED_ARGUMENTS)
|
||||||
message(FATAL_ERROR "zephyr_file(${ARGV0} <val> ...) given unknown arguments: ${FILE_UNPARSED_ARGUMENTS}")
|
message(FATAL_ERROR "zephyr_file(${ARGV0} <val> ...) given unknown arguments: ${ZFILE_UNPARSED_ARGUMENTS}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FILE_APPLICATION_ROOT)
|
if(ZFILE_APPLICATION_ROOT)
|
||||||
# Note: user can do: `-D<var>=<relative-path>` and app can at same
|
# Note: user can do: `-D<var>=<relative-path>` and app can at same
|
||||||
# time specify `list(APPEND <var> <abs-path>)`
|
# time specify `list(APPEND <var> <abs-path>)`
|
||||||
# Thus need to check and update only CACHED variables (-D<var>).
|
# Thus need to check and update only CACHED variables (-D<var>).
|
||||||
set(CACHED_PATH $CACHE{${FILE_APPLICATION_ROOT}})
|
set(CACHED_PATH $CACHE{${ZFILE_APPLICATION_ROOT}})
|
||||||
foreach(path ${CACHED_PATH})
|
foreach(path ${CACHED_PATH})
|
||||||
# The cached variable is relative path, i.e. provided by `-D<var>` or
|
# The cached variable is relative path, i.e. provided by `-D<var>` or
|
||||||
# `set(<var> CACHE)`, so let's update current scope variable to absolute
|
# `set(<var> CACHE)`, so let's update current scope variable to absolute
|
||||||
# path from `APPLICATION_SOURCE_DIR`.
|
# path from `APPLICATION_SOURCE_DIR`.
|
||||||
if(NOT IS_ABSOLUTE ${path})
|
if(NOT IS_ABSOLUTE ${path})
|
||||||
set(abs_path ${APPLICATION_SOURCE_DIR}/${path})
|
set(abs_path ${APPLICATION_SOURCE_DIR}/${path})
|
||||||
list(FIND ${FILE_APPLICATION_ROOT} ${path} index)
|
list(FIND ${ZFILE_APPLICATION_ROOT} ${path} index)
|
||||||
if(NOT ${index} LESS 0)
|
if(NOT ${index} LESS 0)
|
||||||
list(REMOVE_AT ${FILE_APPLICATION_ROOT} ${index})
|
list(REMOVE_AT ${ZFILE_APPLICATION_ROOT} ${index})
|
||||||
list(INSERT ${FILE_APPLICATION_ROOT} ${index} ${abs_path})
|
list(INSERT ${ZFILE_APPLICATION_ROOT} ${index} ${abs_path})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Now all cached relative paths has been updated.
|
# Now all cached relative paths has been updated.
|
||||||
# Let's check if anyone uses relative path as scoped variable, and fail
|
# Let's check if anyone uses relative path as scoped variable, and fail
|
||||||
foreach(path ${${FILE_APPLICATION_ROOT}})
|
foreach(path ${${ZFILE_APPLICATION_ROOT}})
|
||||||
if(NOT IS_ABSOLUTE ${path})
|
if(NOT IS_ABSOLUTE ${path})
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"Relative path encountered in scoped variable: ${FILE_APPLICATION_ROOT}, value=${path}\n \
|
"Relative path encountered in scoped variable: ${ZFILE_APPLICATION_ROOT}, value=${path}\n \
|
||||||
Please adjust any `set(${FILE_APPLICATION_ROOT} ${path})` or `list(APPEND ${FILE_APPLICATION_ROOT} ${path})`\n \
|
Please adjust any `set(${ZFILE_APPLICATION_ROOT} ${path})` or `list(APPEND ${ZFILE_APPLICATION_ROOT} ${path})`\n \
|
||||||
to absolute path using `\${CMAKE_CURRENT_SOURCE_DIR}/${path}` or similar. \n \
|
to absolute path using `\${CMAKE_CURRENT_SOURCE_DIR}/${path}` or similar. \n \
|
||||||
Relative paths are only allowed with `-D${ARGV1}=<path>`")
|
Relative paths are only allowed with `-D${ARGV1}=<path>`")
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# This updates the provided argument in parent scope (callers scope)
|
# This updates the provided argument in parent scope (callers scope)
|
||||||
set(${FILE_APPLICATION_ROOT} ${${FILE_APPLICATION_ROOT}} PARENT_SCOPE)
|
set(${ZFILE_APPLICATION_ROOT} ${${ZFILE_APPLICATION_ROOT}} PARENT_SCOPE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FILE_CONF_FILES)
|
if(ZFILE_CONF_FILES)
|
||||||
if(DEFINED FILE_BOARD_REVISION AND NOT FILE_BOARD)
|
if(DEFINED ZFILE_BOARD_REVISION AND NOT ZFILE_BOARD)
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"zephyr_file(${ARGV0} <path> BOARD_REVISION ${FILE_BOARD_REVISION} ...)"
|
"zephyr_file(${ARGV0} <path> BOARD_REVISION ${ZFILE_BOARD_REVISION} ...)"
|
||||||
" given without BOARD argument, please specify BOARD"
|
" given without BOARD argument, please specify BOARD"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT DEFINED FILE_BOARD)
|
if(NOT DEFINED ZFILE_BOARD)
|
||||||
# Defaulting to system wide settings when BOARD is not given as argument
|
# Defaulting to system wide settings when BOARD is not given as argument
|
||||||
set(FILE_BOARD ${BOARD})
|
set(ZFILE_BOARD ${BOARD})
|
||||||
if(DEFINED BOARD_REVISION)
|
if(DEFINED BOARD_REVISION)
|
||||||
set(FILE_BOARD_REVISION ${BOARD_REVISION})
|
set(ZFILE_BOARD_REVISION ${BOARD_REVISION})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(DEFINED BOARD_QUALIFIERS)
|
if(DEFINED BOARD_QUALIFIERS)
|
||||||
set(FILE_BOARD_QUALIFIERS ${BOARD_QUALIFIERS})
|
set(ZFILE_BOARD_QUALIFIERS ${BOARD_QUALIFIERS})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FILE_NAMES)
|
if(ZFILE_NAMES)
|
||||||
set(dts_filename_list ${FILE_NAMES})
|
set(dts_filename_list ${ZFILE_NAMES})
|
||||||
set(kconf_filename_list ${FILE_NAMES})
|
set(kconf_filename_list ${ZFILE_NAMES})
|
||||||
else()
|
else()
|
||||||
zephyr_build_string(filename_list
|
zephyr_build_string(filename_list
|
||||||
BOARD ${FILE_BOARD}
|
BOARD ${ZFILE_BOARD}
|
||||||
BOARD_REVISION ${FILE_BOARD_REVISION}
|
BOARD_REVISION ${ZFILE_BOARD_REVISION}
|
||||||
BOARD_QUALIFIERS ${FILE_BOARD_QUALIFIERS}
|
BOARD_QUALIFIERS ${ZFILE_BOARD_QUALIFIERS}
|
||||||
BUILD ${FILE_BUILD}
|
BUILD ${ZFILE_BUILD}
|
||||||
MERGE REVERSE
|
MERGE REVERSE
|
||||||
)
|
)
|
||||||
list(REMOVE_DUPLICATES filename_list)
|
list(REMOVE_DUPLICATES filename_list)
|
||||||
|
@ -2614,24 +2614,24 @@ Relative paths are only allowed with `-D${ARGV1}=<path>`")
|
||||||
list(TRANSFORM kconf_filename_list APPEND ".conf")
|
list(TRANSFORM kconf_filename_list APPEND ".conf")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FILE_DTS)
|
if(ZFILE_DTS)
|
||||||
foreach(path ${FILE_CONF_FILES})
|
foreach(path ${ZFILE_CONF_FILES})
|
||||||
foreach(filename ${dts_filename_list})
|
foreach(filename ${dts_filename_list})
|
||||||
if(NOT IS_ABSOLUTE ${filename})
|
if(NOT IS_ABSOLUTE ${filename})
|
||||||
set(test_file ${path}/${filename})
|
set(test_file ${path}/${filename})
|
||||||
else()
|
else()
|
||||||
set(test_file ${filename})
|
set(test_file ${filename})
|
||||||
endif()
|
endif()
|
||||||
zephyr_file_suffix(test_file SUFFIX ${FILE_SUFFIX})
|
zephyr_file_suffix(test_file SUFFIX ${ZFILE_SUFFIX})
|
||||||
|
|
||||||
if(EXISTS ${test_file})
|
if(EXISTS ${test_file})
|
||||||
list(APPEND ${FILE_DTS} ${test_file})
|
list(APPEND ${ZFILE_DTS} ${test_file})
|
||||||
|
|
||||||
if(DEFINED FILE_BUILD)
|
if(DEFINED ZFILE_BUILD)
|
||||||
set(deprecated_file_found y)
|
set(deprecated_file_found y)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FILE_NAMES)
|
if(ZFILE_NAMES)
|
||||||
break()
|
break()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
@ -2639,31 +2639,31 @@ Relative paths are only allowed with `-D${ARGV1}=<path>`")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# This updates the provided list in parent scope (callers scope)
|
# This updates the provided list in parent scope (callers scope)
|
||||||
set(${FILE_DTS} ${${FILE_DTS}} PARENT_SCOPE)
|
set(${ZFILE_DTS} ${${ZFILE_DTS}} PARENT_SCOPE)
|
||||||
|
|
||||||
if(NOT ${FILE_DTS})
|
if(NOT ${ZFILE_DTS})
|
||||||
set(not_found ${dts_filename_list})
|
set(not_found ${dts_filename_list})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FILE_KCONF)
|
if(ZFILE_KCONF)
|
||||||
foreach(path ${FILE_CONF_FILES})
|
foreach(path ${ZFILE_CONF_FILES})
|
||||||
foreach(filename ${kconf_filename_list})
|
foreach(filename ${kconf_filename_list})
|
||||||
if(NOT IS_ABSOLUTE ${filename})
|
if(NOT IS_ABSOLUTE ${filename})
|
||||||
set(test_file ${path}/${filename})
|
set(test_file ${path}/${filename})
|
||||||
else()
|
else()
|
||||||
set(test_file ${filename})
|
set(test_file ${filename})
|
||||||
endif()
|
endif()
|
||||||
zephyr_file_suffix(test_file SUFFIX ${FILE_SUFFIX})
|
zephyr_file_suffix(test_file SUFFIX ${ZFILE_SUFFIX})
|
||||||
|
|
||||||
if(EXISTS ${test_file})
|
if(EXISTS ${test_file})
|
||||||
list(APPEND ${FILE_KCONF} ${test_file})
|
list(APPEND ${ZFILE_KCONF} ${test_file})
|
||||||
|
|
||||||
if(DEFINED FILE_BUILD)
|
if(DEFINED ZFILE_BUILD)
|
||||||
set(deprecated_file_found y)
|
set(deprecated_file_found y)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FILE_NAMES)
|
if(ZFILE_NAMES)
|
||||||
break()
|
break()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
@ -2671,16 +2671,16 @@ Relative paths are only allowed with `-D${ARGV1}=<path>`")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# This updates the provided list in parent scope (callers scope)
|
# This updates the provided list in parent scope (callers scope)
|
||||||
set(${FILE_KCONF} ${${FILE_KCONF}} PARENT_SCOPE)
|
set(${ZFILE_KCONF} ${${ZFILE_KCONF}} PARENT_SCOPE)
|
||||||
|
|
||||||
if(NOT ${FILE_KCONF})
|
if(NOT ${ZFILE_KCONF})
|
||||||
set(not_found ${kconf_filename_list})
|
set(not_found ${kconf_filename_list})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FILE_REQUIRED AND DEFINED not_found)
|
if(ZFILE_REQUIRED AND DEFINED not_found)
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"No ${not_found} file(s) was found in the ${FILE_CONF_FILES} folder(s), "
|
"No ${not_found} file(s) was found in the ${ZFILE_CONF_FILES} folder(s), "
|
||||||
"please read the Zephyr documentation on application development."
|
"please read the Zephyr documentation on application development."
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
@ -2690,17 +2690,17 @@ Relative paths are only allowed with `-D${ARGV1}=<path>`")
|
||||||
" you should switch to using -DFILE_SUFFIX instead")
|
" you should switch to using -DFILE_SUFFIX instead")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FILE_DEFCONFIG)
|
if(ZFILE_DEFCONFIG)
|
||||||
foreach(path ${FILE_CONF_FILES})
|
foreach(path ${ZFILE_CONF_FILES})
|
||||||
foreach(filename ${filename_list})
|
foreach(filename ${filename_list})
|
||||||
if(EXISTS ${path}/${filename}_defconfig)
|
if(EXISTS ${path}/${filename}_defconfig)
|
||||||
list(APPEND ${FILE_DEFCONFIG} ${path}/${filename}_defconfig)
|
list(APPEND ${ZFILE_DEFCONFIG} ${path}/${filename}_defconfig)
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# This updates the provided list in parent scope (callers scope)
|
# This updates the provided list in parent scope (callers scope)
|
||||||
set(${FILE_DEFCONFIG} ${${FILE_DEFCONFIG}} PARENT_SCOPE)
|
set(${ZFILE_DEFCONFIG} ${${ZFILE_DEFCONFIG}} PARENT_SCOPE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue