File: detect_missing_include.sh

package info (click to toggle)
gdal 3.12.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 92,396 kB
  • sloc: cpp: 1,224,305; ansic: 206,456; python: 26,284; java: 6,001; xml: 4,769; sh: 3,869; cs: 2,513; yacc: 1,306; makefile: 214
file content (97 lines) | stat: -rwxr-xr-x 2,705 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash

set -eu

SCRIPT_DIR=$(dirname "$0")
case $SCRIPT_DIR in
    "/"*)
        ;;
    ".")
        SCRIPT_DIR=$(pwd)
        ;;
    *)
        SCRIPT_DIR=$(pwd)/$(dirname "$0")
        ;;
esac
GDAL_ROOT=$SCRIPT_DIR/..
cd "$GDAL_ROOT"

ret_code=0

find alg port gcore apps ogr frmts gnm autotest/cpp \( -name "*.cpp" -o -name "*.h" -o -name "*.hpp" \) > /tmp/gdal_list_files.txt

echo "Checking for missing #include <algorithm> statements..."
rm -f /tmp/missing_include.txt
while read -r i; do
   grep -e std::min -e std::max $i >/dev/null && (grep "#include <algorithm>" $i >/dev/null || echo $i) | grep -v ogr/ogrsf_frmts/flatgeobuf/flatbuffers/ | tee -a /tmp/missing_include.txt;
done < /tmp/gdal_list_files.txt

if test -s /tmp/missing_include.txt; then
    echo "FAIL: missing #include <algorithm> in above listed files"
    ret_code=1
else
    echo "OK."
fi


echo "Checking for missing #include <array> statements..."
rm -f /tmp/missing_include.txt
while read -r i; do
   grep -e std::array $i >/dev/null && (grep "#include <array>" $i >/dev/null || echo $i) |tee -a /tmp/missing_include.txt;
done < /tmp/gdal_list_files.txt

if test -s /tmp/missing_include.txt; then
    echo "FAIL: missing #include <array> in above listed files"
    ret_code=1
else
    echo "OK."
fi


echo "Checking for missing #include <limits> statements..."
rm -f /tmp/missing_include.txt
while read -r i; do
   grep -e std::numeric_limits $i >/dev/null && (grep "#include <limits>" $i >/dev/null || echo $i) | grep -v ogr/ogrsf_frmts/flatgeobuf/flatbuffers/ | tee -a /tmp/missing_include.txt;
done < /tmp/gdal_list_files.txt


if test -s /tmp/missing_include.txt; then
    echo "FAIL: missing #include <limits> in above listed files"
    ret_code=1
else
    echo "OK."
fi


echo "Checking for missing #include <cctype> statements..."
rm -f /tmp/missing_include.txt
while read -r i; do
   grep -e std::isalpha $i >/dev/null && (grep "#include <cctype>" $i >/dev/null || echo $i) | tee -a /tmp/missing_include.txt;
done < /tmp/gdal_list_files.txt


if test -s /tmp/missing_include.txt; then
    echo "FAIL: missing #include <cctype> in above listed files"
    ret_code=1
else
    echo "OK."
fi

echo "Checking for missing #include <cmath> statements..."
rm -f /tmp/missing_include.txt
while read -r i; do
   grep -e std::isnan -e std::isinf -e std::isfinite $i >/dev/null && (grep "#include <cmath>" $i >/dev/null || echo $i) | tee -a /tmp/missing_include.txt;
done < /tmp/gdal_list_files.txt


if test -s /tmp/missing_include.txt; then
    echo "FAIL: missing #include <cmath> in above listed files"
    ret_code=1
else
    echo "OK."
fi

rm -f /tmp/missing_include.txt
rm -f /tmp/gdal_list_files.txt

exit $ret_code