|
40 | 40 |
|
41 | 41 | EXTRA_DIST = libhttpserver.pc.in $(DX_CONFIG) scripts/extract-release-notes.sh scripts/validate-version.sh \ |
42 | 42 | test/headers/consumer_direct.cpp test/headers/consumer_detail.cpp test/headers/consumer_umbrella.cpp \ |
43 | | - test/headers/consumer_post_umbrella.cpp |
| 43 | + test/headers/consumer_post_umbrella.cpp \ |
| 44 | + test/headers/consumer_umbrella_no_backend.cpp |
44 | 45 |
|
45 | 46 | # --------------------------------------------------------------------------- |
46 | 47 | # Header-hygiene checks (TASK-002) |
@@ -163,9 +164,83 @@ check-install-layout: |
163 | 164 | @rm -rf $(CHECK_INSTALL_STAGE) |
164 | 165 | @echo " PASS: staged install layout is clean" |
165 | 166 |
|
166 | | -check-local: check-headers check-install-layout |
| 167 | +# --------------------------------------------------------------------------- |
| 168 | +# Header-hygiene preprocessor gate (TASK-007). |
| 169 | +# |
| 170 | +# This is the preprocessor-grep half of the TASK-007 enforcement (the |
| 171 | +# compile-time half lives as `header_hygiene` in test/Makefile.am). |
| 172 | +# |
| 173 | +# Procedure: |
| 174 | +# 1. Stage `make install DESTDIR=$(CHECK_HYGIENE_STAGE)` to get a |
| 175 | +# pristine public include tree -- exactly what packagers and |
| 176 | +# downstream consumers see. |
| 177 | +# 2. Preprocess test/headers/consumer_umbrella_no_backend.cpp using |
| 178 | +# ONLY -I$(CHECK_HYGIENE_STAGE)$(includedir) plus $(CPPFLAGS) (so |
| 179 | +# e.g. /opt/homebrew/include is on the search path -- the grep |
| 180 | +# below NEEDS to resolve <microhttpd.h> if the umbrella pulls it |
| 181 | +# in, otherwise we couldn't detect the leak). |
| 182 | +# 3. Grep the cpp output for `# <line> "<file>"` line markers that |
| 183 | +# name any forbidden backend header. The line-marker filter |
| 184 | +# avoids false positives from substrings in code or comments. |
| 185 | +# |
| 186 | +# HEADER_HYGIENE_STRICT controls whether a leak is fatal: |
| 187 | +# - "no" (default until M5): leaks are reported as EXPECTED-FAIL |
| 188 | +# and exit 0. This keeps `make check` green during M2-M5 |
| 189 | +# while making M2-M5 progress visible in CI logs. |
| 190 | +# - "yes" (TASK-020 close-out): leaks are fatal. Set this from the |
| 191 | +# command line (`make check-hygiene HEADER_HYGIENE_STRICT=yes`) |
| 192 | +# or flip the default below. |
| 193 | +# |
| 194 | +# Cross-reference: keep HEADER_HYGIENE_FORBIDDEN in sync with the |
| 195 | +# #ifdef ladder in test/unit/header_hygiene_test.cpp. |
| 196 | +# --------------------------------------------------------------------------- |
| 197 | + |
| 198 | +HEADER_HYGIENE_FORBIDDEN = microhttpd\.h|pthread\.h|gnutls/gnutls\.h|sys/socket\.h|sys/uio\.h |
| 199 | +CHECK_HYGIENE_STAGE = $(abs_top_builddir)/.hygiene-stage |
| 200 | +CHECK_HYGIENE_CXX = $(CXX) -std=c++20 -E -I$(CHECK_HYGIENE_STAGE)$(includedir) $(CPPFLAGS) |
| 201 | +HEADER_HYGIENE_STRICT ?= no |
| 202 | + |
| 203 | +check-hygiene: |
| 204 | + @echo "=== check-hygiene: <httpserver.hpp> must not transitively include backend headers ===" |
| 205 | + @rm -rf $(CHECK_HYGIENE_STAGE) |
| 206 | + @$(MAKE) $(AM_MAKEFLAGS) install DESTDIR=$(CHECK_HYGIENE_STAGE) >check-hygiene-install.log 2>&1 || { \ |
| 207 | + echo "FAIL: staged install failed"; cat check-hygiene-install.log; \ |
| 208 | + rm -f check-hygiene-install.log; rm -rf $(CHECK_HYGIENE_STAGE); exit 1; } |
| 209 | + @rm -f check-hygiene-install.log |
| 210 | + @status=0; \ |
| 211 | + if ! $(CHECK_HYGIENE_CXX) $(top_srcdir)/test/headers/consumer_umbrella_no_backend.cpp >check-hygiene.i 2>check-hygiene.err; then \ |
| 212 | + if test "$(HEADER_HYGIENE_STRICT)" = "yes"; then \ |
| 213 | + echo "FAIL: preprocessor failed"; cat check-hygiene.err; \ |
| 214 | + status=1; \ |
| 215 | + else \ |
| 216 | + echo "EXPECTED-FAIL (informational until M5): preprocessor failed against staged install."; \ |
| 217 | + echo " This is expected while M2-M5 are in flight (e.g. webserver.hpp still"; \ |
| 218 | + echo " references private detail headers that aren't shipped)."; \ |
| 219 | + echo " Tail of preprocessor diagnostics:"; \ |
| 220 | + sed 's/^/ /' check-hygiene.err | tail -10; \ |
| 221 | + fi; \ |
| 222 | + else \ |
| 223 | + leaks=`grep -hE '^# [0-9]+ "[^"]*($(HEADER_HYGIENE_FORBIDDEN))"' check-hygiene.i | awk '{print $$3}' | sort -u`; \ |
| 224 | + if test -n "$$leaks"; then \ |
| 225 | + if test "$(HEADER_HYGIENE_STRICT)" = "yes"; then \ |
| 226 | + echo "FAIL: forbidden headers leaked through <httpserver.hpp>:"; \ |
| 227 | + echo "$$leaks"; \ |
| 228 | + status=1; \ |
| 229 | + else \ |
| 230 | + echo "EXPECTED-FAIL (informational until M5): forbidden headers currently leak through <httpserver.hpp>:"; \ |
| 231 | + echo "$$leaks"; \ |
| 232 | + fi; \ |
| 233 | + else \ |
| 234 | + echo " PASS: no forbidden headers reached the consumer TU"; \ |
| 235 | + fi; \ |
| 236 | + fi; \ |
| 237 | + rm -f check-hygiene.i check-hygiene.err; \ |
| 238 | + rm -rf $(CHECK_HYGIENE_STAGE); \ |
| 239 | + exit $$status |
| 240 | + |
| 241 | +check-local: check-headers check-install-layout check-hygiene |
167 | 242 |
|
168 | | -.PHONY: check-headers check-install-layout |
| 243 | +.PHONY: check-headers check-install-layout check-hygiene |
169 | 244 |
|
170 | 245 | MOSTLYCLEANFILES = $(DX_CLEANFILES) *.gcda *.gcno *.gcov |
171 | 246 | DISTCLEANFILES = DIST_REVISION |
|
0 commit comments