fix(cmake): report correct error on unknown component name

Previously the error message was

CMake Error at /home/user/esp-idf/tools/cmake/build.cmake:296 (__component_get_property):
  __component_get_property Function invoked with incorrect arguments for
  function named: __component_get_property
Call Stack (most recent call first):
  /home/user/esp-idf/tools/cmake/build.cmake:341 (__build_resolve_and_add_req)
  /home/user/esp-idf/tools/cmake/build.cmake:638 (__build_expand_requirements)
  /home/user/esp-idf/tools/cmake/project.cmake:710 (idf_build_process)
  CMakeLists.txt:6 (project)

Now it will be:

CMake Error at /home/user/esp-idf/tools/cmake/build.cmake:298 (message):
  Failed to resolve component 'whatever' required by component 'main'.
Call Stack (most recent call first):
  /home/user/esp-idf/tools/cmake/build.cmake:345 (__build_resolve_and_add_req)
  /home/user/esp-idf/tools/cmake/build.cmake:642 (__build_expand_requirements)
  /home/user/esp-idf/tools/cmake/project.cmake:710 (idf_build_process)
  CMakeLists.txt:6 (project)

Also improved the hint to show the component name in quotes.
pull/14365/head
Ivan Grokhotkov 2024-07-11 13:29:51 +02:00
rodzic 75eb7fe379
commit c521fcb6fd
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 1E050E141B280628
4 zmienionych plików z 18 dodań i 4 usunięć

Wyświetl plik

@ -295,11 +295,14 @@ function(__build_resolve_and_add_req var component_target req type)
__component_get_target(_req_target ${req})
__component_get_property(_component_name ${component_target} COMPONENT_NAME)
if(NOT _req_target)
message(FATAL_ERROR "Failed to resolve component '${req}' required by component '${_component_name}'.")
message(FATAL_ERROR
"Failed to resolve component '${req}' required by component '${_component_name}': unknown name.")
endif()
__component_get_property(_req_registered ${_req_target} __COMPONENT_REGISTERED)
if(NOT _req_registered)
message(FATAL_ERROR "Failed to resolve component '${req}' required by component '${_component_name}'.")
message(FATAL_ERROR
"Failed to resolve component '${req}' required by component '${_component_name}': "
"component not registered.")
endif()
__component_set_property(${component_target} ${type} ${_req_target} APPEND)
set(${var} ${_req_target} PARENT_SCOPE)

Wyświetl plik

@ -216,7 +216,7 @@
-
re: "Failed to resolve component '(?!esp_ipc)(\\w+)'"
hint: "The component {} could not be found. This could be because: component name was misspelled, the component was not added to the build, the component has been moved to the IDF component manager, the component has been removed and refactored into some other component or the component may not be supported by the selected target.\nPlease look out for component in 'https://components.espressif.com' and add using 'idf.py add-dependency' command.\nRefer to the migration guide for more details about moved components.\nRefer to the build-system guide for more details about how components are found and included in the build."
hint: "The component '{}' could not be found. This could be because: component name was misspelled, the component was not added to the build, the component has been moved to the IDF component manager, the component has been removed and refactored into some other component or the component may not be supported by the selected target.\nPlease look out for component in 'https://components.espressif.com' and add using 'idf.py add-dependency' command.\nRefer to the migration guide for more details about moved components.\nRefer to the build-system guide for more details about how components are found and included in the build."
match_to_output: True
-

Wyświetl plik

@ -153,3 +153,14 @@ def test_version_in_component_cmakelist(idf_py: IdfPyFunc, test_app_copy: Path)
replace_in_file((test_app_copy / 'main' / 'CMakeLists.txt'), '# placeholder_before_idf_component_register',
'\n'.join(['if (NOT IDF_VERSION_MAJOR)', ' message(FATAL_ERROR "IDF version not set")', 'endif()']))
idf_py('reconfigure')
def test_unknown_component_error(idf_py: IdfPyFunc, test_app_copy: Path) -> None:
logging.info('When unknown component name is specified, correct error is shown')
replace_in_file(
test_app_copy / 'main' / 'CMakeLists.txt',
search='# placeholder_inside_idf_component_register',
replace='REQUIRES unknown',
)
ret = idf_py('reconfigure', check=False)
assert 'Failed to resolve component \'unknown\' required by component \'main\'' in ret.stderr

Wyświetl plik

@ -47,7 +47,7 @@
"HINT: The struct 'esp_tls_t' has now been made private - its elements can be only be accessed/modified through respective getter/setter functions. Please refer to the migration guide for more information."
"Failed to resolve component 'component'\n":
"HINT: The component component could not be found. This could be because: component name was misspelled, the component was not added to the build, the component has been moved to the IDF component manager, the component has been removed and refactored into some other component or the component may not be supported by the selected target.\nPlease look out for component in 'https://components.espressif.com' and add using 'idf.py add-dependency' command.\nRefer to the migration guide for more details about moved components.\nRefer to the build-system guide for more details about how components are found and included in the build."
"HINT: The component 'component' could not be found. This could be because: component name was misspelled, the component was not added to the build, the component has been moved to the IDF component manager, the component has been removed and refactored into some other component or the component may not be supported by the selected target.\nPlease look out for component in 'https://components.espressif.com' and add using 'idf.py add-dependency' command.\nRefer to the migration guide for more details about moved components.\nRefer to the build-system guide for more details about how components are found and included in the build."
'fatal error: tmp/atca_mbedtls_wrap.h: No such file or directory\n':
"HINT: To use CONFIG_ESP_TLS_USE_SECURE_ELEMENT option, please install `esp-cryptoauthlib` using 'idf.py add-dependency espressif/esp-cryptoauthlib'"