Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: add REQUIRED option ot dt_nodelabel #78406

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions cmake/modules/extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3636,9 +3636,11 @@ endfunction()
#
# <var> : Return variable where the node path will be stored
# NODELABEL <label> : Node label
# REQUIRED : Generate a fatal error if the node-label is not found
function(dt_nodelabel var)
set(options "REQUIRED")
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)
message(FATAL_ERROR "dt_nodelabel(${ARGV0} ...) missing return parameter.")
Expand All @@ -3654,6 +3656,9 @@ function(dt_nodelabel var)

get_target_property(${var} devicetree_target "DT_NODELABEL|${DT_LABEL_NODELABEL}")
if(${${var}} STREQUAL ${var}-NOTFOUND)
if(DT_LABEL_REQUIRED)
message(FATAL_ERROR "required nodelabel not found: ${DT_LABEL_NODELABEL}")
endif()
set(${var})
endif()

Expand All @@ -3679,9 +3684,11 @@ endfunction()
#
# <var> : Return variable where the node path will be stored
# PROPERTY <prop> : The alias to check
# REQUIRED : Generate a fatal error if the alias is not found
function(dt_alias var)
set(options "REQUIRED")
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)
message(FATAL_ERROR "dt_alias(${ARGV0} ...) missing return parameter.")
Expand All @@ -3697,6 +3704,9 @@ function(dt_alias var)

get_target_property(${var} devicetree_target "DT_ALIAS|${DT_ALIAS_PROPERTY}")
if(${${var}} STREQUAL ${var}-NOTFOUND)
if(DT_ALIAS_REQUIRED)
message(FATAL_ERROR "required alias not found: ${DT_ALIAS_PROPERTY}")
endif()
set(${var})
endif()

Expand Down Expand Up @@ -3849,10 +3859,12 @@ endfunction()
# PROPERTY <prop>: Property for which a value should be returned, as it
# appears in the DTS source
# 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)
set(options "REQUIRED")
set(req_single_args "PATH;PROPERTY")
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)
message(FATAL_ERROR "dt_prop(${ARGV0} ...) missing return parameter.")
Expand All @@ -3874,6 +3886,9 @@ function(dt_prop var)

if(NOT exists)
set(${var} PARENT_SCOPE)
if(DT_PROP_REQUIRED)
message(FATAL_ERROR "required property not found: ${canonical}/${DT_PROP_PROPERTY}")
endif()
return()
endif()

Expand Down
Loading