v2.1-0003-headerscheck-Parallelize-by-writing-out-a-makef.patch

text/plain

Filename: v2.1-0003-headerscheck-Parallelize-by-writing-out-a-makef.patch
Type: text/plain
Part: 3
Message: Re: headerscheck ccache support

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v2-0003
Subject: headerscheck: Parallelize by writing out a makefile
File+
GNUmakefile.in 2 2
src/tools/pginclude/headerscheck 19 10
From 863b295a4be6304fe629082d8ae0a9ebf5c7d2eb Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Fri, 28 Nov 2025 12:03:05 +0100
Subject: [PATCH v2.1 3/3] headerscheck: Parallelize by writing out a makefile

---
 GNUmakefile.in                   |  4 ++--
 src/tools/pginclude/headerscheck | 29 +++++++++++++++++++----------
 2 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/GNUmakefile.in b/GNUmakefile.in
index cf6e759486e..eb36fd07f39 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -129,9 +129,9 @@ distcheck: dist
 	@echo "Distribution integrity checks out."
 
 headerscheck: submake-generated-headers
-	$(top_srcdir)/src/tools/pginclude/headerscheck $(top_srcdir) $(abs_top_builddir)
+	+$(top_srcdir)/src/tools/pginclude/headerscheck $(top_srcdir) $(abs_top_builddir)
 
 cpluspluscheck: submake-generated-headers
-	$(top_srcdir)/src/tools/pginclude/headerscheck --cplusplus $(top_srcdir) $(abs_top_builddir)
+	+$(top_srcdir)/src/tools/pginclude/headerscheck --cplusplus $(top_srcdir) $(abs_top_builddir)
 
 .PHONY: dist distcheck docs install-docs world check-world install-world installcheck-world headerscheck cpluspluscheck
diff --git a/src/tools/pginclude/headerscheck b/src/tools/pginclude/headerscheck
index 8caa6e4de12..3d119c0b3c6 100755
--- a/src/tools/pginclude/headerscheck
+++ b/src/tools/pginclude/headerscheck
@@ -82,6 +82,17 @@ trap "ret=$?; rm -rf $tmp; exit $ret" 0 1 2 3 15
 
 exit_status=0
 
+cat >"$tmp/Makefile" <<EOF
+all:
+
+EXTRAINCLUDES = $perl_includespec $python_includespec -I $builddir/src/interfaces/ecpg/include -I $srcdir/src/interfaces/ecpg/include -I $builddir/src/backend/parser/ -I $builddir/src/backend/utils/adt/
+
+%.o: %.$ext
+	$COMPILER $COMPILER_FLAGS -I $builddir -I $srcdir -I $builddir/src/include -I $srcdir/src/include -I $builddir/src/interfaces/libpq -I $srcdir/src/interfaces/libpq \$(EXTRAINCLUDES) \$(EXTRAFLAGS) -c \$< -o \$@
+
+ALL_FILES =
+EOF
+
 # Scan all of src/ and contrib/ for header files.
 for f in `cd "$srcdir" && find src contrib -name '*.h' -print`
 do
@@ -255,16 +266,14 @@ do
 		EXTRAINCLUDES="" ;;
 	esac
 
-	# Run the test.
-	if ! $COMPILER $COMPILER_FLAGS -I $builddir -I $srcdir \
-		-I $builddir/src/include -I $srcdir/src/include \
-		-I $builddir/src/interfaces/libpq -I $srcdir/src/interfaces/libpq \
-		$EXTRAINCLUDES $EXTRAFLAGS -c "$tmp/$test_file_name.$ext" -o "$tmp/$test_file_name.o"
-	then
-		exit_status=1
-	fi
-
-	rm -f "$tmp/$test_file_name.$ext" "$tmp/$test_file_name.o"
+	printf 'ALL_FILES += %s\n' "$test_file_name.$ext" >> "$tmp/Makefile"
 done
 
+cat >>"$tmp/Makefile" <<EOF
+
+all: \$(ALL_FILES:%.$ext=%.o)
+EOF
+
+make -C "$tmp" -k -s all
+
 exit $exit_status
-- 
2.52.0