Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading