Scripts: Three modes of warning printing.

WARN_MODE=early
print warnings at compilation stage

WARN_MODE=late
print warnings at build finish stage

WARN_MODE=both
print both at early and at later stages
This commit is contained in:
kevg 2016-11-20 22:17:35 +03:00 committed by Aleksey Midenkov
parent 303d72a0f4
commit b98f09fcbf
2 changed files with 21 additions and 5 deletions

View file

@ -1,7 +1,8 @@
#!/bin/bash
warn_path=$1
shift
warn_mode=$2
shift 2
warn_file="$warn_path/compile.warnings"
suppress_file="$warn_path/suppress.warnings"
@ -10,7 +11,8 @@ cmderr=$("$@" 2>&1 1>&3)
error=$?
if [[ -n "$cmderr" ]]; then
echo "$cmderr" >&2
[[ "$warn_mode" == "both" ]] &&
echo "$cmderr" >&2
[[ "$cmderr" =~ warning:(.+)$ ]] &&
echo -n "$cmderr" >> "$warn_file"
fi

View file

@ -1,6 +1,20 @@
IF (NOT DEFINED WITHOUT_REPRINT AND CMAKE_BUILD_TYPE MATCHES "Debug")
IF(NOT DEFINED WARN_MODE)
IF(CMAKE_BUILD_TYPE MATCHES "Debug")
SET(WARN_MODE "late")
ELSE()
SET(WARN_MODE "early")
ENDIF()
ENDIF()
IF(NOT WARN_MODE STREQUAL "early" AND
NOT WARN_MODE STREQUAL "late" AND
NOT WARN_MODE STREQUAL "both")
MESSAGE(FATAL_ERROR "Unknown WARN_MODE: expected 'early', 'late' or 'both'")
ENDIF()
IF(NOT WARN_MODE MATCHES "early")
SET_DIRECTORY_PROPERTIES(PROPERTIES RULE_LAUNCH_COMPILE
"bash ${CMAKE_SOURCE_DIR}/BUILD/capture_warnings.sh ${CMAKE_BINARY_DIR}")
"bash ${CMAKE_SOURCE_DIR}/BUILD/capture_warnings.sh ${CMAKE_BINARY_DIR} ${WARN_MODE}")
SET_DIRECTORY_PROPERTIES(PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
"${CMAKE_BINARY_DIR}/compile.warnings")
ADD_CUSTOM_TARGET(rm_compile.warnings ALL