Skip to content

Commit

Permalink
[sonar-cloud] publish gcov reports
Browse files Browse the repository at this point in the history
  • Loading branch information
Raffaello committed May 12, 2020
1 parent 1a08c26 commit bc01dfa
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
4 changes: 3 additions & 1 deletion azure-pipelines/templates/sonarcloud-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ jobs:
- script: ctest -C ${{ parameters.build_type }} -V
displayName: cmake test (ctest)
workingDirectory: build

- bash: llvm-cov gcov -f -b -u $(find . -name *.gcda)
displayName: collect coverage data
workingDirectory: build
- task: SonarCloudAnalyze@1
- task: SonarCloudPublish@1
inputs:
Expand Down
36 changes: 21 additions & 15 deletions sdl2-vga-terminal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,15 @@ if (BUILD_SHARED_LIBS)
unset(LIB_VER)
endif()

### TODO include GCC/CLang sanitizers [refactor the blocks belows]
### BODY: make valgrind test to be compiled in UNIX systems
### so they can be tested with the sanitizer too and not just with valgrind.

######################## add compiler options ################################
if(CMAKE_CXX_COMPILER_ID MATCHES "^MSVC")
# @see https://docs.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-by-category?view=vs-2019

target_compile_options(vga-terminal-static PRIVATE /W4 /WX
target_compile_options(vga-terminal-static PUBLIC /W4 /WX
$<$<CONFIG:DEBUG>:/Od /GR /GS /Gs /guard:cf /RTC1c /D_ALLOW_RTCc_IN_STL>
$<$<CONFIG:RELEASE>:/O2 /Ot /GA /GL /Gw>
)
Expand All @@ -160,7 +164,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "^MSVC")
# )
#endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "^GNU")
target_compile_options(vga-terminal-static PRIVATE -Wall -Wextra -pedantic -fPIC
target_compile_options(vga-terminal-static PUBLIC -Wall -Wextra -pedantic -fPIC
$<$<CONFIG:DEBUG>:
-O0;-D_GLIBCXX_DEBUG;-D_GLIBCXX_ASSERTIONS;-fexceptions;
-W; -Wshadow; -Wunused-variable;
Expand Down Expand Up @@ -189,40 +193,42 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang")
-Watomic-implicit-seq-cst -Watomic-properties -Wbad-function-cast -Wbinary-literal
-fPIC
$<$<CONFIG:DEBUG>:
-g; -c --coverage; -fprofile-arcs; -ftest-coverage;
-g;
>
$<$<CONFIG:RELEASE>:
-O2;
>
) #-Weverything #-Werror
target_link_options(vga-terminal-static INTERFACE $<$<CONFIG:DEBUG>:-fprofile-arcs; -ftest-coverage; --coverage;>)


### This if Clang is shipped with VS2019 CE
if (WIN32)
set(LINK_SUBSYS_WIN /subsystem:windows)
message(STATUS ${LINK_SUBSYS_WIN})
target_link_options(vga-terminal-static INTERFACE ${LINK_SUBSYS_WIN})
elseif()
target_compile_options(vga-terminal-static PRIVATE
elseif(UNIX)
#target_compile_options(vga-terminal-static PUBLIC -fprofile-instr-generate -fcoverage-mapping)
target_compile_options(vga-terminal-static INTERFACE
$<$<CONFIG:DEBUG>:
-flto; -fsanitize=address; -fsanitize=thread; -fsanitize=memory; -fsanitize=undefined; -fsanitize=dataflow;
-fsanitize=cfi; -fsanitize=safe-stack;
#-flto; -fsanitize=address; -fsanitize=thread; -fsanitize=memory; -fsanitize=undefined; -fsanitize=dataflow;
#-fsanitize=cfi; -fsanitize=safe-stack;
#-fprofile-instr-generate; -fcoverage-mapping;
-c -ftest-coverage;
>
$<$<CONFIG:RELEASE>:
>
)
target_compile_options(vga-terminal-static INTERFACE
$<$<CONFIG:DEBUG>:
-fsanitize=address; -fsanitize=thread; -fsanitize=memory; -fsanitize=undefined; -fsanitize=dataflow;
-fsanitize=cfi; -fsanitize=safe-stack;
>
)
#target_link_options(vga-terminal-static PUBLIC $<$<CONFIG:DEBUG>: -fprofile-instr-generate; -fcoverage-mapping;>)
target_link_options(vga-terminal-static INTERFACE $<$<CONFIG:DEBUG>: -ftest-coverage; --coverage;>)
else()
message(ERROR "Unknown OS")
endif()
else()
message(WARNING ${CMAKE_CXX_COMPILER_ID})
endif()

message("target interface compiler options:")
get_target_property(vga-terminal-static_copts vga-terminal-static INTERFACE_COMPILE_OPTIONS)
get_target_property(vga-terminal-static_copts vga-terminal-static COMPILE_OPTIONS)
message(STATUS "vga-terminal-static " ${vga-terminal-static_copts})
unset(vga-terminal-static_copts)
#if (BUILD_SHARED_LIBS)
Expand Down
3 changes: 2 additions & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ sonar.tests=sdl2-vga-terminal/test
sonar.cfamily.build-wrapper-output=build/bw-output
sonar.cfamily.threads=2
sonar.cfamily.cache.enabled=false
sonar.cfamily.gcov.reportsPath=build/sdl2-vga-terminal/CMakeFiles/vga-terminal-static.dir/src,build/sdl2-vga-terminal/CMakeFiles/vga-terminal.dir/src
sonar.cfamily.gcov.reportsPath=build
sonar.cfamily.llvm-cov.reportPath=

0 comments on commit bc01dfa

Please sign in to comment.