mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/change_component_ordering' into 'master'
cmake: swap priority between EXTRA_COMPONENT_DIRS and project components Closes IDF-2864 See merge request espressif/esp-idf!12765
This commit is contained in:
commit
da3dca1fdc
@ -363,7 +363,7 @@ When CMake runs to configure the project, it logs the components included in the
|
||||
Multiple components with the same name
|
||||
--------------------------------------
|
||||
|
||||
When ESP-IDF is collecting all the components to compile, it will do this in the order specified by ``COMPONENT_DIRS``; by default, this means ESP-IDF's internal components first, then the project's components, and finally any components set in ``EXTRA_COMPONENT_DIRS``. If two or more of these directories contain component sub-directories with the same name, the component in the last place searched is used. This allows, for example, overriding ESP-IDF components with a modified version by copying that component from the ESP-IDF components directory to the project components directory and then modifying it there. If used in this way, the ESP-IDF directory itself can remain untouched.
|
||||
When ESP-IDF is collecting all the components to compile, it will do this in the order specified by ``COMPONENT_DIRS``; by default, this means ESP-IDF's internal components first (``IDF_PATH/components``), then any components in directories specified in ``EXTRA_COMPONENT_DIRS``, and finally the project's components (``PROJECT_DIR/components``). If two or more of these directories contain component sub-directories with the same name, the component in the last place searched is used. This allows, for example, overriding ESP-IDF components with a modified version by copying that component from the ESP-IDF components directory to the project components directory and then modifying it there. If used in this way, the ESP-IDF directory itself can remain untouched.
|
||||
|
||||
.. note:: If a component is overridden in an existing project by moving it to a new location, the project will not automatically see the new component path. Run ``idf.py reconfigure`` (or delete the project build folder) and then build again.
|
||||
|
||||
|
@ -419,6 +419,19 @@ endmenu\n" >> ${IDF_PATH}/Kconfig;
|
||||
git checkout -- sdkconfig.rename Kconfig
|
||||
popd
|
||||
|
||||
print_status "Project components prioritized over EXTRA_COMPONENT_DIRS"
|
||||
clean_build_dir
|
||||
mkdir -p extra_dir/my_component
|
||||
echo "COMPONENT_CONFIG_ONLY := 1" > extra_dir/my_component/component.mk
|
||||
cp Makefile Makefile.bak # set EXTRA_COMPONENT_DIRS to point to the other directory
|
||||
sed -i "s%PROJECT_NAME := app-template%PROJECT_NAME := app-template\nEXTRA_COMPONENT_DIRS := extra_dir%" Makefile
|
||||
(make list-components | grep "$PWD/extra_dir/my_component") || failure "Unable to find component specified in EXTRA_COMPONENT_DIRS"
|
||||
mkdir -p components/my_component
|
||||
echo "COMPONENT_CONFIG_ONLY := 1" > components/my_component/component.mk
|
||||
(make list-components | grep "$PWD/components/my_component") || failure "Project components should be prioritized over EXTRA_COMPONENT_DIRS"
|
||||
mv Makefile.bak Makefile # revert previous modifications
|
||||
rm -rf extra_dir components
|
||||
|
||||
print_status "All tests completed"
|
||||
if [ -n "${FAILURES}" ]; then
|
||||
echo "Some failures were detected:"
|
||||
|
@ -814,6 +814,19 @@ endmenu\n" >> ${IDF_PATH}/Kconfig
|
||||
(idf.py reconfigure | grep "kconfig:$IDF_PATH/components/esp32/Kconfig") || failure "Failed to verify original `main` directory"
|
||||
rm -rf components
|
||||
|
||||
print_status "Project components prioritized over EXTRA_COMPONENT_DIRS"
|
||||
clean_build_dir
|
||||
mkdir -p extra_dir/my_component
|
||||
echo "idf_component_register()" > extra_dir/my_component/CMakeLists.txt
|
||||
cp CMakeLists.txt CMakeLists.bak # set EXTRA_COMPONENT_DIRS to point to the other directory
|
||||
${SED} -i "s%cmake_minimum_required(VERSION \([0-9]\+\).\([0-9]\+\))%cmake_minimum_required(VERSION \1.\2)\nset(EXTRA_COMPONENT_DIRS extra_dir)%" CMakeLists.txt
|
||||
(idf.py reconfigure | grep "$PWD/extra_dir/my_component") || failure "Unable to find component specified in EXTRA_COMPONENT_DIRS"
|
||||
mkdir -p components/my_component
|
||||
echo "idf_component_register()" > components/my_component/CMakeLists.txt
|
||||
(idf.py reconfigure | grep "$PWD/components/my_component") || failure "Project components should be prioritized over EXTRA_COMPONENT_DIRS"
|
||||
mv CMakeLists.bak CMakeLists.txt # revert previous modifications
|
||||
rm -rf extra_dir components
|
||||
|
||||
print_status "Create project using idf.py and build it"
|
||||
echo "Trying to create project."
|
||||
(idf.py -C projects create-project temp_test_project) || failure "Failed to create the project."
|
||||
@ -850,8 +863,6 @@ endmenu\n" >> ${IDF_PATH}/Kconfig
|
||||
expected_failure $EXPECTED_EXIT_VALUE idf.py create-project --path "$IDF_PATH/example_proj" temp_test_project || failure "Command exit value is wrong."
|
||||
rm -rf "$IDF_PATH/example_proj"
|
||||
|
||||
|
||||
|
||||
print_status "All tests completed"
|
||||
if [ -n "${FAILURES}" ]; then
|
||||
echo "Some failures were detected:"
|
||||
|
@ -180,18 +180,18 @@ function(__project_init components_var test_components_var)
|
||||
__project_component_dir(${component_dir})
|
||||
endforeach()
|
||||
else()
|
||||
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/main")
|
||||
__project_component_dir("${CMAKE_CURRENT_LIST_DIR}/main")
|
||||
endif()
|
||||
|
||||
spaces2list(EXTRA_COMPONENT_DIRS)
|
||||
foreach(component_dir ${EXTRA_COMPONENT_DIRS})
|
||||
__project_component_dir("${component_dir}")
|
||||
endforeach()
|
||||
|
||||
__project_component_dir("${CMAKE_CURRENT_LIST_DIR}/components")
|
||||
|
||||
# Look for components in the usual places: CMAKE_CURRENT_LIST_DIR/main,
|
||||
# CMAKE_CURRENT_LIST_DIR/components, and the extra component dirs
|
||||
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/main")
|
||||
__project_component_dir("${CMAKE_CURRENT_LIST_DIR}/main")
|
||||
endif()
|
||||
# extra component dirs, and CMAKE_CURRENT_LIST_DIR/components
|
||||
__project_component_dir("${CMAKE_CURRENT_LIST_DIR}/components")
|
||||
endif()
|
||||
|
||||
spaces2list(COMPONENTS)
|
||||
|
Loading…
Reference in New Issue
Block a user