tools/ci/checkpatch: add cmake style check into ci-check

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2023-07-18 12:01:40 +08:00 committed by Alan Carvalho de Assis
parent 075eb6a6d2
commit 7eff229838
3 changed files with 21 additions and 0 deletions

View file

@ -58,6 +58,15 @@ is_rust_file() {
fi
}
is_cmake_file() {
file_name=$(basename $@)
if [ "$file_name" == "CMakeLists.txt" ] || [[ "$file_name" =~ "cmake" ]]; then
echo 1
else
echo 0
fi
}
check_file() {
if [ -x $@ ]; then
case $@ in
@ -76,6 +85,16 @@ check_file() {
elif ! rustfmt --edition 2021 --check $@ 2>&1; then
fail=1
fi
elif [ "$(is_cmake_file $@)" == "1" ]; then
if ! command -v cmake-format &> /dev/null; then
echo -e "\ncmake-format not found, run following command to install:"
echo " $ pip install cmake-format"
fail=1
elif ! cmake-format --check $@ 2>&1; then
echo -e "\ncmake-format check failed, run following command to update the style:"
echo " $ cmake-format -o $@ $@"
fail=1
fi
elif ! $TOOLDIR/nxstyle $@ 2>&1; then
fail=1
fi

View file

@ -282,6 +282,7 @@ function python-tools {
# Force the reinstall of python packages due to issues with GitHub
# cache restoration.
pip3 install --force-reinstall \
cmake-format \
CodeChecker \
cvt2utf \
cxxfilt \

View file

@ -286,6 +286,7 @@ ENV PIP_NO_CACHE_DIR=0
# instead of requiring them to be compiled.
RUN pip3 install setuptools
RUN pip3 install wheel
RUN pip3 install cmake-format
# Install CodeChecker and use it to statically analyze the code.
RUN pip3 install CodeChecker
# Install cvt2utf to check for non-UTF characters.