|
1 | 1 | #!/bin/sh
|
2 | 2 |
|
3 |
| -# Check all include files in or below the current directory for C++ |
4 |
| -# compatibility. Typically, run this in PostgreSQL's src/include/ directory. |
| 3 | +# Check all exported PostgreSQL include files for C++ compatibility. |
| 4 | +# Run this from the top-level source directory after performing a build. |
5 | 5 | # No output if everything is OK, else compiler errors.
|
6 | 6 |
|
7 |
| -set -e |
8 |
| - |
9 | 7 | me=`basename $0`
|
10 | 8 |
|
11 |
| -trap 'rm -rf $tmp' 0 1 2 3 15 |
12 | 9 | tmp=`mktemp -d /tmp/$me.XXXXXX`
|
13 | 10 |
|
14 |
| -{ |
15 |
| -echo ' extern "C" {' |
16 |
| -echo '#include "postgres.h"' |
| 11 | +trap 'rm -rf $tmp' 0 1 2 3 15 |
17 | 12 |
|
18 |
| -# Omit port/, because it's platform specific, and c.h includes the relevant |
19 |
| -# file anyway. |
20 |
| -# Omit regex/ and snowball/, because those files came from elsewhere, and |
21 |
| -# they would need extra work if someone cared to fix them. |
22 |
| -# gram.h will be included by ./parser/gramparse.h. |
23 |
| -# kwlist.h is not meant to be included without having defined PG_KEYWORD. |
24 |
| -# rusagestub.h will be included by ./utils/pg_rusage.h if necessary. |
25 |
| -for file in `find . \( -name port -prune -o -name regex -prune -o -name snowball -prune \) -o -name '*.h' -not -name gram.h -not -name kwlist.h -not -name rusagestub.h -print`; do |
26 |
| - f=`echo $file | sed 's,^\./,,'` |
27 |
| - echo "#include \"$f\"" |
| 13 | +# Omit src/include/port/, because it's platform specific, and c.h includes |
| 14 | +# the relevant file anyway. |
| 15 | +# rusagestub.h is also platform-specific, and will be included by |
| 16 | +# utils/pg_rusage.h if necessary. |
| 17 | +# regex/regerrs.h is not meant to be included standalone. |
| 18 | +# parser/gram.h will be included by parser/gramparse.h. |
| 19 | +# parser/kwlist.h is not meant to be included standalone. |
| 20 | + |
| 21 | +for f in `find src/include src/interfaces/libpq/libpq-fe.h src/interfaces/libpq/libpq-events.h -name '*.h' -print | \ |
| 22 | + grep -v -e ^src/include/port/ \ |
| 23 | + -e ^src/include/rusagestub.h -e ^src/include/regex/regerrs.h \ |
| 24 | + -e ^src/include/parser/gram.h -e ^src/include/parser/kwlist.h` |
| 25 | +do |
| 26 | + { |
| 27 | + echo ' extern "C" {' |
| 28 | + echo '#include "postgres.h"' |
| 29 | + echo "#include \"$f\"" |
| 30 | + echo '};' |
| 31 | + } >$tmp/test.cpp |
| 32 | + |
| 33 | + # -fno-operator-names omits the definition of bitand and bitor, which |
| 34 | + # collide with varbit.h. Could be fixed, if one were so inclined. |
| 35 | + ${CXX:-g++} -I . -I src/include -fsyntax-only -fno-operator-names -Wall -c $tmp/test.cpp |
28 | 36 | done
|
29 |
| - |
30 |
| -echo '};' |
31 |
| -} >$tmp/test.cpp |
32 |
| - |
33 |
| -# -fno-operator-names omits the definition of bitand and bitor, which would |
34 |
| -# collide with varbit.h. Could be fixed, if one were so inclined. |
35 |
| -${CXX:-g++} -I. -fsyntax-only -fno-operator-names -Wall -c $tmp/test.cpp |
|
0 commit comments