Commit 7773fb387517c2738f6e7982d10f2e16e6fa92f0

Authored by m-holger
1 parent 7b4ecb60

Add script to validate private header files in isolation

Introduce `check-private-headers` script to ensure all private headers compile independently. Update `build-linux` script to include this new validation step. Adjust release notes to reflect the additional header checks.

Addresses the issue raised in #1465
build-scripts/build-linux
@@ -20,6 +20,9 @@ done @@ -20,6 +20,9 @@ done
20 cd .. 20 cd ..
21 # Perform additional tests on header files. 21 # Perform additional tests on header files.
22 ./build-scripts/check-headers 22 ./build-scripts/check-headers
  23 +# Perform additional tests on private header files.
  24 +./build-scripts/check-private-headers
  25 +# Create distribution
23 export TMPDIR=$PWD/dist-tmp 26 export TMPDIR=$PWD/dist-tmp
24 rm -rf $TMPDIR 27 rm -rf $TMPDIR
25 ./make_dist --ci 28 ./make_dist --ci
build-scripts/check-private-headers 0 → 100755
  1 +#!/bin/bash
  2 +set -eo pipefail
  3 +cd "$(dirname $0)/.."
  4 +
  5 +trap "rm -f a.cc" EXIT
  6 +declare -a pheaders
  7 +cd libqpdf
  8 +for i in qpdf/*.hh; do
  9 + if [[ ! $i =~ .*auto_.* ]] && ! grep -q >/dev/null 2>&1 QPDFOBJECT_OLD_HH $i; then
  10 + pheaders+=($i)
  11 + fi
  12 +done
  13 +cd ..
  14 +# Make sure each header file can be included in isolation and that the
  15 +# result can be compiled with the version of the C++ standard used by the qpdf project, currently C++-20.
  16 +declare -a perrors
  17 +for i in "${pheaders[@]}"; do
  18 + rm -f a.cc
  19 + cat > a.cc <<EOF
  20 +#include "$i"
  21 +int main() { return 0; }
  22 +EOF
  23 + echo "Checking $i"
  24 + if ! g++ -std=c++20 -pedantic-errors -c -Iinclude -Ilibqpdf -Ibuild/libqpdf a.cc -o /dev/null; then
  25 + perrors+=("$i doesn't compile")
  26 + fi
  27 +done
  28 +if [[ ${#perrors[@]} -gt 0 ]]; then
  29 + echo ""
  30 + echo "Some header files had errors"
  31 + for i in "${perrors[@]}"; do
  32 + echo "$i"
  33 + done
  34 + exit 2
  35 +fi
manual/release-notes.rst
1 .. _ticket: https://issues.qpdf.org 1 .. _ticket: https://issues.qpdf.org
2 .. _shared null: https://wiki.qpdf.org/PDF-null-objects-vs-qpdf-null-objects 2 .. _shared null: https://wiki.qpdf.org/PDF-null-objects-vs-qpdf-null-objects
3 3
4 -  
5 .. _release-notes: 4 .. _release-notes:
6 5
7 Release Notes 6 Release Notes
@@ -79,8 +78,8 @@ more detail. @@ -79,8 +78,8 @@ more detail.
79 78
80 - Build fixes 79 - Build fixes
81 80
82 - - Attempt to detect if any > C++-17 changes snuck into any public  
83 - headers. 81 + - Attempt to detect if any > C++17 changes snuck into any public
  82 + headers and check all private headers compile stand-alone.
84 83
85 - CLI Enhancements 84 - CLI Enhancements
86 85