Hi,

On 2019-05-30 15:02:44 -0700, Andres Freund wrote:
> right now cpluspluscheck doesn't work with vpath builds. That's pretty
> annoying, because it does require cloning the git tree into a separate
> directory + doing configure there just to run cpluspluscheck.
> 
> Attached is a small patch allowing cpluspluscheck to run from different
> directories. I needs the src and build directories for that,
> unsurprisingly.
> 
> As that makes it more complicated to invoke, I added a makefile target
> (in the top level) for it.
> 
> Seems we could round the edges a good bit further than what's done in
> the attached (argument checking, for example, but also using the C++
> compiler from configure). But I think this would already be an
> improvement?

Ugh, sent the previous email too early.

Greetings,

Andres Freund
>From 647934bd150684ec97a51005b953ad6d8207ded5 Mon Sep 17 00:00:00 2001
From: Andres Freund <and...@anarazel.de>
Date: Thu, 30 May 2019 14:59:47 -0700
Subject: [PATCH] integrate cpluspluscheck a bit more

---
 GNUmakefile.in                     |  3 +++
 src/tools/pginclude/cpluspluscheck | 13 +++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/GNUmakefile.in b/GNUmakefile.in
index f4e31a7c5f1..6242ece2492 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -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
diff --git a/src/tools/pginclude/cpluspluscheck b/src/tools/pginclude/cpluspluscheck
index 3a771c48b62..02f5ca565fa 100755
--- a/src/tools/pginclude/cpluspluscheck
+++ b/src/tools/pginclude/cpluspluscheck
@@ -1,9 +1,15 @@
 #!/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 source directory, argument 2 the build directory
+# (they might be the same).
+#
 # No output if everything is OK, else compiler errors.
 
+srcdir="$1"
+builddir="$2"
+
 me=`basename $0`
 
 tmp=`mktemp -d /tmp/$me.XXXXXX`
@@ -22,6 +28,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.
 
+cd "$srcdir"
 for f in `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 \
@@ -36,5 +43,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
-- 
2.21.0.dirty

Reply via email to