Commit a5cd46b8 authored by Torsten Rasmussen's avatar Torsten Rasmussen Committed by Anas Nashif
Browse files

cmake: support PATH argument in build_info()



Support PATH argument in build_info() function.
The PATH argument can be used to provide a list of paths paths and that
those paths might be using native style, such as `c:\win\path', and
therefore should be converted to CMake style path.

Signed-off-by: default avatarTorsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
parent 121cb49a
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -3659,6 +3659,7 @@ endfunction()

# Usage:
#   build_info(<tag>... VALUE <value>... )
#   build_info(<tag>... PATH  <path>... )
#
# This function populates updates the build_info.yml info file with exchangable build information
# related to the current build.
@@ -3675,11 +3676,20 @@ endfunction()
# <tag>...: One of the pre-defined valid CMake keys supported by build info or vendor-specific.
#           See 'scripts/schemas/build-schema.yml' CMake section for valid tags.
# VALUE <value>... : value(s) to place in the build_info.yml file.
# PATH  <path>... : path(s) to place in the build_info.yml file. All paths are converted to CMake
#                   style. If no conversion is required, for example when paths are already
#                   guaranteed to be CMake style, then VALUE can also be used.
function(build_info)
  set(convert_path FALSE)
  set(arg_list ${ARGV})
  list(FIND arg_list VALUE index)
  if(index EQUAL -1)
    message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION}(...) missing a required argument: VALUE")
    list(FIND arg_list PATH index)
    set(convert_path TRUE)
  endif()

  if(index EQUAL -1)
    message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION}(...) missing a required argument: VALUE or PATH")
  endif()

  yaml_context(EXISTS NAME build_info result)
@@ -3697,6 +3707,15 @@ function(build_info)
  list(SUBLIST arg_list ${index} -1 values)
  list(POP_FRONT values)

  if(convert_path)
    set(converted_values)
    foreach(val ${values})
      cmake_path(SET cmake_path "${val}")
      list(APPEND converted_values "${cmake_path}")
    endforeach()
    set(values "${converted_values}")
  endif()

  if(ARGV0 STREQUAL "vendor-specific")
    set(type VALUE)
  else()