File: check_include_file.sh

package info (click to toggle)
cppad 2026.00.00.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,584 kB
  • sloc: cpp: 112,960; sh: 6,146; ansic: 179; python: 71; sed: 12; makefile: 10
file content (99 lines) | stat: -rwxr-xr-x 3,020 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
98
99
#! /bin/bash -e
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <bradbell@seanet.com>
# SPDX-FileContributor: 2003-24 Bradley M. Bell
# ----------------------------------------------------------------------------
if [ ! -e "bin/check_include_file.sh" ]
then
   msg="must be executed from its parent directory"
   echo "bin/check_include_file.sh: $msg"
   exit 1
fi
#
# $grep, sed
source bin/grep_and_sed.sh
# -----------------------------------------------------------------------------
#
echo "Checking difference between C++ include directives and file names."
echo "-------------------------------------------------------------------"
if [ -e check_include_file.1.$$ ]
then
   echo "bin/check_include_file.sh: unexpected check_include_file.1.$$"
   exit 1
fi
list=`git ls-files | $sed -n \
   -e '/\.cpp$/p' \
   -e '/\.hpp$/p'`
for file in $list
do
   $sed -n $file \
      -e '/^# *include *<cppad\/cg\//d' \
      -e '/^# *include *<cppad\//p' \
      >> check_include_file.1.$$
done
#
cat check_include_file.1.$$ | \
   $sed -e 's%[^<]*<%%'  -e 's%>.*$%%' | \
   sort -u > check_include_file.2.$$
#
# The following files should never be included:
#  cppad/local/var_op/prototype_op.hpp
#  cppad/local/optimize/define_prototype.hpp
# All other files should.
#
# The files cppad/configure.hpp and cppad/local/is_pod.hpp
# are not in git repository (they are built during configuration)
git ls-files | $sed -n -e '/include\/cppad\/.*\.hpp$/p' | \
   $sed \
      -e '1,1s|^|include/cppad/configure.hpp\n|' \
      -e '1,1s|^|include/cppad/local/is_pod.hpp\n|' \
      -e '/include\/cppad\/local\/var_op\/prototype_op.hpp/d' \
      -e '/include\/cppad\/example\/eigen_plugin.hpp/d' | \
   $sed -e 's|^include/||' | \
   sort -u > check_include_file.3.$$
#
different='no'
if ! diff check_include_file.2.$$ check_include_file.3.$$ > /dev/null
then
   found='no'
   different='yes'
   for file in `cat check_include_file.2.$$`
   do
      if ! $grep "$file" check_include_file.3.$$ > /dev/null
      then
         found='yes'
         echo "The file include/$file is unknown to git."
         echo 'Perhaps it needs to be added with the command'
         echo "    git add include/$file"
      fi
   done
   for file in `cat check_include_file.3.$$`
   do
      if ! $grep "$file" check_include_file.2.$$ > /dev/null
      then
         found='yes'
         echo "The included $file is no longer included."
         echo 'Perhaps it needs to be git deleted ?'
      fi
   done
   if [ "$found" == 'no' ]
   then
      echo 'bin/check_include_file.sh: Cannot find reason for difference'
      echo 'Improve this script.'
      exit 1
   fi
fi
for index in 1 2 3
do
   rm check_include_file.$index.$$
done
#
echo "-------------------------------------------------------------------"
if [ $different = "yes" ]
then
   echo "Error: nothing should be between the two dashed lines above"
   exit 1
else
   echo "Ok: nothing is between the two dashed lines above"
   exit 0
fi