Browse Source

Integrate cpluspluscheck into build system.

Previously cpluspluscheck wouldn't work in vpath builds, this commit
fixes that. To make it easier to invoke, there's a top-level
cpluspluscheck target.

Discussion: https://postgr.es/20190530220244.kiputcbl4gkl2oo6@alap3.anarazel.de
tags/REL_12_BETA2
Andres Freund 1 month ago
parent
commit
b1cd7ce23f
2 changed files with 26 additions and 3 deletions
  1. 3
    0
      GNUmakefile.in
  2. 23
    3
      src/tools/pginclude/cpluspluscheck

+ 3
- 0
GNUmakefile.in View File

@@ -128,4 +128,7 @@ distcheck: dist
128 128
 	rm -rf $(distdir) $(dummy)
129 129
 	@echo "Distribution integrity checks out."
130 130
 
131
+cpluspluscheck: submake-generated-headers
132
+	$(top_srcdir)/src/tools/pginclude/cpluspluscheck $(top_srcdir) $(abs_top_builddir)
133
+
131 134
 .PHONY: dist distdir distcheck docs install-docs world check-world install-world installcheck-world

+ 23
- 3
src/tools/pginclude/cpluspluscheck View File

@@ -1,9 +1,27 @@
1 1
 #!/bin/sh
2 2
 
3 3
 # Check all exported PostgreSQL include files for C++ compatibility.
4
-# Run this from the top-level source directory after performing a build.
4
+#
5
+# Argument 1 is the top-level source directory, argument 2 the
6
+# top-level build directory (they might be the same). If not set, they
7
+# default to the current directory.
8
+#
9
+# Needs to be run after all generated headers are created.
10
+#
5 11
 # No output if everything is OK, else compiler errors.
6 12
 
13
+if [ -z "$1" ];then
14
+    srcdir="."
15
+else
16
+    srcdir="$1"
17
+fi
18
+
19
+if [ -z "$2" ];then
20
+    builddir="$."
21
+else
22
+    builddir="$2"
23
+fi
24
+
7 25
 me=`basename $0`
8 26
 
9 27
 tmp=`mktemp -d /tmp/$me.XXXXXX`
@@ -22,7 +40,7 @@ trap 'rm -rf $tmp' 0 1 2 3 15
22 40
 # which itself contains C++ code and so won't compile with a C++
23 41
 # compiler under extern "C" linkage.
24 42
 
25
-for f in `find src/include src/interfaces/libpq/libpq-fe.h src/interfaces/libpq/libpq-events.h -name '*.h' -print | \
43
+for f in `cd "$srcdir" && find src/include src/interfaces/libpq/libpq-fe.h src/interfaces/libpq/libpq-events.h -name '*.h' -print | \
26 44
     grep -v -e ^src/include/port/ \
27 45
 	-e ^src/include/rusagestub.h -e ^src/include/regex/regerrs.h \
28 46
 	-e ^src/include/access/rmgrlist.h \
@@ -36,5 +54,7 @@ do
36 54
 	    echo '};'
37 55
 	} >$tmp/test.cpp
38 56
 
39
-	${CXX:-g++} -I . -I src/interfaces/libpq -I src/include -fsyntax-only -Wall -c $tmp/test.cpp
57
+	${CXX:-g++} -I $srcdir -I $srcdir/src/interfaces/libpq -I $srcdir/src/include \
58
+		    -I $builddir -I $builddir/src/interfaces/libpq -I $builddir/src/include \
59
+		    -fsyntax-only -Wall -c $tmp/test.cpp
40 60
 done

Loading…
Cancel
Save