Skip to content

Commit

Permalink
tools/ci/checkpatch: add cmake style check into ci-check
Browse files Browse the repository at this point in the history
Signed-off-by: chao an <[email protected]>
  • Loading branch information
anchao committed Jul 18, 2023
1 parent b79671a commit c712f97
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tools/checkpatch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions tools/ci/cibuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions tools/ci/docker/linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c712f97

Please sign in to comment.