Skip to content

Commit b9fac7c

Browse files
committed
build: replace the hand-written mrdocs.rnc with the one generated via --schemas
This guarantees the RELAX NG schema stays in sync with the C++ type definitions. Every CI run now validates all golden test XML files against a schema derived from the same reflection metadata that produces the XML.
1 parent 8ce59c1 commit b9fac7c

5 files changed

Lines changed: 22 additions & 956 deletions

File tree

CMakeLists.txt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -561,12 +561,19 @@ if (MRDOCS_BUILD_TESTS)
561561
message(FATAL_ERROR "Java is needed to run xml-lint")
562562
endif()
563563

564+
# Generate mrdocs.rnc via the --schemas option, then
565+
# convert it to a .rng for xmllint validation.
566+
add_custom_command(
567+
COMMAND mrdocs --schemas=${CMAKE_CURRENT_BINARY_DIR}
568+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mrdocs.rnc
569+
DEPENDS mrdocs
570+
COMMENT "Generating mrdocs.rnc from --schemas")
564571
add_custom_command(
565572
COMMAND ${Java_JAVA_EXECUTABLE} -jar ${CMAKE_CURRENT_SOURCE_DIR}/util/trang.jar
566-
${CMAKE_CURRENT_SOURCE_DIR}/mrdocs.rnc ${CMAKE_CURRENT_BINARY_DIR}/mrdocs.rng
567-
OUTPUT mrdocs.rng
568-
DEPENDS mrdocs.rnc)
569-
add_custom_target(mrdocs_rng ALL DEPENDS mrdocs.rng)
573+
${CMAKE_CURRENT_BINARY_DIR}/mrdocs.rnc ${CMAKE_CURRENT_BINARY_DIR}/mrdocs.rng
574+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mrdocs.rng
575+
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mrdocs.rnc)
576+
add_custom_target(mrdocs_rng ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mrdocs.rng)
570577

571578
file(GLOB_RECURSE XML_SOURCES CONFIGURE_DEPENDS test-files/golden-tests/*.xml)
572579
add_test(NAME xml-lint

0 commit comments

Comments
 (0)