mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(cmake): check for missing component_target
Closes https://github.com/espressif/esp-idf/pull/14036 [Frantisek Hrbata: fixed spelling not related to this change so spellcheck succeeds] [Frantisek Hrbata: modified the error message to be recognized by the existing hint] [Frantisek Hrbata: added also check in idf_component_set_property and simple tests] Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
parent
5448703663
commit
f6a852e1cf
@ -44,7 +44,7 @@ function(__component_get_target var name_or_alias)
|
||||
|
||||
idf_build_get_property(component_targets __COMPONENT_TARGETS)
|
||||
|
||||
# Assume first that the paramters is an alias.
|
||||
# Assume first that the parameters is an alias.
|
||||
string(REPLACE "::" "_" name_or_alias "${name_or_alias}")
|
||||
set(component_target ___${name_or_alias})
|
||||
|
||||
@ -376,10 +376,14 @@ endmacro()
|
||||
function(idf_component_get_property var component property)
|
||||
cmake_parse_arguments(_ "GENERATOR_EXPRESSION" "" "" ${ARGN})
|
||||
__component_get_target(component_target ${component})
|
||||
if(__GENERATOR_EXPRESSION)
|
||||
set(val "$<TARGET_PROPERTY:${component_target},${property}>")
|
||||
if("${component_target}" STREQUAL "")
|
||||
message(FATAL_ERROR "Failed to resolve component '${component}'")
|
||||
else()
|
||||
__component_get_property(val ${component_target} ${property})
|
||||
if(__GENERATOR_EXPRESSION)
|
||||
set(val "$<TARGET_PROPERTY:${component_target},${property}>")
|
||||
else()
|
||||
__component_get_property(val ${component_target} ${property})
|
||||
endif()
|
||||
endif()
|
||||
set(${var} "${val}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
@ -398,6 +402,9 @@ endfunction()
|
||||
function(idf_component_set_property component property val)
|
||||
cmake_parse_arguments(_ "APPEND" "" "" ${ARGN})
|
||||
__component_get_target(component_target ${component})
|
||||
if(NOT component_target)
|
||||
message(FATAL_ERROR "Failed to resolve component '${component}'")
|
||||
endif()
|
||||
|
||||
if(__APPEND)
|
||||
__component_set_property(${component_target} ${property} "${val}" APPEND)
|
||||
|
@ -87,6 +87,24 @@ def test_component_properties_are_set(idf_py: IdfPyFunc, test_app_copy: Path) ->
|
||||
assert 'SRCS:{}'.format((test_app_copy / 'main' / 'build_test_app.c').as_posix()) in ret.stdout, 'Component properties should be set'
|
||||
|
||||
|
||||
def test_get_property_for_unknown_component(idf_py: IdfPyFunc, test_app_copy: Path) -> None:
|
||||
logging.info('Getting property of unknown component fails gracefully')
|
||||
append_to_file(test_app_copy / 'CMakeLists.txt', '\n'.join(['',
|
||||
'idf_component_get_property(VAR UNKNOWN PROP)']))
|
||||
ret = idf_py('reconfigure', check=False)
|
||||
assert "Failed to resolve component 'UNKNOWN'" in ret.stderr, ('idf_component_get_property '
|
||||
'for unknown component should fail gracefully')
|
||||
|
||||
|
||||
def test_set_property_for_unknown_component(idf_py: IdfPyFunc, test_app_copy: Path) -> None:
|
||||
logging.info('Setting property of unknown component fails gracefully')
|
||||
append_to_file(test_app_copy / 'CMakeLists.txt', '\n'.join(['',
|
||||
'idf_component_set_property(UNKNOWN PROP VAL)']))
|
||||
ret = idf_py('reconfigure', check=False)
|
||||
assert "Failed to resolve component 'UNKNOWN'" in ret.stderr, ('idf_component_set_property '
|
||||
'for unknown component should fail gracefully')
|
||||
|
||||
|
||||
def test_component_overridden_dir(idf_py: IdfPyFunc, test_app_copy: Path, default_idf_env: EnvDict) -> None:
|
||||
logging.info('Getting component overridden dir')
|
||||
(test_app_copy / 'components' / 'hal').mkdir(parents=True)
|
||||
|
Loading…
Reference in New Issue
Block a user