Skip to content

Commit 3e370c4

Browse files
committed
Merge branch 'bugfix/filter_out_readme_searching_components' into 'master'
cmake: allow to have README file in the components folder See merge request espressif/esp-idf!15330
2 parents 8d74bf8 + 0f7b90d commit 3e370c4

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

tools/cmake/build.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,12 @@ function(__build_init idf_path)
150150
file(GLOB component_dirs ${idf_path}/components/*)
151151
list(SORT component_dirs)
152152
foreach(component_dir ${component_dirs})
153-
get_filename_component(component_dir ${component_dir} ABSOLUTE)
154-
__component_dir_quick_check(is_component ${component_dir})
155-
if(is_component)
156-
__component_add(${component_dir} ${prefix})
153+
# A potential component must be a directory
154+
if(IS_DIRECTORY ${component_dir})
155+
__component_dir_quick_check(is_component ${component_dir})
156+
if(is_component)
157+
__component_add(${component_dir} ${prefix})
158+
endif()
157159
endif()
158160
endforeach()
159161

tools/cmake/component.cmake

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,11 @@ function(__component_dir_quick_check var component_dir)
9797
set(res 1)
9898
get_filename_component(abs_dir ${component_dir} ABSOLUTE)
9999

100-
# Check this is really a directory and that a CMakeLists.txt file for this component exists
101-
# - warn and skip anything which isn't valid looking (probably cruft)
102-
if(NOT IS_DIRECTORY "${abs_dir}")
103-
message(STATUS "Unexpected file in components directory: ${abs_dir}")
104-
set(res 0)
105-
endif()
106-
107100
get_filename_component(base_dir ${abs_dir} NAME)
108101
string(SUBSTRING "${base_dir}" 0 1 first_char)
109102

103+
# Check the component directory contains a CMakeLists.txt file
104+
# - warn and skip anything which isn't valid looking (probably cruft)
110105
if(NOT first_char STREQUAL ".")
111106
if(NOT EXISTS "${abs_dir}/CMakeLists.txt")
112107
message(STATUS "Component directory ${abs_dir} does not contain a CMakeLists.txt file. "

tools/cmake/project.cmake

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,14 @@ function(__project_init components_var test_components_var)
157157

158158
function(__project_component_dir component_dir)
159159
get_filename_component(component_dir "${component_dir}" ABSOLUTE)
160+
# The directory itself is a valid idf component
160161
if(EXISTS ${component_dir}/CMakeLists.txt)
161162
idf_build_component(${component_dir})
162163
else()
164+
# otherwise, check whether the subfolders are potential idf components
163165
file(GLOB component_dirs ${component_dir}/*)
164166
foreach(component_dir ${component_dirs})
165-
if(EXISTS ${component_dir}/CMakeLists.txt)
166-
get_filename_component(base_dir ${component_dir} NAME)
167+
if(IS_DIRECTORY ${component_dir})
167168
__component_dir_quick_check(is_component ${component_dir})
168169
if(is_component)
169170
idf_build_component(${component_dir})
@@ -205,9 +206,11 @@ function(__project_init components_var test_components_var)
205206
file(GLOB bootloader_component_dirs "${CMAKE_CURRENT_LIST_DIR}/bootloader_components/*")
206207
list(SORT bootloader_component_dirs)
207208
foreach(bootloader_component_dir ${bootloader_component_dirs})
208-
__component_dir_quick_check(is_component ${bootloader_component_dir})
209-
if(is_component)
210-
__kconfig_bootloader_component_add("${bootloader_component_dir}")
209+
if(IS_DIRECTORY ${bootloader_component_dir})
210+
__component_dir_quick_check(is_component ${bootloader_component_dir})
211+
if(is_component)
212+
__kconfig_bootloader_component_add("${bootloader_component_dir}")
213+
endif()
211214
endif()
212215
endforeach()
213216

0 commit comments

Comments
 (0)