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.
This commit is contained in:
Ivan Grokhotkov
2024-07-11 13:29:51 +02:00
parent 75eb7fe379
commit c521fcb6fd
4 changed files with 18 additions and 4 deletions

View File

@@ -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