diff --git a/.gitlab/ci/pre_check.yml b/.gitlab/ci/pre_check.yml index aeee0b3cf7..b18c20d798 100644 --- a/.gitlab/ci/pre_check.yml +++ b/.gitlab/ci/pre_check.yml @@ -64,11 +64,12 @@ check_version: - export IDF_PATH=$PWD - tools/ci/check_idf_version.sh -check_rom_api_header: +check_api_usage: extends: .pre_check_template script: - tools/ci/check_examples_rom_header.sh - tools/ci/check_api_violation.sh + - tools/ci/check_examples_extra_component_dirs.sh test_check_kconfigs: extends: .pre_check_template diff --git a/tools/ci/check_examples_extra_component_dirs.sh b/tools/ci/check_examples_extra_component_dirs.sh new file mode 100755 index 0000000000..207efff7f4 --- /dev/null +++ b/tools/ci/check_examples_extra_component_dirs.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +set -uo pipefail + +# Examples shouldn't use EXTRA_COMPONENT_DIRS, instead the dependencies should be specified in idf_component.yml files + +output=$(find ${IDF_PATH}/examples -name "CMakeLists.txt" -not -path "**/managed_components/**" -not -path "**/build/**") +files=$(egrep "set\(EXTRA_COMPONENT_DIRS" ${output} | cut -d ":" -f 1) +found_issues=0 +for file in ${files} +do + if [ "$file" == "${IDF_PATH}/examples/system/unit_test/test/CMakeLists.txt" ]; then + # this specific one is okay + continue + fi + echo "${file} uses EXTRA_COMPONENT_DIRS. Change it to reference the component using idf_component.yml file." + ((found_issues++)) +done + +if [ $found_issues -eq 0 ]; then + echo "No examples use EXTRA_COMPONENT_DIRS" + exit 0 +fi + +exit 1 diff --git a/tools/ci/executable-list.txt b/tools/ci/executable-list.txt index 59bf4162b9..6d27152c5f 100644 --- a/tools/ci/executable-list.txt +++ b/tools/ci/executable-list.txt @@ -55,6 +55,7 @@ tools/ci/check_callgraph.py tools/ci/check_codeowners.py tools/ci/check_deprecated_kconfigs.py tools/ci/check_esp_memory_utils_headers.sh +tools/ci/check_examples_extra_component_dirs.sh tools/ci/check_examples_rom_header.sh tools/ci/check_executables.py tools/ci/check_idf_version.sh