ci: added script to check api violations

This commit is contained in:
morris 2021-06-15 17:11:50 +08:00
parent 9afdf54748
commit 4c0ddd34b4
4 changed files with 12 additions and 4 deletions

View File

@ -50,7 +50,7 @@ check_rom_api_header:
extends: .pre_check_job_template extends: .pre_check_job_template
script: script:
- tools/ci/check_examples_rom_header.sh - tools/ci/check_examples_rom_header.sh
- tools/ci/check_rom_apis.sh - tools/ci/check_api_violation.sh
check_python_style: check_python_style:
extends: extends:

View File

@ -22,7 +22,7 @@ extern "C" {
/** /**
* Mock function to replace ESP ROM function used in IDF with a Linux implementation. * Mock function to replace ESP ROM function used in IDF with a Linux implementation.
* Note: the name MUST have the prefix esp_rom_* since tools/ci/check_rom_apis.sh checks and complains otherwise. * Note: the name MUST have the prefix esp_rom_* since tools/ci/check_api_violation.sh checks and complains otherwise.
*/ */
uint32_t esp_rom_crc32_le(uint32_t crc, const uint8_t* buf, size_t len); uint32_t esp_rom_crc32_le(uint32_t crc, const uint8_t* buf, size_t len);

View File

@ -3,7 +3,6 @@
set -uo pipefail set -uo pipefail
# ESP-IDF should only use the ROM API that has a prefix "esp_rom_" # ESP-IDF should only use the ROM API that has a prefix "esp_rom_"
cd ${IDF_PATH} # git ls-files operates on working directory only, make sure we're at the top directory cd ${IDF_PATH} # git ls-files operates on working directory only, make sure we're at the top directory
deprecated_rom_apis=$(cat ${IDF_PATH}/components/esp_rom/esp32/ld/esp32.rom.api.ld | grep "esp_rom_" | cut -d "=" -f 2 | cut -d " " -f 2) deprecated_rom_apis=$(cat ${IDF_PATH}/components/esp_rom/esp32/ld/esp32.rom.api.ld | grep "esp_rom_" | cut -d "=" -f 2 | cut -d " " -f 2)
files_to_search=$(git ls-files --full-name '*.c' ':!:components/esp_rom/') files_to_search=$(git ls-files --full-name '*.c' ':!:components/esp_rom/')
@ -21,3 +20,12 @@ if [ $count -gt 0 ]; then
echo "Please try to use the APIs listed in esp_rom/include/esp_rom_xxx.h" echo "Please try to use the APIs listed in esp_rom/include/esp_rom_xxx.h"
exit 1 exit 1
fi fi
# ESP-IDF `hal` component shouldn't call "assert()" directlly
files_to_search=$(git ls-files --full-name 'components/hal/*')
found_libc_assert=$(grep -E '\W+assert\(' $files_to_search)
if [ -n "$found_libc_assert" ]; then
echo "hal assert violation"
echo $found_libc_assert
echo "Please use HAL_ASSERT() instead of assert() in hal component"
fi

View File

@ -38,6 +38,7 @@ install.sh
tools/build_apps.py tools/build_apps.py
tools/check_python_dependencies.py tools/check_python_dependencies.py
tools/ci/build_template_app.sh tools/ci/build_template_app.sh
tools/ci/check_api_violation.sh
tools/ci/check_build_warnings.py tools/ci/check_build_warnings.py
tools/ci/check_callgraph.py tools/ci/check_callgraph.py
tools/ci/check_codeowners.py tools/ci/check_codeowners.py
@ -48,7 +49,6 @@ tools/ci/check_executables.py
tools/ci/check_idf_version.sh tools/ci/check_idf_version.sh
tools/ci/check_kconfigs.py tools/ci/check_kconfigs.py
tools/ci/check_readme_links.py tools/ci/check_readme_links.py
tools/ci/check_rom_apis.sh
tools/ci/check_rules_yml.py tools/ci/check_rules_yml.py
tools/ci/check_tools_files_patterns.py tools/ci/check_tools_files_patterns.py
tools/ci/check_type_comments.py tools/ci/check_type_comments.py