2024-04-23 03:28:51 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e -E -u -o pipefail
|
2023-04-02 04:06:09 +03:00
|
|
|
|
|
|
|
echo "running cpplint"
|
|
|
|
cpplint \
|
|
|
|
--filter=-build/c++11,-build/include_subdir,-build/header_guard,-whitespace/line_length \
|
|
|
|
--recursive ./src ./include ./R-package ./swig ./tests \
|
2024-02-10 07:42:00 +03:00
|
|
|
|| exit 1
|
2023-04-02 04:06:09 +03:00
|
|
|
echo "done running cpplint"
|
|
|
|
|
|
|
|
echo "running cmakelint"
|
|
|
|
cmake_files=$(
|
|
|
|
find . -name CMakeLists.txt -o -path "./cmake/*.cmake" \
|
|
|
|
| grep -v external_libs
|
|
|
|
)
|
|
|
|
cmakelint \
|
|
|
|
--linelength=120 \
|
|
|
|
--filter=-convention/filename,-package/stdargs,-readability/wonkycase \
|
|
|
|
${cmake_files} \
|
2024-02-10 07:42:00 +03:00
|
|
|
|| exit 1
|
2023-04-02 04:06:09 +03:00
|
|
|
echo "done running cmakelint"
|
2023-10-10 04:05:51 +03:00
|
|
|
|
|
|
|
echo "checking that all OpenMP pragmas specify num_threads()"
|
|
|
|
get_omp_pragmas_without_num_threads() {
|
|
|
|
grep \
|
|
|
|
-n \
|
|
|
|
-R \
|
|
|
|
--include='*.c' \
|
|
|
|
--include='*.cc' \
|
|
|
|
--include='*.cpp' \
|
|
|
|
--include='*.h' \
|
|
|
|
--include='*.hpp' \
|
|
|
|
'pragma omp parallel' \
|
2023-12-08 02:03:16 +03:00
|
|
|
| grep -v ' num_threads'
|
2023-10-10 04:05:51 +03:00
|
|
|
}
|
2024-04-23 03:28:51 +03:00
|
|
|
|
|
|
|
# 'grep' returns a non-0 exit code if 0 lines were found.
|
|
|
|
# Turning off '-e -o pipefail' options here so that bash doesn't
|
|
|
|
# consider this a failure and stop execution of the script.
|
|
|
|
#
|
|
|
|
# ref: https://www.gnu.org/software/grep/manual/html_node/Exit-Status.html
|
|
|
|
set +e +o pipefail
|
2023-10-10 04:05:51 +03:00
|
|
|
PROBLEMATIC_LINES=$(
|
|
|
|
get_omp_pragmas_without_num_threads
|
|
|
|
)
|
2024-04-23 03:28:51 +03:00
|
|
|
set -e -o pipefail
|
2023-10-10 04:05:51 +03:00
|
|
|
if test "${PROBLEMATIC_LINES}" != ""; then
|
|
|
|
get_omp_pragmas_without_num_threads
|
|
|
|
echo "Found '#pragma omp parallel' not using explicit num_threads() configuration. Fix those."
|
|
|
|
echo "For details, see https://www.openmp.org/spec-html/5.0/openmpse14.html#x54-800002.6"
|
2024-02-10 07:42:00 +03:00
|
|
|
exit 1
|
2023-10-10 04:05:51 +03:00
|
|
|
fi
|
|
|
|
echo "done checking OpenMP pragmas"
|