fix(build): keep counter instrumentation out of the installed release library
The linux-release preset inherited PLOT_BUILD_TESTS=ON, so the release build compiled the pyramid cover/merge and ring upload/wait/slot counters into libplot_core.a and cmake --install shipped them. Set PLOT_BUILD_TESTS=OFF in the preset; the suite keeps running in linux-debug and linux-asan, which are unchanged. Also pin the two header properties the plan calls Global Constraints and that nothing guarded: every header under include/plot/ compiles standalone, and include/plot/plot.hpp includes every public one. tests/CMakeLists.txt globs the headers at configure time (CONFIGURE_DEPENDS) and generates one TU per header plus an umbrella TU that constructs Plot, Renderer, data::StreamSeries and input::Controller; a ctest entry builds the header TUs and runs the umbrella, and cmake/plot_umbrella_check.cmake fails configure and ctest when a public header is missing from the umbrella.
This commit is contained in:
1 parent
0972903d27
commit
f363523195
3 files changed
+149
No files matched your search
@@ -0,0 +1,76 @@
|
||||
# Keeps include/plot/plot.hpp honest against the plan's Global Constraints:
|
||||
# every public header under include/plot/ must be included by the umbrella, and
|
||||
# every <plot/...> the umbrella names must be a file that actually exists.
|
||||
#
|
||||
# "Public" is everything the recursive glob finds except the macro-gated
|
||||
# */detail/ instrumentation, which is documented as not part of the surface and
|
||||
# deliberately stays out of the umbrella.
|
||||
#
|
||||
# Runs twice: tests/CMakeLists.txt includes it at configure time (so a header
|
||||
# added without its umbrella line stops the configure rather than the run), and
|
||||
# ctest runs it again as `plot_umbrella_covers_public_headers` via `cmake -P`.
|
||||
# Both read the same file so a header the build sees is a header this checks --
|
||||
# there is no hand-maintained list to fall out of date.
|
||||
#
|
||||
# Inputs (set by the including scope, or passed with -D in script mode):
|
||||
# PLOT_INCLUDE_DIR the installed-header root, e.g. <source>/include
|
||||
# PLOT_UMBRELLA the umbrella header, e.g. <PLOT_INCLUDE_DIR>/plot/plot.hpp
|
||||
|
||||
if(NOT DEFINED PLOT_INCLUDE_DIR)
|
||||
message(FATAL_ERROR "plot: PLOT_INCLUDE_DIR is not set")
|
||||
endif()
|
||||
if(NOT DEFINED PLOT_UMBRELLA)
|
||||
set(PLOT_UMBRELLA "${PLOT_INCLUDE_DIR}/plot/plot.hpp")
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE plot_umbrella_headers
|
||||
RELATIVE "${PLOT_INCLUDE_DIR}"
|
||||
"${PLOT_INCLUDE_DIR}/plot/*.hpp")
|
||||
list(SORT plot_umbrella_headers)
|
||||
file(READ "${PLOT_UMBRELLA}" plot_umbrella_text)
|
||||
|
||||
# The umbrella is a public header too, but it cannot include itself.
|
||||
file(RELATIVE_PATH plot_umbrella_relative "${PLOT_INCLUDE_DIR}" "${PLOT_UMBRELLA}")
|
||||
|
||||
# Every other public header is named by the umbrella.
|
||||
set(plot_umbrella_missing "")
|
||||
foreach(header IN LISTS plot_umbrella_headers)
|
||||
if(header MATCHES "/detail/" OR header STREQUAL plot_umbrella_relative)
|
||||
continue()
|
||||
endif()
|
||||
string(FIND "${plot_umbrella_text}" "#include <${header}>" plot_umbrella_pos)
|
||||
if(plot_umbrella_pos EQUAL -1)
|
||||
list(APPEND plot_umbrella_missing "${header}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(plot_umbrella_missing)
|
||||
string(REPLACE ";" "\n " plot_umbrella_missing_text "${plot_umbrella_missing}")
|
||||
message(FATAL_ERROR
|
||||
"plot: ${PLOT_UMBRELLA} does not include every public header under "
|
||||
"include/plot/ -- missing:\n ${plot_umbrella_missing_text}\n"
|
||||
"Add each as `#include <plot/...>`, or move it under a */detail/ directory "
|
||||
"if it is implementation-only and not part of the public surface.")
|
||||
endif()
|
||||
|
||||
# And every header the umbrella names is a file that exists (a rename or a
|
||||
# deleted header cannot leave a dangling include behind).
|
||||
string(REGEX MATCHALL "#include <plot/[^>]+>" plot_umbrella_includes "${plot_umbrella_text}")
|
||||
set(plot_umbrella_dangling "")
|
||||
foreach(plot_umbrella_include IN LISTS plot_umbrella_includes)
|
||||
string(REGEX REPLACE "#include <([^>]+)>" "\\1" plot_umbrella_header "${plot_umbrella_include}")
|
||||
if(NOT EXISTS "${PLOT_INCLUDE_DIR}/${plot_umbrella_header}")
|
||||
list(APPEND plot_umbrella_dangling "${plot_umbrella_header}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(plot_umbrella_dangling)
|
||||
string(REPLACE ";" "\n " plot_umbrella_dangling_text "${plot_umbrella_dangling}")
|
||||
message(FATAL_ERROR
|
||||
"plot: ${PLOT_UMBRELLA} includes headers that do not exist under "
|
||||
"include/plot/:\n ${plot_umbrella_dangling_text}")
|
||||
endif()
|
||||
|
||||
list(LENGTH plot_umbrella_headers plot_umbrella_header_count)
|
||||
message(STATUS
|
||||
"plot: umbrella covers every public header (${plot_umbrella_header_count} headers globbed)")
|
||||
Reference in new issue
Block a user