CMake+CI: Colorize our compiler output.
As described at https://medium.com/@alasher/colored-c-compiler-output-with-ninja-clang-gcc-10bfe7f2b949 both Clang and gcc generate colorized output when they detect a terminal, but not for piped output, which is the case when using Ninja. Add an ENABLE_COMPILER_COLOR_DIAGNOSTICS CMake option, and set it to "ON" when we're using Ninja. In the merge-req:ubuntu-gcc-ctest and merge-req:ubuntu-clang-other-tests GitLab CI jobs, generate colorized HTML report artifacts using ansi2html.
This commit is contained in:
parent
cf46f0d747
commit
1dc50f7433
|
@ -18,6 +18,8 @@ variables:
|
|||
GIT_DEPTH: "1"
|
||||
GIT_FETCH_EXTRA_FLAGS: "--depth=5000"
|
||||
CCACHE_DIR: "${CI_PROJECT_DIR}/ccache"
|
||||
# Enable color output in CMake, Ninja, and other tools. https://bixense.com/clicolors/
|
||||
CLICOLOR_FORCE: 1
|
||||
|
||||
.build:
|
||||
stage: build
|
||||
|
@ -342,10 +344,14 @@ merge-req:ubuntu-gcc-ctest:
|
|||
script:
|
||||
# build-ubuntu puts us in `build`.
|
||||
- CC=gcc CXX=g++ cmake -DENABLE_EXTRA_COMPILER_WARNINGS=on -DCMAKE_EXPORT_COMPILE_COMMANDS=on -DENABLE_CCACHE=ON -G Ninja ..
|
||||
- ninja
|
||||
- script --command ninja --flush --quiet --return ../gcc_report.txt
|
||||
- ansi2html < ../gcc_report.txt > ../gcc_report.html
|
||||
- ninja test-programs
|
||||
- chown -R user .
|
||||
- su user -c "ctest --parallel $(getconf _NPROCESSORS_ONLN) --force-new-ctest-process --verbose"
|
||||
artifacts:
|
||||
paths:
|
||||
- gcc_report.html
|
||||
|
||||
merge-req:ubuntu-clang-other-tests:
|
||||
extends: clang-11
|
||||
|
@ -363,14 +369,16 @@ merge-req:ubuntu-clang-other-tests:
|
|||
- if [[ -s "cppcheck_report.xml" ]]; then cppcheck-htmlreport --file cppcheck_report.xml --report-dir . ; fi
|
||||
- cd build
|
||||
- cmake -DENABLE_EXTRA_COMPILER_WARNINGS=on -DENABLE_CHECKHF_CONFLICT=on -DCMAKE_EXPORT_COMPILE_COMMANDS=on -DENABLE_CCACHE=ON -G Ninja ..
|
||||
- ninja
|
||||
- script --command ninja --flush --quiet --return ../clang_report.txt
|
||||
- ansi2html < ../clang_report.txt > ../clang_report.html
|
||||
- ./run/tshark -v
|
||||
- sh -c '[ ! -e ../tools/validate-clang-check.sh ] || ../tools/validate-clang-check.sh'
|
||||
- ninja checkAPI
|
||||
artifacts:
|
||||
paths:
|
||||
- cppcheck_report.xml
|
||||
- clang_report.html
|
||||
- cppcheck_report.html
|
||||
- cppcheck_report.xml
|
||||
- item_calls_check.txt
|
||||
- tfs_check.txt
|
||||
|
||||
|
|
|
@ -796,6 +796,18 @@ else() # ! MSVC
|
|||
)
|
||||
endif()
|
||||
|
||||
if(ENABLE_COMPILER_COLOR_DIAGNOSTICS)
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
set(WIRESHARK_COMMON_FLAGS ${WIRESHARK_COMMON_FLAGS}
|
||||
-fcolor-diagnostics
|
||||
)
|
||||
elseif(CMAKE_C_COMPILER_ID MATCHES "GNU")
|
||||
set(WIRESHARK_COMMON_FLAGS ${WIRESHARK_COMMON_FLAGS}
|
||||
-fdiagnostics-color=always
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_definitions(
|
||||
-DG_DISABLE_DEPRECATED
|
||||
-DG_DISABLE_SINGLE_INCLUDES
|
||||
|
|
|
@ -55,6 +55,12 @@ option(ENABLE_FUZZER "Enable libFuzzer instrumentation for use with fuzzshark" O
|
|||
option(ENABLE_CHECKHF_CONFLICT "Enable hf conflict check for debugging (start-up may be slower)" OFF)
|
||||
option(ENABLE_CCACHE "Speed up compiling and linking using ccache if possible" OFF)
|
||||
|
||||
if(CMAKE_GENERATOR STREQUAL "Ninja")
|
||||
option(ENABLE_COMPILER_COLOR_DIAGNOSTICS "Always enable the compiler's color diagnostic output" ON)
|
||||
else()
|
||||
option(ENABLE_COMPILER_COLOR_DIAGNOSTICS "Always enable the compiler's color diagnostic output" OFF)
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
option(ENABLE_LTO "Improves performance using Link time Optimization" ON)
|
||||
else()
|
||||
|
|
Loading…
Reference in New Issue