cmake: Add REQUIRED option to devicetree getters
namely: - dt_nodelabel - dt_alias - dt_prop these currently fail quietly. This can cause some very confusing errors later on. By adding `REQUIRED` to the function call one can easily generate a more clear message: required nodelabel not found: ... Signed-off-by: David van Rijn <david@refractor.dev>
This commit is contained in:
parent
ccc243c129
commit
96386eac0b
1 changed files with 18 additions and 3 deletions
|
@ -3636,9 +3636,11 @@ endfunction()
|
||||||
#
|
#
|
||||||
# <var> : Return variable where the node path will be stored
|
# <var> : Return variable where the node path will be stored
|
||||||
# NODELABEL <label> : Node label
|
# NODELABEL <label> : Node label
|
||||||
|
# REQUIRED : Generate a fatal error if the node-label is not found
|
||||||
function(dt_nodelabel var)
|
function(dt_nodelabel var)
|
||||||
|
set(options "REQUIRED")
|
||||||
set(req_single_args "NODELABEL")
|
set(req_single_args "NODELABEL")
|
||||||
cmake_parse_arguments(DT_LABEL "" "${req_single_args}" "" ${ARGN})
|
cmake_parse_arguments(DT_LABEL "${options}" "${req_single_args}" "" ${ARGN})
|
||||||
|
|
||||||
if(${ARGV0} IN_LIST req_single_args)
|
if(${ARGV0} IN_LIST req_single_args)
|
||||||
message(FATAL_ERROR "dt_nodelabel(${ARGV0} ...) missing return parameter.")
|
message(FATAL_ERROR "dt_nodelabel(${ARGV0} ...) missing return parameter.")
|
||||||
|
@ -3654,6 +3656,9 @@ function(dt_nodelabel var)
|
||||||
|
|
||||||
get_target_property(${var} devicetree_target "DT_NODELABEL|${DT_LABEL_NODELABEL}")
|
get_target_property(${var} devicetree_target "DT_NODELABEL|${DT_LABEL_NODELABEL}")
|
||||||
if(${${var}} STREQUAL ${var}-NOTFOUND)
|
if(${${var}} STREQUAL ${var}-NOTFOUND)
|
||||||
|
if(DT_LABEL_REQUIRED)
|
||||||
|
message(FATAL_ERROR "required nodelabel not found: ${DT_LABEL_NODELABEL}")
|
||||||
|
endif()
|
||||||
set(${var})
|
set(${var})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -3679,9 +3684,11 @@ endfunction()
|
||||||
#
|
#
|
||||||
# <var> : Return variable where the node path will be stored
|
# <var> : Return variable where the node path will be stored
|
||||||
# PROPERTY <prop> : The alias to check
|
# PROPERTY <prop> : The alias to check
|
||||||
|
# REQUIRED : Generate a fatal error if the alias is not found
|
||||||
function(dt_alias var)
|
function(dt_alias var)
|
||||||
|
set(options "REQUIRED")
|
||||||
set(req_single_args "PROPERTY")
|
set(req_single_args "PROPERTY")
|
||||||
cmake_parse_arguments(DT_ALIAS "" "${req_single_args}" "" ${ARGN})
|
cmake_parse_arguments(DT_ALIAS "${options}" "${req_single_args}" "" ${ARGN})
|
||||||
|
|
||||||
if(${ARGV0} IN_LIST req_single_args)
|
if(${ARGV0} IN_LIST req_single_args)
|
||||||
message(FATAL_ERROR "dt_alias(${ARGV0} ...) missing return parameter.")
|
message(FATAL_ERROR "dt_alias(${ARGV0} ...) missing return parameter.")
|
||||||
|
@ -3697,6 +3704,9 @@ function(dt_alias var)
|
||||||
|
|
||||||
get_target_property(${var} devicetree_target "DT_ALIAS|${DT_ALIAS_PROPERTY}")
|
get_target_property(${var} devicetree_target "DT_ALIAS|${DT_ALIAS_PROPERTY}")
|
||||||
if(${${var}} STREQUAL ${var}-NOTFOUND)
|
if(${${var}} STREQUAL ${var}-NOTFOUND)
|
||||||
|
if(DT_ALIAS_REQUIRED)
|
||||||
|
message(FATAL_ERROR "required alias not found: ${DT_ALIAS_PROPERTY}")
|
||||||
|
endif()
|
||||||
set(${var})
|
set(${var})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -3849,10 +3859,12 @@ endfunction()
|
||||||
# PROPERTY <prop>: Property for which a value should be returned, as it
|
# PROPERTY <prop>: Property for which a value should be returned, as it
|
||||||
# appears in the DTS source
|
# appears in the DTS source
|
||||||
# INDEX <idx> : Optional index when retrieving a value in an array property
|
# INDEX <idx> : Optional index when retrieving a value in an array property
|
||||||
|
# REQUIRED : Generate a fatal error if the property is not found
|
||||||
function(dt_prop var)
|
function(dt_prop var)
|
||||||
|
set(options "REQUIRED")
|
||||||
set(req_single_args "PATH;PROPERTY")
|
set(req_single_args "PATH;PROPERTY")
|
||||||
set(single_args "INDEX")
|
set(single_args "INDEX")
|
||||||
cmake_parse_arguments(DT_PROP "" "${req_single_args};${single_args}" "" ${ARGN})
|
cmake_parse_arguments(DT_PROP "${options}" "${req_single_args};${single_args}" "" ${ARGN})
|
||||||
|
|
||||||
if(${ARGV0} IN_LIST req_single_args)
|
if(${ARGV0} IN_LIST req_single_args)
|
||||||
message(FATAL_ERROR "dt_prop(${ARGV0} ...) missing return parameter.")
|
message(FATAL_ERROR "dt_prop(${ARGV0} ...) missing return parameter.")
|
||||||
|
@ -3874,6 +3886,9 @@ function(dt_prop var)
|
||||||
|
|
||||||
if(NOT exists)
|
if(NOT exists)
|
||||||
set(${var} PARENT_SCOPE)
|
set(${var} PARENT_SCOPE)
|
||||||
|
if(DT_PROP_REQUIRED)
|
||||||
|
message(FATAL_ERROR "required property not found: ${canonical}/${DT_PROP_PROPERTY}")
|
||||||
|
endif()
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue