-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathdetect_missing_include.sh
executable file
·83 lines (64 loc) · 2.24 KB
/
detect_missing_include.sh
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
#!/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 <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