lint-cpp.sh 1.28 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh

echo "running cpplint"
cpplint \
    --filter=-build/c++11,-build/include_subdir,-build/header_guard,-whitespace/line_length \
    --recursive ./src ./include ./R-package ./swig ./tests \
|| exit -1
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} \
|| exit -1
echo "done running cmakelint"
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

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' \
    | grep -v ' num_threads' \
    | grep -v 'openmp_wrapper.h'
}
PROBLEMATIC_LINES=$(
    get_omp_pragmas_without_num_threads
)
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"
    exit -1
fi
echo "done checking OpenMP pragmas"