]> granicus.if.org Git - postgresql/commitdiff
Integrate cpluspluscheck into build system.
authorAndres Freund <andres@anarazel.de>
Fri, 31 May 2019 19:36:17 +0000 (12:36 -0700)
committerAndres Freund <andres@anarazel.de>
Fri, 31 May 2019 19:36:17 +0000 (12:36 -0700)
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

GNUmakefile.in
src/tools/pginclude/cpluspluscheck

index f4e31a7c5f1f2ab114a77400c06f720c909a7838..6242ece2492117c1d3796086c2862a99f826a7ec 100644 (file)
@@ -128,4 +128,7 @@ distcheck: dist
        rm -rf $(distdir) $(dummy)
        @echo "Distribution integrity checks out."
 
+cpluspluscheck: submake-generated-headers
+       $(top_srcdir)/src/tools/pginclude/cpluspluscheck $(top_srcdir) $(abs_top_builddir)
+
 .PHONY: dist distdir distcheck docs install-docs world check-world install-world installcheck-world
index 3a771c48b62860c90d46c9ed555a430f9978b473..72a9d47677e00897e520be8daa717c9c04b6c56d 100755 (executable)
@@ -1,9 +1,27 @@
 #!/bin/sh
 
 # Check all exported PostgreSQL include files for C++ compatibility.
-# Run this from the top-level source directory after performing a build.
+#
+# Argument 1 is the top-level source directory, argument 2 the
+# top-level build directory (they might be the same). If not set, they
+# default to the current directory.
+#
+# Needs to be run after all generated headers are created.
+#
 # No output if everything is OK, else compiler errors.
 
+if [ -z "$1" ];then
+    srcdir="."
+else
+    srcdir="$1"
+fi
+
+if [ -z "$2" ];then
+    builddir="$."
+else
+    builddir="$2"
+fi
+
 me=`basename $0`
 
 tmp=`mktemp -d /tmp/$me.XXXXXX`
@@ -22,7 +40,7 @@ trap 'rm -rf $tmp' 0 1 2 3 15
 # which itself contains C++ code and so won't compile with a C++
 # compiler under extern "C" linkage.
 
-for f in `find src/include src/interfaces/libpq/libpq-fe.h src/interfaces/libpq/libpq-events.h -name '*.h' -print | \
+for f in `cd "$srcdir" && find src/include src/interfaces/libpq/libpq-fe.h src/interfaces/libpq/libpq-events.h -name '*.h' -print | \
     grep -v -e ^src/include/port/ \
        -e ^src/include/rusagestub.h -e ^src/include/regex/regerrs.h \
        -e ^src/include/access/rmgrlist.h \
@@ -36,5 +54,7 @@ do
            echo '};'
        } >$tmp/test.cpp
 
-       ${CXX:-g++} -I . -I src/interfaces/libpq -I src/include -fsyntax-only -Wall -c $tmp/test.cpp
+       ${CXX:-g++} -I $srcdir -I $srcdir/src/interfaces/libpq -I $srcdir/src/include \
+                   -I $builddir -I $builddir/src/interfaces/libpq -I $builddir/src/include \
+                   -fsyntax-only -Wall -c $tmp/test.cpp
 done