diff --git a/CMakeLists.txt b/CMakeLists.txt index 61a7fffad6..9c46cf2698 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ else() endif() option(TINT_BUILD_DOCS "Build documentation" ${TINT_BUILD_DOCS_DEFAULT}) +option(TINT_DOCS_WARN_AS_ERROR "When building documentation, treat warnings as errors" OFF) option(TINT_BUILD_SPV_READER "Build the SPIR-V input reader" ON) option(TINT_BUILD_WGSL_READER "Build the WGSL input reader" ON) option(TINT_BUILD_HLSL_WRITER "Build the HLSL output writer" ON) @@ -62,6 +63,7 @@ option(TINT_EMIT_COVERAGE "Emit code coverage information" OFF) option(TINT_CHECK_CHROMIUM_STYLE "Check for [chromium-style] issues during build" OFF) message(STATUS "Tint build docs: ${TINT_BUILD_DOCS}") +message(STATUS "Tint build docs with warn as error: ${TINT_DOCS_WARN_AS_ERROR}") message(STATUS "Tint build SPIR-V reader: ${TINT_BUILD_SPV_READER}") message(STATUS "Tint build WGSL reader: ${TINT_BUILD_WGSL_READER}") message(STATUS "Tint build HLSL writer: ${TINT_BUILD_HLSL_WRITER}") @@ -143,9 +145,15 @@ endif() if(${TINT_BUILD_DOCS}) find_package(Doxygen) if(DOXYGEN_FOUND) + set(DOXYGEN_WARN_AS_ERROR NO) + if(TINT_DOCS_WARN_AS_ERROR) + set(DOXYGEN_WARN_AS_ERROR YES) + endif() add_custom_target(tint-docs ALL COMMAND ${CMAKE_COMMAND} - -E env "DOXYGEN_OUTPUT_DIRECTORY=${CMAKE_BINARY_DIR}/docs" + -E env + "DOXYGEN_OUTPUT_DIRECTORY=${CMAKE_BINARY_DIR}/docs" + "DOXYGEN_WARN_AS_ERROR=${DOXYGEN_WARN_AS_ERROR}" ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Generating API documentation" diff --git a/Doxyfile b/Doxyfile index 2e1c7aa719..0fe2602ed9 100644 --- a/Doxyfile +++ b/Doxyfile @@ -757,7 +757,7 @@ WARN_NO_PARAMDOC = YES # a warning is encountered. # The default value is: NO. -WARN_AS_ERROR = NO +WARN_AS_ERROR = $(DOXYGEN_WARN_AS_ERROR) # The WARN_FORMAT tag determines the format of the warning messages that doxygen # can produce. The string should contain the $file, $line, and $text tags, which diff --git a/kokoro/linux/docker.sh b/kokoro/linux/docker.sh index df64536667..21e8d4fa90 100755 --- a/kokoro/linux/docker.sh +++ b/kokoro/linux/docker.sh @@ -86,6 +86,7 @@ if [ "$BUILD_SYSTEM" == "cmake" ]; then COMMON_CMAKE_FLAGS="" COMMON_CMAKE_FLAGS+=" -DCMAKE_BUILD_TYPE=${BUILD_TYPE}" + COMMON_CMAKE_FLAGS+=" -DTINT_DOCS_WARN_AS_ERROR=ON" if [ "$BUILD_TOOLCHAIN" == "clang" ]; then using clang-10.0.0 @@ -103,10 +104,21 @@ if [ "$BUILD_SYSTEM" == "cmake" ]; then cd ${BUILD_DIR} + status "Running Doxygen" + echo "NOTE: This will fail on first warning. Run with -DTINT_DOCS_WARN_AS_ERROR=OFF to see all warnings". + echo "" + show_cmds + # NOTE: If we upgrade Doxygen to a more recent version, we can set DOXYGEN_WARN_AS_ERROR to + # "FAIL_ON_WARNINGS" instead of "YES" in our CMakeLists.txt so see all warnings, and then + # fail. See https://www.doxygen.nl/manual/config.html#cfg_warn_as_error + cmake ${SRC_DIR} ${CMAKE_FLAGS} ${COMMON_CMAKE_FLAGS} + cmake --build . --target tint-docs + hide_cmds + status "Building tint" show_cmds cmake ${SRC_DIR} ${CMAKE_FLAGS} ${COMMON_CMAKE_FLAGS} - make --jobs=$(nproc) + cmake --build . -- --jobs=$(nproc) hide_cmds status "Running tint_unittests" @@ -122,7 +134,7 @@ if [ "$BUILD_SYSTEM" == "cmake" ]; then status "Checking _other.cc files also build" show_cmds cmake ${SRC_DIR} ${CMAKE_FLAGS} ${COMMON_CMAKE_FLAGS} -DTINT_BUILD_AS_OTHER_OS=1 - make --jobs=$(nproc) + cmake --build . -- --jobs=$(nproc) hide_cmds else status "Unsupported build system: $BUILD_SYSTEM"