File: detect_missing_include.sh

package info (click to toggle)
gdal 3.6.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 89,664 kB
  • sloc: cpp: 1,136,033; ansic: 197,355; python: 35,910; java: 5,511; xml: 4,011; sh: 3,950; cs: 2,443; yacc: 1,047; makefile: 288
file content (54 lines) | stat: -rwxr-xr-x 1,427 bytes parent folder | download
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
#!/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

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

exit $ret_code