From c8a3f4191a223de1ea4dc73e257d92c0a269aeef Mon Sep 17 00:00:00 2001 From: Raffaello Bertini Date: Sun, 10 May 2020 16:56:25 +0100 Subject: [PATCH 01/15] split variable file --- azure-pipelines/analyzer.yml | 4 +++- azure-pipelines/variables/build_switches.yml | 6 ++++++ azure-pipelines/variables/global.yml | 5 +++++ azure-pipelines/variables/images.yml | 4 ++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 azure-pipelines/variables/build_switches.yml create mode 100644 azure-pipelines/variables/global.yml create mode 100644 azure-pipelines/variables/images.yml diff --git a/azure-pipelines/analyzer.yml b/azure-pipelines/analyzer.yml index d0d2ecf6..9d95e5f3 100644 --- a/azure-pipelines/analyzer.yml +++ b/azure-pipelines/analyzer.yml @@ -25,7 +25,9 @@ pr: - LICENSE variables: - - template: variables.yml + - template: variables/global.yml + - template: variables/images.yml + - template: variables/build_switches.yml stages: - stage: Dep diff --git a/azure-pipelines/variables/build_switches.yml b/azure-pipelines/variables/build_switches.yml new file mode 100644 index 00000000..a7db19d7 --- /dev/null +++ b/azure-pipelines/variables/build_switches.yml @@ -0,0 +1,6 @@ +variables: + SDL2_STATIC: ON + BUILD_TESTING: ON + BUILD_SHARED_LIBS: ON + BUILD_EXAMPLES: ON + BUILD_SNAPSHOT: OFF diff --git a/azure-pipelines/variables/global.yml b/azure-pipelines/variables/global.yml new file mode 100644 index 00000000..ad1500e2 --- /dev/null +++ b/azure-pipelines/variables/global.yml @@ -0,0 +1,5 @@ +variables: + CACHE_VCPKG_KEY: v4 | vcpkg-root + VCPKG_CMAKE: "$(Build.SourcesDirectory)/vcpkg/scripts/buildsystems/vcpkg.cmake" + CMAKE_ARGS: -DWITH_SDL2_STATIC=$(SDL2_STATIC) -DBUILD_TESTING=$(BUILD_TESTING) -DBUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS) -DBUILD_EXAMPLES=$(BUILD_EXAMPLES) -DBUILD_SNAPSHOT=$(BUILD_SNAPSHOT) + CMAKE_IGNORE_PATH_WIN: "C:/MinGW/bin;C:/Strawberry/c/bin;C:/Program Files (x86)/LLVM/bin;C:/ProgramData/chocolatey/bin" diff --git a/azure-pipelines/variables/images.yml b/azure-pipelines/variables/images.yml new file mode 100644 index 00000000..1b47b328 --- /dev/null +++ b/azure-pipelines/variables/images.yml @@ -0,0 +1,4 @@ +variables: + windows_image: 'windows-2019' + linux_image: 'ubuntu-18.04' + mac_image: 'macOS-10.15' From 3be9aef351dd4a55c8dbec235119779f7f509799 Mon Sep 17 00:00:00 2001 From: Raffaello Bertini Date: Sun, 10 May 2020 17:00:05 +0100 Subject: [PATCH 02/15] [azure-pipeline] refactor variables template :pager: --- azure-pipelines/linux.yml | 4 +++- azure-pipelines/macos.yml | 5 +++-- azure-pipelines/monolithic.yml | 4 +++- azure-pipelines/variables.yml | 13 ------------- azure-pipelines/windows.yml | 4 +++- 5 files changed, 12 insertions(+), 18 deletions(-) delete mode 100644 azure-pipelines/variables.yml diff --git a/azure-pipelines/linux.yml b/azure-pipelines/linux.yml index d58f09a4..419a9cea 100644 --- a/azure-pipelines/linux.yml +++ b/azure-pipelines/linux.yml @@ -25,7 +25,9 @@ pr: - LICENSE variables: - - template: variables.yml + - template: variables/global.yml + - template: variables/images.yml + - template: variables/build_switches.yml stages: - stage: Dep diff --git a/azure-pipelines/macos.yml b/azure-pipelines/macos.yml index 808b10e9..e46c33c9 100644 --- a/azure-pipelines/macos.yml +++ b/azure-pipelines/macos.yml @@ -23,9 +23,10 @@ pr: - README.md - appveyor.yml - LICENSE - variables: - - template: variables.yml + - template: variables/global.yml + - template: variables/images.yml + - template: variables/build_switches.yml stages: - stage: Dep diff --git a/azure-pipelines/monolithic.yml b/azure-pipelines/monolithic.yml index 7be7250b..6fb014b8 100644 --- a/azure-pipelines/monolithic.yml +++ b/azure-pipelines/monolithic.yml @@ -27,7 +27,9 @@ pr: - LICENSE variables: - - template: variables.yml + - template: variables/global.yml + - template: variables/images.yml + - template: variables/build_switches.yml stages: - stage: Dep diff --git a/azure-pipelines/variables.yml b/azure-pipelines/variables.yml deleted file mode 100644 index d6fd212c..00000000 --- a/azure-pipelines/variables.yml +++ /dev/null @@ -1,13 +0,0 @@ -variables: - windows_image: 'windows-2019' - linux_image: 'ubuntu-18.04' - mac_image: 'macOS-10.15' - CACHE_VCPKG_KEY: v4 | vcpkg-root - VCPKG_CMAKE: "$(Build.SourcesDirectory)/vcpkg/scripts/buildsystems/vcpkg.cmake" - SDL2_STATIC: ON - BUILD_TESTING: ON - BUILD_SHARED_LIBS: ON - BUILD_EXAMPLES: ON - BUILD_SNAPSHOT: OFF - CMAKE_ARGS: -DWITH_SDL2_STATIC=$(SDL2_STATIC) -DBUILD_TESTING=$(BUILD_TESTING) -DBUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS) -DBUILD_EXAMPLES=$(BUILD_EXAMPLES) -DBUILD_SNAPSHOT=$(BUILD_SNAPSHOT) - CMAKE_IGNORE_PATH_WIN: "C:/MinGW/bin;C:/Strawberry/c/bin;C:/Program Files (x86)/LLVM/bin;C:/ProgramData/chocolatey/bin" diff --git a/azure-pipelines/windows.yml b/azure-pipelines/windows.yml index 44b08d02..be79ec73 100644 --- a/azure-pipelines/windows.yml +++ b/azure-pipelines/windows.yml @@ -25,7 +25,9 @@ pr: - LICENSE variables: - - template: variables.yml + - template: variables/global.yml + - template: variables/images.yml + - template: variables/build_switches.yml stages: - stage: Dep From ae98ca07e786fa53801a6e4229a0fb79ce6226f7 Mon Sep 17 00:00:00 2001 From: Raffaello Bertini Date: Sun, 10 May 2020 17:06:17 +0100 Subject: [PATCH 03/15] [azure-pipelines] tidy pipelines --- azure-pipelines/linux.yml | 14 +++----------- azure-pipelines/macos.yml | 14 +++----------- azure-pipelines/windows.yml | 6 +++--- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/azure-pipelines/linux.yml b/azure-pipelines/linux.yml index 419a9cea..f8e37d2b 100644 --- a/azure-pipelines/linux.yml +++ b/azure-pipelines/linux.yml @@ -33,25 +33,17 @@ stages: - stage: Dep jobs: - job: vcpkg - strategy: - matrix: - Linux: - imageName: ${{ variables.linux_image }} - TRIPLET: x64-linux pool: - vmImage: $(imageName) + vmImage: ${{ variables.linux_image }} steps: - template: templates/dep-vcpkg-steps.yml parameters: vcpkg_key_cache: $(CACHE_VCPKG_KEY) - triplet: $(TRIPLET) - arch: $(ARCH) + triplet: x64-linux - stage: CI jobs: - job: Linux - variables: - TRIPLET: x64-linux strategy: matrix: GCC Debug: @@ -64,7 +56,7 @@ stages: - template: 'templates/ci-steps.yml' parameters: vcpkg_key_cache: $(CACHE_VCPKG_KEY) - triplet: $(TRIPLET) + triplet: x64-linux build_type: $(CONFIGURATION) test: false install: false diff --git a/azure-pipelines/macos.yml b/azure-pipelines/macos.yml index e46c33c9..e8707b2d 100644 --- a/azure-pipelines/macos.yml +++ b/azure-pipelines/macos.yml @@ -32,25 +32,17 @@ stages: - stage: Dep jobs: - job: vcpkg - strategy: - matrix: - MacOS: - imageName: ${{ variables.mac_image }} - TRIPLET: x64-osx pool: - vmImage: $(imageName) + vmImage: ${{ variables.mac_image }} steps: - template: templates/dep-vcpkg-steps.yml parameters: vcpkg_key_cache: $(CACHE_VCPKG_KEY) - triplet: $(TRIPLET) - arch: $(ARCH) + triplet: x64-osx - stage: CI jobs: - job: macOS - variables: - TRIPLET: x64-osx strategy: matrix: Debug: @@ -63,6 +55,6 @@ stages: - template: 'templates/ci-steps.yml' parameters: vcpkg_key_cache: $(CACHE_VCPKG_KEY) - triplet: $(TRIPLET) + triplet: x64-osx build_type: $(CONFIGURATION) install: false diff --git a/azure-pipelines/windows.yml b/azure-pipelines/windows.yml index be79ec73..6c675144 100644 --- a/azure-pipelines/windows.yml +++ b/azure-pipelines/windows.yml @@ -36,15 +36,13 @@ stages: strategy: matrix: Win 32 bits: - imageName: ${{ variables.windows_image }} TRIPLET: x86-windows ARCH: 32 Win 64 bits: - imageName: ${{ variables.windows_image }} TRIPLET: x64-windows ARCH: 64 pool: - vmImage: $(imageName) + vmImage: ${{ variables.windows_image }} steps: - template: templates/dep-vcpkg-steps.yml parameters: @@ -57,6 +55,8 @@ stages: - job: Windows variables: #SDL2_STATIC: OFF + # TODO remove the line below + # BODY [..] when done the build-matrix configuration BUILD_SHARED_LIBS: ON strategy: matrix: From 0f8f7aeb86f177c07dcaae1e6f567efab99ddff5 Mon Sep 17 00:00:00 2001 From: Raffaello Bertini Date: Sun, 10 May 2020 17:14:30 +0100 Subject: [PATCH 04/15] [WIP] [azure-pipelines] Ci on Win-GCC --- azure-pipelines/templates/sonarcloud-job.yml | 4 ++ azure-pipelines/win-gcc.yml | 66 ++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 azure-pipelines/win-gcc.yml diff --git a/azure-pipelines/templates/sonarcloud-job.yml b/azure-pipelines/templates/sonarcloud-job.yml index 1f5a59e4..8b9469eb 100644 --- a/azure-pipelines/templates/sonarcloud-job.yml +++ b/azure-pipelines/templates/sonarcloud-job.yml @@ -90,6 +90,7 @@ jobs: parameters: vcpkg_key_cache: ${{ parameters.vcpkg_key_cache }} triplet: ${{ parameters.triplet }} + - task: Cache@2 inputs: key: '"${{ parameters.sonar_wrapper_url }}" | "$(Agent.OS)"' @@ -102,6 +103,7 @@ jobs: unzip build-wrapper.zip displayName: build-wrapper condition: ne(variables.CACHED_BUILD_WRAPPER, 'true') + - task: SonarCloudPrepare@1 inputs: SonarCloud: 'sonarCloud' @@ -109,6 +111,7 @@ jobs: scannerMode: 'CLI' configMode: 'file' displayName: Prepare sonarCloud + - template: 'cmake-gen-build-steps.yml' parameters: build_type: ${{ parameters.build_type }} @@ -117,6 +120,7 @@ jobs: cmake_ignore_path: ${{ parameters.cmake_ignore_path }} arch: ${{ parameters.arch }} build_wrapper: "${{ parameters.build_wrapper }} --out-dir bw-output" + - task: SonarCloudAnalyze@1 - task: SonarCloudPublish@1 inputs: diff --git a/azure-pipelines/win-gcc.yml b/azure-pipelines/win-gcc.yml new file mode 100644 index 00000000..c73fb321 --- /dev/null +++ b/azure-pipelines/win-gcc.yml @@ -0,0 +1,66 @@ +trigger: + branches: + include: + - master + paths: + exclude: + #- .gitignore + - .github/* + - README.md + - appveyor.yml + tags: + include: + - '*' + +pr: + branches: + include: + - master + paths: + exclude: + #- .gitignore + - .github/* + - README.md + - appveyor.yml + - LICENSE + +variables: + - template: variables/global.yml + - template: variables/images.yml + - template: variables/build_switches.yml + +stages: +- stage: Dep + jobs: + - job: vcpkg + strategy: + matrix: + Win Mingw64: + imageName: ${{ variables.windows_image }} + TRIPLET: x64-mingw + ARCH: 64 + pool: + vmImage: $(imageName) + steps: + - template: templates/dep-vcpkg-steps.yml + parameters: + vcpkg_key_cache: $(CACHE_VCPKG_KEY) + triplet: $(TRIPLET) + arch: $(ARCH) + +- stage: mingw + jobs: + - template: 'templates/sonarcloud-job.yml' + parameters: + imageName: ${{ variables.windows_image }} + jobName: SonarCloud_win_gcc + jobDisplayName: SonarCloud (WIN GCC) + vcpkg_key_cache: $(CACHE_VCPKG_KEY) + triplet: x64-mingw + arch: 64 + build_type: Debug + sonar_wrapper_url: 'https://sonarcloud.io/static/cpp/build-wrapper-win-x86.zip' + build_wrapper: 'build-wrapper-win-x86\build-wrapper-win-x86-64.exe' + build_wrapper_path: build/build-wrapper-win-x86 + #cmake_ignore_path: $(CMAKE_IGNORE_PATH_WIN) + From 4df7d1fd02775ea5d257c5197c3279af05b4b30f Mon Sep 17 00:00:00 2001 From: Raffaello Bertini Date: Sun, 10 May 2020 17:40:29 +0100 Subject: [PATCH 05/15] [azure-pipelines] cmage gen step with VCPKG_TRIPLET explicit param --- azure-pipelines/templates/ci-steps.yml | 1 + azure-pipelines/templates/cmake-gen-build-steps.yml | 8 ++++++-- azure-pipelines/templates/sonarcloud-job.yml | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/azure-pipelines/templates/ci-steps.yml b/azure-pipelines/templates/ci-steps.yml index e997ba82..45687eda 100644 --- a/azure-pipelines/templates/ci-steps.yml +++ b/azure-pipelines/templates/ci-steps.yml @@ -57,6 +57,7 @@ steps: - template: 'cmake-gen-build-steps.yml' parameters: build_type: ${{ parameters.build_type }} + triplet: ${{ parameters.triplet }} vcpkg_cmake: ${{ parameters.vcpkg_cmake }} cmake_args: ${{ parameters.cmake_args }} cmake_ignore_path: ${{ parameters.cmake_ignore_path }} diff --git a/azure-pipelines/templates/cmake-gen-build-steps.yml b/azure-pipelines/templates/cmake-gen-build-steps.yml index 74545c13..b0c18732 100644 --- a/azure-pipelines/templates/cmake-gen-build-steps.yml +++ b/azure-pipelines/templates/cmake-gen-build-steps.yml @@ -2,6 +2,10 @@ parameters: - name: build_type displayName: Build Type type: string + + - name: triplet + displayName: triplet + type: string - name: vcpkg_cmake displayName: VCPKG_CMAKE @@ -31,7 +35,7 @@ parameters: steps: - bash: | mkdir -p build && cd build - cmake -DCMAKE_BUILD_TYPE=${{ parameters.build_type }} -DCMAKE_TOOLCHAIN_FILE=${{ parameters.vcpkg_cmake }} ${{ parameters.cmake_args }} .. + cmake -DVCPKG_TARGET_TRIPLET=${{ parameters.triplet }} -DCMAKE_BUILD_TYPE=${{ parameters.build_type }} -DCMAKE_TOOLCHAIN_FILE=${{ parameters.vcpkg_cmake }} ${{ parameters.cmake_args }} .. displayName: cmake generator (UNIX) condition: ne(variables['Agent.OS'], 'Windows_NT') - bash: ${{ parameters.build_wrapper }} cmake --build . @@ -42,7 +46,7 @@ steps: - script: | call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars${{ parameters.arch }}.bat" mkdir build & cd build - cmake -DCMAKE_IGNORE_PATH="${{ parameters.cmake_ignore_path }}" -G"Ninja" -DCMAKE_BUILD_TYPE=${{ parameters.build_type }} -DCMAKE_TOOLCHAIN_FILE=${{ parameters.vcpkg_cmake }} ${{ parameters.cmake_args }} .. + cmake -DVCPKG_TARGET_TRIPLET=${{ parameters.triplet }} -DCMAKE_IGNORE_PATH="${{ parameters.cmake_ignore_path }}" -G"Ninja" -DCMAKE_BUILD_TYPE=${{ parameters.build_type }} -DCMAKE_TOOLCHAIN_FILE=${{ parameters.vcpkg_cmake }} ${{ parameters.cmake_args }} .. displayName: 'CMake generator (WIN)' condition: eq(variables['Agent.OS'], 'Windows_NT') - script: | diff --git a/azure-pipelines/templates/sonarcloud-job.yml b/azure-pipelines/templates/sonarcloud-job.yml index 8b9469eb..99603783 100644 --- a/azure-pipelines/templates/sonarcloud-job.yml +++ b/azure-pipelines/templates/sonarcloud-job.yml @@ -115,6 +115,7 @@ jobs: - template: 'cmake-gen-build-steps.yml' parameters: build_type: ${{ parameters.build_type }} + triplet: ${{ parameters.triplet }} vcpkg_cmake: ${{ parameters.vcpkg_cmake }} cmake_args: ${{ parameters.cmake_args }} cmake_ignore_path: ${{ parameters.cmake_ignore_path }} From 7a028cadc2cbf4a3946bf81f80bf1630b3731d5b Mon Sep 17 00:00:00 2001 From: Raffaello Bertini Date: Sun, 10 May 2020 17:52:52 +0100 Subject: [PATCH 06/15] [azure-pipelines] mingw disable build examples --- azure-pipelines/analyzer.yml | 2 ++ azure-pipelines/templates/sonarcloud-job.yml | 12 +++++++++++- azure-pipelines/win-gcc.yml | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/azure-pipelines/analyzer.yml b/azure-pipelines/analyzer.yml index 9d95e5f3..171428cc 100644 --- a/azure-pipelines/analyzer.yml +++ b/azure-pipelines/analyzer.yml @@ -49,6 +49,8 @@ stages: arch: $(ARCH) - stage: Analyzer + variables: + BUILD_EXAMPLES: OFF jobs: - template: 'templates/sonarcloud-job.yml' parameters: diff --git a/azure-pipelines/templates/sonarcloud-job.yml b/azure-pipelines/templates/sonarcloud-job.yml index 99603783..9f37d47e 100644 --- a/azure-pipelines/templates/sonarcloud-job.yml +++ b/azure-pipelines/templates/sonarcloud-job.yml @@ -74,6 +74,11 @@ parameters: - build/build-wrapper-linux-x86-64 - build/build-wrapper-macosx-x86 + - name: test + displayName: Run Test? + type: boolean + default: true + - name: publish_timeout displayName: PUBLISH_TIMEOUT type: number @@ -120,7 +125,12 @@ jobs: cmake_args: ${{ parameters.cmake_args }} cmake_ignore_path: ${{ parameters.cmake_ignore_path }} arch: ${{ parameters.arch }} - build_wrapper: "${{ parameters.build_wrapper }} --out-dir bw-output" + build_wrapper: "${{ parameters.build_wrapper }} --out-dir bw-output" + + - ${{ if eq(parameters.test, true) }}: + - script: ctest -C ${{ parameters.build_type }} -V + displayName: cmake test (ctest) + workingDirectory: build - task: SonarCloudAnalyze@1 - task: SonarCloudPublish@1 diff --git a/azure-pipelines/win-gcc.yml b/azure-pipelines/win-gcc.yml index c73fb321..27f12acd 100644 --- a/azure-pipelines/win-gcc.yml +++ b/azure-pipelines/win-gcc.yml @@ -49,6 +49,9 @@ stages: arch: $(ARCH) - stage: mingw + variables: + BUILD_EXAMPLES: OFF + #BUILD_SHARED_LIBS: OFF jobs: - template: 'templates/sonarcloud-job.yml' parameters: From a873c63de4b4469ff98ae03741107df4e554cae2 Mon Sep 17 00:00:00 2001 From: Raffaello Bertini Date: Sun, 10 May 2020 17:57:59 +0100 Subject: [PATCH 07/15] [code cov] add GCC on macos --- azure-pipelines/win-gcc.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/azure-pipelines/win-gcc.yml b/azure-pipelines/win-gcc.yml index 27f12acd..690821f7 100644 --- a/azure-pipelines/win-gcc.yml +++ b/azure-pipelines/win-gcc.yml @@ -39,6 +39,9 @@ stages: imageName: ${{ variables.windows_image }} TRIPLET: x64-mingw ARCH: 64 + osx: + imageName: ${{ variables.mac_image }} + TRIPLET: x64-osx pool: vmImage: $(imageName) steps: @@ -51,7 +54,7 @@ stages: - stage: mingw variables: BUILD_EXAMPLES: OFF - #BUILD_SHARED_LIBS: OFF + BUILD_SHARED_LIBS: OFF jobs: - template: 'templates/sonarcloud-job.yml' parameters: @@ -65,5 +68,15 @@ stages: sonar_wrapper_url: 'https://sonarcloud.io/static/cpp/build-wrapper-win-x86.zip' build_wrapper: 'build-wrapper-win-x86\build-wrapper-win-x86-64.exe' build_wrapper_path: build/build-wrapper-win-x86 - #cmake_ignore_path: $(CMAKE_IGNORE_PATH_WIN) + - template: 'templates/sonarcloud-job.yml' + parameters: + imageName: ${{ variables.mac_image }} + jobName: SonarCloud_macos + jobDisplayName: SonarCloud (macOS) + vcpkg_key_cache: $(CACHE_VCPKG_KEY) + triplet: x64-osx + build_type: Debug + sonar_wrapper_url: 'https://sonarcloud.io/static/cpp/build-wrapper-macosx-x86.zip' + build_wrapper: 'build-wrapper-macosx-x86/build-wrapper-macosx-x86' + build_wrapper_path: build/build-wrapper-macosx-x86 From c2d55d2565dd89ec742105ef93d4e96d14c71959 Mon Sep 17 00:00:00 2001 From: Raffaello Bertini Date: Sun, 10 May 2020 19:55:01 +0100 Subject: [PATCH 08/15] clean ups --- azure-pipelines/templates/dep-vcpkg-steps.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/azure-pipelines/templates/dep-vcpkg-steps.yml b/azure-pipelines/templates/dep-vcpkg-steps.yml index 6d3bb399..e68e82db 100644 --- a/azure-pipelines/templates/dep-vcpkg-steps.yml +++ b/azure-pipelines/templates/dep-vcpkg-steps.yml @@ -25,11 +25,10 @@ parameters: steps: - checkout: none -- task: Cache@2 - inputs: - key: '${{ parameters.vcpkg_key_cache }} | ${{ parameters.triplet }}' - path: "vcpkg" - cacheHitVar: CACHE_RESTORED +- template: 'vcpkg-cache-step.yml' + parameters: + vcpkg_key_cache: ${{ parameters.vcpkg_key_cache }} + triplet: ${{ parameters.triplet }} - bash: test -d vcpkg || git clone https://github.com/Microsoft/vcpkg.git displayName: clone vcpkg - script: echo "installing packages ${{ parameters.packages }}" From 40f7b95ef0e29d6d76062c61b109d99620f03d3d Mon Sep 17 00:00:00 2001 From: Raffaello Bertini Date: Sun, 10 May 2020 23:17:58 +0100 Subject: [PATCH 09/15] [azure-pipeline] container linux in vm windows --- azure-pipelines/win-gcc.yml | 94 ++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 43 deletions(-) diff --git a/azure-pipelines/win-gcc.yml b/azure-pipelines/win-gcc.yml index 690821f7..a605d4bd 100644 --- a/azure-pipelines/win-gcc.yml +++ b/azure-pipelines/win-gcc.yml @@ -30,53 +30,61 @@ variables: - template: variables/build_switches.yml stages: -- stage: Dep - jobs: - - job: vcpkg - strategy: - matrix: - Win Mingw64: - imageName: ${{ variables.windows_image }} - TRIPLET: x64-mingw - ARCH: 64 - osx: - imageName: ${{ variables.mac_image }} - TRIPLET: x64-osx - pool: - vmImage: $(imageName) - steps: - - template: templates/dep-vcpkg-steps.yml - parameters: - vcpkg_key_cache: $(CACHE_VCPKG_KEY) - triplet: $(TRIPLET) - arch: $(ARCH) +# - stage: Dep +# jobs: +# - job: vcpkg +# strategy: +# matrix: +# Win Mingw64: +# imageName: ${{ variables.windows_image }} +# TRIPLET: x64-mingw +# ARCH: 64 +# osx: +# imageName: ${{ variables.mac_image }} +# TRIPLET: x64-osx +# pool: +# vmImage: $(imageName) +# steps: +# - template: templates/dep-vcpkg-steps.yml +# parameters: +# vcpkg_key_cache: $(CACHE_VCPKG_KEY) +# triplet: $(TRIPLET) +# arch: $(ARCH) - stage: mingw variables: BUILD_EXAMPLES: OFF BUILD_SHARED_LIBS: OFF jobs: - - template: 'templates/sonarcloud-job.yml' - parameters: - imageName: ${{ variables.windows_image }} - jobName: SonarCloud_win_gcc - jobDisplayName: SonarCloud (WIN GCC) - vcpkg_key_cache: $(CACHE_VCPKG_KEY) - triplet: x64-mingw - arch: 64 - build_type: Debug - sonar_wrapper_url: 'https://sonarcloud.io/static/cpp/build-wrapper-win-x86.zip' - build_wrapper: 'build-wrapper-win-x86\build-wrapper-win-x86-64.exe' - build_wrapper_path: build/build-wrapper-win-x86 + # - template: 'templates/sonarcloud-job.yml' + # parameters: + # imageName: ${{ variables.windows_image }} + # jobName: SonarCloud_win_gcc + # jobDisplayName: SonarCloud (WIN GCC) + # vcpkg_key_cache: $(CACHE_VCPKG_KEY) + # triplet: x64-mingw + # arch: 64 + # build_type: Debug + # sonar_wrapper_url: 'https://sonarcloud.io/static/cpp/build-wrapper-win-x86.zip' + # build_wrapper: 'build-wrapper-win-x86\build-wrapper-win-x86-64.exe' + # build_wrapper_path: build/build-wrapper-win-x86 - - template: 'templates/sonarcloud-job.yml' - parameters: - imageName: ${{ variables.mac_image }} - jobName: SonarCloud_macos - jobDisplayName: SonarCloud (macOS) - vcpkg_key_cache: $(CACHE_VCPKG_KEY) - triplet: x64-osx - build_type: Debug - sonar_wrapper_url: 'https://sonarcloud.io/static/cpp/build-wrapper-macosx-x86.zip' - build_wrapper: 'build-wrapper-macosx-x86/build-wrapper-macosx-x86' - build_wrapper_path: build/build-wrapper-macosx-x86 + # - template: 'templates/sonarcloud-job.yml' + # parameters: + # imageName: ${{ variables.mac_image }} + # jobName: SonarCloud_macos + # jobDisplayName: SonarCloud (macOS) + # vcpkg_key_cache: $(CACHE_VCPKG_KEY) + # triplet: x64-osx + # build_type: Debug + # sonar_wrapper_url: 'https://sonarcloud.io/static/cpp/build-wrapper-macosx-x86.zip' + # build_wrapper: 'build-wrapper-macosx-x86/build-wrapper-macosx-x86' + # build_wrapper_path: build/build-wrapper-macosx-x86 + - job: container + pool: + vmImage: ${{ variables.windows_image }} + container: ubuntu:16.04 + steps: + - script: echo "hello" + - script: cat /proc/cpu + From 59d8b745f09519449272d8722bbb8129c87ab01d Mon Sep 17 00:00:00 2001 From: Raffaello Bertini Date: Mon, 11 May 2020 10:05:54 +0100 Subject: [PATCH 10/15] [azure-pipelines] clean up todo --- azure-pipelines/win-gcc.yml | 14 +++++++------- azure-pipelines/windows.yml | 3 --- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/azure-pipelines/win-gcc.yml b/azure-pipelines/win-gcc.yml index a605d4bd..344e7105 100644 --- a/azure-pipelines/win-gcc.yml +++ b/azure-pipelines/win-gcc.yml @@ -80,11 +80,11 @@ stages: # sonar_wrapper_url: 'https://sonarcloud.io/static/cpp/build-wrapper-macosx-x86.zip' # build_wrapper: 'build-wrapper-macosx-x86/build-wrapper-macosx-x86' # build_wrapper_path: build/build-wrapper-macosx-x86 - - job: container - pool: - vmImage: ${{ variables.windows_image }} - container: ubuntu:16.04 - steps: - - script: echo "hello" - - script: cat /proc/cpu + # - job: container + # pool: + # vmImage: ${{ variables.windows_image }} + # container: ubuntu:16.04 + # steps: + # - script: echo "hello" + # - script: cat /proc/cpu diff --git a/azure-pipelines/windows.yml b/azure-pipelines/windows.yml index 6c675144..dcea1216 100644 --- a/azure-pipelines/windows.yml +++ b/azure-pipelines/windows.yml @@ -55,9 +55,6 @@ stages: - job: Windows variables: #SDL2_STATIC: OFF - # TODO remove the line below - # BODY [..] when done the build-matrix configuration - BUILD_SHARED_LIBS: ON strategy: matrix: 64-bit Debug: From d92f6b76b1ad13e28eb8d190a9e80e88d4f94816 Mon Sep 17 00:00:00 2001 From: Raffaello Bertini Date: Mon, 11 May 2020 19:47:56 +0100 Subject: [PATCH 11/15] clang compiler options. fix #83 --- azure-pipelines/windows.yml | 2 - sdl2-vga-terminal/CMakeLists.txt | 88 ++++++++++++++++------- sdl2-vga-terminal/examples/CMakeLists.txt | 8 ++- sdl2-vga-terminal/src/VgaTerminal.cpp | 2 +- sdl2-vga-terminal/test/CMakeLists.txt | 10 +-- 5 files changed, 72 insertions(+), 38 deletions(-) diff --git a/azure-pipelines/windows.yml b/azure-pipelines/windows.yml index dcea1216..49eab1ad 100644 --- a/azure-pipelines/windows.yml +++ b/azure-pipelines/windows.yml @@ -53,8 +53,6 @@ stages: - stage: CI jobs: - job: Windows - variables: - #SDL2_STATIC: OFF strategy: matrix: 64-bit Debug: diff --git a/sdl2-vga-terminal/CMakeLists.txt b/sdl2-vga-terminal/CMakeLists.txt index 237a36ed..6bbf7b9f 100644 --- a/sdl2-vga-terminal/CMakeLists.txt +++ b/sdl2-vga-terminal/CMakeLists.txt @@ -146,20 +146,20 @@ if (BUILD_SHARED_LIBS) endif() ######################## add compiler options ################################ -if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") +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 $<$:/Od /GR /GS /Gs /guard:cf /RTC1c /D_ALLOW_RTCc_IN_STL> $<$:/O2 /Ot /GA /GL /Gw> ) - if (BUILD_SHARED_LIBS) - target_compile_options(vga-terminal PRIVATE /W4 /WX - $<$:/Od /GR /GS /Gs /guard:cf /RTC1c /D_ALLOW_RTCc_IN_STL> - $<$:/O2 /Ot /GA /GL /Gw> - ) - endif() -elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + #if (BUILD_SHARED_LIBS) + # target_compile_options(vga-terminal PRIVATE /W4 /WX + # $<$:/Od /GR /GS /Gs /guard:cf /RTC1c /D_ALLOW_RTCc_IN_STL> + # $<$:/O2 /Ot /GA /GL /Gw> + # ) + #endif() +elseif(CMAKE_CXX_COMPILER_ID MATCHES "^GNU") target_compile_options(vga-terminal-static PRIVATE -Wall -Wextra -pedantic -fPIC $<$: -O0;-D_GLIBCXX_DEBUG;-D_GLIBCXX_ASSERTIONS;-fexceptions; @@ -170,32 +170,66 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") #$<$:-O2;-fexceptions;-fstack-clash-protection;-D_FORTIFY_SOURCE=2> $<$:-O2;-fexceptions;-D_FORTIFY_SOURCE=2> ) #-Werror) - target_link_options(vga-terminal-static INTERFACE $<$:-fprofile-arcs; -ftest-coverage --coverage>;) - if (BUILD_SHARED_LIBS) - target_compile_options(vga-terminal PRIVATE + target_link_options(vga-terminal-static INTERFACE $<$:-fprofile-arcs; -ftest-coverage; --coverage;>) + #if (BUILD_SHARED_LIBS) + # target_compile_options(vga-terminal INTERAFCE + # $<$: + # -O0;-D_GLIBCXX_DEBUG;-D_GLIBCXX_ASSERTIONS;-fexceptions; + # -W; -Wshadow; -Wunused-variable; + # -Wunused-parameter; -Wunused-function; -Wunused; -Wno-system-headers; + # -Wno-deprecated; -Woverloaded-virtual; -Wwrite-strings; -fprofile-arcs; -ftest-coverage; + # > + # $<$:-fexceptions;-D_FORTIFY_SOURCE=2> + # ) #-Werror) + # target_link_options(vga-terminal INTERFACE $<$:-fprofile-arcs; -ftest-coverage>;) + #endif() + +elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang") + target_compile_options(vga-terminal-static PRIVATE -WCL4 -Wabstract-vbase-init -Wassign-enum + -Watomic-implicit-seq-cst -Watomic-properties -Wbad-function-cast -Wbinary-literal + -fPIC + $<$: + -g; -c --coverage; -fprofile-arcs; -ftest-coverage; + > + $<$: + -O2; + > + ) #-Weverything #-Werror + target_link_options(vga-terminal-static INTERFACE $<$:-fprofile-arcs; -ftest-coverage; --coverage;>) + + 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 + $<$: + -flto; -fsanitize=address; -fsanitize=thread; -fsanitize=memory; -fsanitize=undefined; -fsanitize=dataflow; + -fsanitize=cfi; -fsanitize=safe-stack; + > + $<$: + > + ) + target_compile_options(vga-terminal-static INTERFACE $<$: - -O0;-D_GLIBCXX_DEBUG;-D_GLIBCXX_ASSERTIONS;-fexceptions; - -W; -Wshadow; -Wunused-variable; - -Wunused-parameter; -Wunused-function; -Wunused; -Wno-system-headers; - -Wno-deprecated; -Woverloaded-virtual; -Wwrite-strings; -fprofile-arcs; -ftest-coverage; + -fsanitize=address; -fsanitize=thread; -fsanitize=memory; -fsanitize=undefined; -fsanitize=dataflow; + -fsanitize=cfi; -fsanitize=safe-stack; > - $<$:-fexceptions;-D_FORTIFY_SOURCE=2> - ) #-Werror) - target_link_options(vga-terminal PRIVATE $<$:-fprofile-arcs; -ftest-coverage>;) + ) endif() - -elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +else() + message(WARNING ${CMAKE_CXX_COMPILER_ID}) endif() -message("target compiler options:") -get_target_property(vga-terminal-static_copts vga-terminal-static COMPILE_OPTIONS) +message("target interface compiler options:") +get_target_property(vga-terminal-static_copts vga-terminal-static INTERFACE_COMPILE_OPTIONS) message(STATUS "vga-terminal-static " ${vga-terminal-static_copts}) unset(vga-terminal-static_copts) -if (BUILD_SHARED_LIBS) - get_target_property(vga-terminal_copts vga-terminal COMPILE_OPTIONS) - message(STATUS "vga-terminal " ${vga-terminal_copts}) - unset(vga-terminal_copts) -endif() +#if (BUILD_SHARED_LIBS) +# get_target_property(vga-terminal_copts vga-terminal COMPILE_OPTIONS) +# message(STATUS "vga-terminal " ${vga-terminal_copts}) +# unset(vga-terminal_copts) +#endif() diff --git a/sdl2-vga-terminal/examples/CMakeLists.txt b/sdl2-vga-terminal/examples/CMakeLists.txt index 3280e5e0..a88846e0 100644 --- a/sdl2-vga-terminal/examples/CMakeLists.txt +++ b/sdl2-vga-terminal/examples/CMakeLists.txt @@ -3,13 +3,13 @@ cmake_minimum_required (VERSION 3.16) ############################## Main Example ################################## add_executable (${PROJECT_NAME} "sdl2-vga-terminal.cpp") add_dependencies(${PROJECT_NAME} vga-terminal-static) -target_link_libraries(${PROJECT_NAME} vga-terminal-static ${LIB_SDL2main}) +target_link_libraries(${PROJECT_NAME} ${LIB_SDL2main} vga-terminal-static) if (BUILD_SHARED_LIBS) ################## C example using SO/DLL with lazy loading ################## add_executable (${PROJECT_NAME}-so "sdl2-vga-terminal-so.c") add_dependencies(${PROJECT_NAME}-so vga-terminal) - target_link_libraries(${PROJECT_NAME}-so vga-terminal ${LIB_SDL2main}) + target_link_libraries(${PROJECT_NAME}-so ${LIB_SDL2main} vga-terminal) add_custom_command(TARGET "${PROJECT_NAME}-so" POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ ) @@ -24,7 +24,9 @@ if (BUILD_SHARED_LIBS) ################## C example using SO/DLL run-time loading ################## add_executable (${PROJECT_NAME}-load-so "sdl2-vga-terminal-load-so.c") - target_link_libraries(${PROJECT_NAME}-load-so PUBLIC ${LIB_SDL2} ${LIB_SDL2main} ${CMAKE_DL_LIBS}) + target_link_libraries(${PROJECT_NAME}-load-so PUBLIC ${LIB_SDL2main} ${LIB_SDL2} ${CMAKE_DL_LIBS}) + target_link_options(${PROJECT_NAME}-load-so PUBLIC ${LINK_SUBSYS_WIN}) + add_custom_command(TARGET "${PROJECT_NAME}-load-so" POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ ) diff --git a/sdl2-vga-terminal/src/VgaTerminal.cpp b/sdl2-vga-terminal/src/VgaTerminal.cpp index ca123798..429da21e 100644 --- a/sdl2-vga-terminal/src/VgaTerminal.cpp +++ b/sdl2-vga-terminal/src/VgaTerminal.cpp @@ -416,7 +416,7 @@ uint32_t VgaTerminal::_timerCallBack(uint32_t interval) interval = cursor_time; userevent.code = 0; - userevent.data1 = userevent.data2 = NULL; + userevent.data1 = userevent.data2 = nullptr; event.type = userevent.type = SDL_USEREVENT; event.user = userevent; userevent.windowID = event.window.windowID = getWindowId(); diff --git a/sdl2-vga-terminal/test/CMakeLists.txt b/sdl2-vga-terminal/test/CMakeLists.txt index f09ceb00..df6a9c17 100644 --- a/sdl2-vga-terminal/test/CMakeLists.txt +++ b/sdl2-vga-terminal/test/CMakeLists.txt @@ -10,7 +10,7 @@ else() ### VgaTerminal tests ### add_executable(runUnitTests "tests.cpp") add_test(UnitTestsInMain runUnitTests) - target_link_libraries(runUnitTests PRIVATE vga-terminal-static GTest::gtest GTest::gmock ${LIB_SDL2main}) + target_link_libraries(runUnitTests PRIVATE ${LIB_SDL2main} vga-terminal-static GTest::gtest GTest::gmock) add_custom_command(TARGET runUnitTests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ @@ -22,7 +22,7 @@ else() if (BUILD_SHARED_LIBS) add_executable(runSOTest "so-test.cpp") add_test(SOTest runSOTest) - target_link_libraries(runSOTest PRIVATE vga-terminal GTest::gtest ${LIB_SDL2main}) + target_link_libraries(runSOTest PRIVATE ${LIB_SDL2main} vga-terminal GTest::gtest) add_custom_command(TARGET runSOTest POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ @@ -36,7 +36,7 @@ if (BUILD_SNAPSHOT) find_package(SDL2-image CONFIG REQUIRED) add_executable(runSnapshotTests "snapshotTest.cpp") - target_link_libraries(runSnapshotTests PRIVATE vga-terminal-static GTest::gtest GTest::gmock SDL2::SDL2_image ${LIB_SDL2main}) + target_link_libraries(runSnapshotTests PRIVATE ${LIB_SDL2main} vga-terminal-static GTest::gtest GTest::gmock SDL2::SDL2_image) add_test(SnapshotTestsInMain runSnapshotTests) add_custom_command(TARGET runSnapshotTests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ @@ -49,7 +49,7 @@ endif() ### Valgrind tests ### if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") add_executable(runHelgrindTests "valgrind/helgrind.cpp") - target_link_libraries(runHelgrindTests PRIVATE vga-terminal-static ${LIB_SDL2main}) + target_link_libraries(runHelgrindTests PRIVATE ${LIB_SDL2main} vga-terminal-static) add_executable(runMultiThreadFuzzTests "valgrind/multithreading.cpp") - target_link_libraries(runMultiThreadFuzzTests PRIVATE vga-terminal-static ${LIB_SDL2main}) + target_link_libraries(runMultiThreadFuzzTests PRIVATE ${LIB_SDL2main} vga-terminal-static) endif() From 1a08c2696e74babe5d86afb279dc2c776c44a697 Mon Sep 17 00:00:00 2001 From: Raffaello Bertini Date: Mon, 11 May 2020 19:59:38 +0100 Subject: [PATCH 12/15] [azure-pipeline] clang sonarcloud cov test --- azure-pipelines/win-gcc.yml | 54 ++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/azure-pipelines/win-gcc.yml b/azure-pipelines/win-gcc.yml index 344e7105..b5da9620 100644 --- a/azure-pipelines/win-gcc.yml +++ b/azure-pipelines/win-gcc.yml @@ -30,26 +30,26 @@ variables: - template: variables/build_switches.yml stages: -# - stage: Dep -# jobs: -# - job: vcpkg -# strategy: -# matrix: +- stage: Dep + jobs: + - job: vcpkg + strategy: + matrix: # Win Mingw64: # imageName: ${{ variables.windows_image }} # TRIPLET: x64-mingw # ARCH: 64 -# osx: -# imageName: ${{ variables.mac_image }} -# TRIPLET: x64-osx -# pool: -# vmImage: $(imageName) -# steps: -# - template: templates/dep-vcpkg-steps.yml -# parameters: -# vcpkg_key_cache: $(CACHE_VCPKG_KEY) -# triplet: $(TRIPLET) -# arch: $(ARCH) + osx: + imageName: ${{ variables.mac_image }} + TRIPLET: x64-osx + pool: + vmImage: $(imageName) + steps: + - template: templates/dep-vcpkg-steps.yml + parameters: + vcpkg_key_cache: $(CACHE_VCPKG_KEY) + triplet: $(TRIPLET) + arch: $(ARCH) - stage: mingw variables: @@ -69,17 +69,17 @@ stages: # build_wrapper: 'build-wrapper-win-x86\build-wrapper-win-x86-64.exe' # build_wrapper_path: build/build-wrapper-win-x86 - # - template: 'templates/sonarcloud-job.yml' - # parameters: - # imageName: ${{ variables.mac_image }} - # jobName: SonarCloud_macos - # jobDisplayName: SonarCloud (macOS) - # vcpkg_key_cache: $(CACHE_VCPKG_KEY) - # triplet: x64-osx - # build_type: Debug - # sonar_wrapper_url: 'https://sonarcloud.io/static/cpp/build-wrapper-macosx-x86.zip' - # build_wrapper: 'build-wrapper-macosx-x86/build-wrapper-macosx-x86' - # build_wrapper_path: build/build-wrapper-macosx-x86 + - template: 'templates/sonarcloud-job.yml' + parameters: + imageName: ${{ variables.mac_image }} + jobName: SonarCloud_macos + jobDisplayName: SonarCloud (macOS) + vcpkg_key_cache: $(CACHE_VCPKG_KEY) + triplet: x64-osx + build_type: Debug + sonar_wrapper_url: 'https://sonarcloud.io/static/cpp/build-wrapper-macosx-x86.zip' + build_wrapper: 'build-wrapper-macosx-x86/build-wrapper-macosx-x86' + build_wrapper_path: build/build-wrapper-macosx-x86 # - job: container # pool: # vmImage: ${{ variables.windows_image }} From bc01dfa78e1cd5a8af1acf30773ee2de7eb5cc9e Mon Sep 17 00:00:00 2001 From: Raffaello Bertini Date: Tue, 12 May 2020 15:45:49 +0100 Subject: [PATCH 13/15] [sonar-cloud] publish gcov reports --- azure-pipelines/templates/sonarcloud-job.yml | 4 ++- sdl2-vga-terminal/CMakeLists.txt | 36 ++++++++++++-------- sonar-project.properties | 3 +- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/azure-pipelines/templates/sonarcloud-job.yml b/azure-pipelines/templates/sonarcloud-job.yml index 9f37d47e..b50799bd 100644 --- a/azure-pipelines/templates/sonarcloud-job.yml +++ b/azure-pipelines/templates/sonarcloud-job.yml @@ -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: diff --git a/sdl2-vga-terminal/CMakeLists.txt b/sdl2-vga-terminal/CMakeLists.txt index 6bbf7b9f..c2524dbc 100644 --- a/sdl2-vga-terminal/CMakeLists.txt +++ b/sdl2-vga-terminal/CMakeLists.txt @@ -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 $<$:/Od /GR /GS /Gs /guard:cf /RTC1c /D_ALLOW_RTCc_IN_STL> $<$:/O2 /Ot /GA /GL /Gw> ) @@ -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 $<$: -O0;-D_GLIBCXX_DEBUG;-D_GLIBCXX_ASSERTIONS;-fexceptions; -W; -Wshadow; -Wunused-variable; @@ -189,40 +193,42 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang") -Watomic-implicit-seq-cst -Watomic-properties -Wbad-function-cast -Wbinary-literal -fPIC $<$: - -g; -c --coverage; -fprofile-arcs; -ftest-coverage; + -g; > $<$: -O2; > ) #-Weverything #-Werror - target_link_options(vga-terminal-static INTERFACE $<$:-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 $<$: - -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; > $<$: > ) - target_compile_options(vga-terminal-static INTERFACE - $<$: - -fsanitize=address; -fsanitize=thread; -fsanitize=memory; -fsanitize=undefined; -fsanitize=dataflow; - -fsanitize=cfi; -fsanitize=safe-stack; - > - ) + #target_link_options(vga-terminal-static PUBLIC $<$: -fprofile-instr-generate; -fcoverage-mapping;>) + target_link_options(vga-terminal-static INTERFACE $<$: -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) diff --git a/sonar-project.properties b/sonar-project.properties index 8e051305..2403a9e9 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -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= From d0f95f152cd54e3494f0f90d53a971b80fe5fa23 Mon Sep 17 00:00:00 2001 From: Raffaello Bertini Date: Tue, 12 May 2020 16:08:29 +0100 Subject: [PATCH 14/15] [azure-pipeline] test integration --- CMakeLists.txt | 1 + README.md | 1 + appveyor.yml | 21 ++++- azure-pipelines/analyzer.yml | 39 ++++++--- azure-pipelines/templates/ci-steps.yml | 13 ++- azure-pipelines/templates/sonarcloud-job.yml | 31 ++++++- azure-pipelines/variables/build_switches.yml | 1 + azure-pipelines/variables/global.yml | 2 +- azure-pipelines/win-gcc.yml | 90 -------------------- sdl2-vga-terminal/CMakeLists.txt | 65 +++++++------- sonar-project.properties | 2 +- 11 files changed, 119 insertions(+), 147 deletions(-) delete mode 100644 azure-pipelines/win-gcc.yml diff --git a/CMakeLists.txt b/CMakeLists.txt index dbb18f1d..372e8553 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ include(CPack) option(BUILD_SHARED_LIBS "build shared libs with C inteface" ON) option(BUILD_EXAMPLES "build examples" ON) include(CTest) +option(ENABLE_CODE_COVERAGE "compile Debug with code coverage" OFF) option(BUILD_SNAPSHOT "build snapshot test" OFF) include(CMakeDependentOption) CMAKE_DEPENDENT_OPTION(TEST_DUMP_SNAPSHOT "build test to dump the expected output instead of verifing it" OFF diff --git a/README.md b/README.md index a88bd0ef..4764c6e1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # SDL2 VGA Terminal [![Codacy Badge](https://api.codacy.com/project/badge/Grade/83e178fb7d9343b78be651f2797fe3f8)](https://app.codacy.com/manual/Raffaello/sdl2-vga-terminal?utm_source=github.com&utm_medium=referral&utm_content=Raffaello/sdl2-vga-terminal&utm_campaign=Badge_Grade_Settings) +[![codecov](https://codecov.io/gh/Raffaello/sdl2-vga-terminal/branch/master/graph/badge.svg)](https://codecov.io/gh/Raffaello/sdl2-vga-terminal) | Monolithic CI | Note | |:-------------:|-----:| diff --git a/appveyor.yml b/appveyor.yml index ac65772f..6843ff53 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -19,6 +19,7 @@ configuration: environment: VCPKG_SCRIPT: scripts/buildsystems/vcpkg.cmake + ENABLE_CODE_COVERAGE: OFF matrix: allow_failures: @@ -46,17 +47,29 @@ for: environment: WS: /Users/appveyor/projects TRIPLET: $PLATFORM-osx + ENABLE_CODE_COVERAGE: ON cache: #- $WS/vcpkg - $WS/vcpkg/installed init: - sh: if [ $PLATFORM = "x86" ]; then exit 1; fi - - sh: brew install p7zip + - sh: brew install p7zip lcov - sh: cd $WS && git clone https://github.com/Microsoft/vcpkg.git - sh: cd $APPVEYOR_BUILD_FOLDER + # /Library/Developer/CommandLineTools/usr/bin/llvm-cov + #- sh: sudo find / -name llvm-cov 2> /dev/null + #- sh: llvm-cov --help test_script: - sh: ctest -V - + #- sh: find . -name *.gcda + #- sh: echo '#!/bin/bash' > g.sh + #- sh: echo 'exec /Library/Developer/CommandLineTools/usr/bin/llvm-cov gcov "$@"' >> g.sh + #- sh: chmod +x g.sh + #- sh: ./g.sh -f -b -u $(find . -name *.gcda) + #- sh: lcov --directory . --base-directory . --gcov-tool ./g.sh --capture -o cov.info + #- sh: lcov --remove cov.info '/Applications/*' --output-file coverage.info + #- sh: lcov --list coverage.info + #- sh: bash <(curl -s https://codecov.io/bash) -f coverage.info -t b8f07100-6985-49f7-aa4c-14e36f29ac80 skip_commits: files: @@ -90,8 +103,8 @@ before_build: build_script: - mkdir out - cd out - - cmd: cmake -G "Ninja" -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DWITH_SDL2_STATIC=OFF -DBUILD_SNAPSHOT=OFF -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/%VCPKG_SCRIPT% .. - - sh : cmake -DCMAKE_BUILD_TYPE=$CONFIGURATION -DWITH_SDL2_STATIC=ON -DBUILD_SNAPSHOT=OFF -DCMAKE_TOOLCHAIN_FILE=$WS/vcpkg/$VCPKG_SCRIPT .. + - cmd: cmake -G "Ninja" -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DWITH_SDL2_STATIC=OFF -DBUILD_SNAPSHOT=OFF -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/%VCPKG_SCRIPT% .. + - sh : cmake -DCMAKE_BUILD_TYPE=$CONFIGURATION -DWITH_SDL2_STATIC=ON -DBUILD_SNAPSHOT=OFF -DENABLE_CODE_COVERAGE=$ENABLE_CODE_COVERAGE -DCMAKE_TOOLCHAIN_FILE=$WS/vcpkg/$VCPKG_SCRIPT .. - cmake --build . test_script: diff --git a/azure-pipelines/analyzer.yml b/azure-pipelines/analyzer.yml index 171428cc..7faaaf2a 100644 --- a/azure-pipelines/analyzer.yml +++ b/azure-pipelines/analyzer.yml @@ -35,10 +35,9 @@ stages: - job: vcpkg strategy: matrix: - Win 64 bits: - imageName: ${{ variables.windows_image }} - TRIPLET: x64-windows - ARCH: 64 + osx: + imageName: ${{ variables.mac_image }} + TRIPLET: x64-osx pool: vmImage: $(imageName) steps: @@ -48,20 +47,34 @@ stages: triplet: $(TRIPLET) arch: $(ARCH) + - stage: Analyzer variables: BUILD_EXAMPLES: OFF + BUILD_SHARED_LIBS: ON + ENABLE_CODE_COVERAGE: ON jobs: + # - template: 'templates/sonarcloud-job.yml' + # parameters: + # imageName: ${{ variables.windows_image }} + # jobName: SonarCloud_win + # jobDisplayName: SonarCloud (WIN) + # vcpkg_key_cache: $(CACHE_VCPKG_KEY) + # triplet: x64-windows + # arch: 64 + # build_type: Debug + # sonar_wrapper_url: 'https://sonarcloud.io/static/cpp/build-wrapper-win-x86.zip' + # build_wrapper: 'build-wrapper-win-x86\build-wrapper-win-x86-64.exe' + # build_wrapper_path: build/build-wrapper-win-x86 + # cmake_ignore_path: $(CMAKE_IGNORE_PATH_WIN) - template: 'templates/sonarcloud-job.yml' parameters: - imageName: ${{ variables.windows_image }} - jobName: SonarCloud_win - jobDisplayName: SonarCloud (WIN) + imageName: ${{ variables.mac_image }} + jobName: SonarCloud_macos + jobDisplayName: SonarCloud (macOS) vcpkg_key_cache: $(CACHE_VCPKG_KEY) - triplet: x64-windows - arch: 64 + triplet: x64-osx build_type: Debug - sonar_wrapper_url: 'https://sonarcloud.io/static/cpp/build-wrapper-win-x86.zip' - build_wrapper: 'build-wrapper-win-x86\build-wrapper-win-x86-64.exe' - build_wrapper_path: build/build-wrapper-win-x86 - cmake_ignore_path: $(CMAKE_IGNORE_PATH_WIN) + sonar_wrapper_url: 'https://sonarcloud.io/static/cpp/build-wrapper-macosx-x86.zip' + build_wrapper: 'build-wrapper-macosx-x86/build-wrapper-macosx-x86' + build_wrapper_path: build/build-wrapper-macosx-x86 diff --git a/azure-pipelines/templates/ci-steps.yml b/azure-pipelines/templates/ci-steps.yml index 45687eda..c8d4b8c9 100644 --- a/azure-pipelines/templates/ci-steps.yml +++ b/azure-pipelines/templates/ci-steps.yml @@ -64,9 +64,20 @@ steps: arch: ${{ parameters.arch }} #build_wrapper: - ${{ if eq(parameters.test, true) }}: - - script: ctest -C ${{ parameters.build_type }} -V + - script: ctest -C ${{ parameters.build_type }} -v -V -T Test displayName: cmake test (ctest) workingDirectory: build + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'cTest' # Options: JUnit, NUnit, VSTest, xUnit, cTest + testResultsFiles: '**/Test.xml' + searchFolder: build # Optional + #mergeTestResults: false # Optional + #failTaskOnFailedTests: false # Optional + #testRunTitle: # Optional + #buildPlatform: # Optional + #buildConfiguration: # Optional + #publishRunAttachments: true # Optional - ${{ if eq(parameters.install, true) }}: - script: cmake --build . --target install diff --git a/azure-pipelines/templates/sonarcloud-job.yml b/azure-pipelines/templates/sonarcloud-job.yml index b50799bd..3726ce80 100644 --- a/azure-pipelines/templates/sonarcloud-job.yml +++ b/azure-pipelines/templates/sonarcloud-job.yml @@ -128,12 +128,37 @@ jobs: build_wrapper: "${{ parameters.build_wrapper }} --out-dir bw-output" - ${{ if eq(parameters.test, true) }}: - - script: ctest -C ${{ parameters.build_type }} -V - displayName: cmake test (ctest) + - script: ctest -C ${{ parameters.build_type }} + displayName: ctest workingDirectory: build - - bash: llvm-cov gcov -f -b -u $(find . -name *.gcda) + # /usr/local/Cellar/llvm/10.0.0_3/bin/llvm-cov + - bash: | + echo '#!/bin/bash' > g.sh + echo 'exec /usr/local/Cellar/llvm/10.0.0_3/bin/llvm-cov gcov "$@"' >> g.sh + chmod +x g.sh + cat g.sh + displayName: llvm-cov gcov wrapper + workingDirectory: build + condition: ne(variables['Agent.OS'], 'Windows_NT') + + #- bash: sudo find / -name llvm-cov 2> /dev/null + # displayName: llvm-cov DEBUG + # condition: ne(variables['Agent.OS'], 'Windows_NT') + - bash: | + echo $OSTYPE + test $OSTYPE = "darwin19" && brew install lcov || apt-get install -y lcov + #brew install lcov + #echo "finding..." + #find . -name *.gcda + #echo "...." + ./g.sh -f -b -u $(find . -name *.gcda) + lcov --directory . --base-directory . --gcov-tool ./g.sh --capture -o cov.info + lcov --remove cov.info '/Applications/*' --output-file coverage.info + lcov --list coverage.info + bash <(curl -s https://codecov.io/bash) -f coverage.info -t b8f07100-6985-49f7-aa4c-14e36f29ac80 displayName: collect coverage data workingDirectory: build + condition: ne(variables['Agent.OS'], 'Windows_NT') - task: SonarCloudAnalyze@1 - task: SonarCloudPublish@1 inputs: diff --git a/azure-pipelines/variables/build_switches.yml b/azure-pipelines/variables/build_switches.yml index a7db19d7..49888b70 100644 --- a/azure-pipelines/variables/build_switches.yml +++ b/azure-pipelines/variables/build_switches.yml @@ -4,3 +4,4 @@ variables: BUILD_SHARED_LIBS: ON BUILD_EXAMPLES: ON BUILD_SNAPSHOT: OFF + ENABLE_CODE_COVERAGE: OFF diff --git a/azure-pipelines/variables/global.yml b/azure-pipelines/variables/global.yml index ad1500e2..09849b1a 100644 --- a/azure-pipelines/variables/global.yml +++ b/azure-pipelines/variables/global.yml @@ -1,5 +1,5 @@ variables: CACHE_VCPKG_KEY: v4 | vcpkg-root VCPKG_CMAKE: "$(Build.SourcesDirectory)/vcpkg/scripts/buildsystems/vcpkg.cmake" - CMAKE_ARGS: -DWITH_SDL2_STATIC=$(SDL2_STATIC) -DBUILD_TESTING=$(BUILD_TESTING) -DBUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS) -DBUILD_EXAMPLES=$(BUILD_EXAMPLES) -DBUILD_SNAPSHOT=$(BUILD_SNAPSHOT) + CMAKE_ARGS: -DWITH_SDL2_STATIC=$(SDL2_STATIC) -DBUILD_TESTING=$(BUILD_TESTING) -DBUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS) -DBUILD_EXAMPLES=$(BUILD_EXAMPLES) -DBUILD_SNAPSHOT=$(BUILD_SNAPSHOT) -DENABLE_CODE_COVERAGE=$(ENABLE_CODE_COVERAGE) CMAKE_IGNORE_PATH_WIN: "C:/MinGW/bin;C:/Strawberry/c/bin;C:/Program Files (x86)/LLVM/bin;C:/ProgramData/chocolatey/bin" diff --git a/azure-pipelines/win-gcc.yml b/azure-pipelines/win-gcc.yml deleted file mode 100644 index b5da9620..00000000 --- a/azure-pipelines/win-gcc.yml +++ /dev/null @@ -1,90 +0,0 @@ -trigger: - branches: - include: - - master - paths: - exclude: - #- .gitignore - - .github/* - - README.md - - appveyor.yml - tags: - include: - - '*' - -pr: - branches: - include: - - master - paths: - exclude: - #- .gitignore - - .github/* - - README.md - - appveyor.yml - - LICENSE - -variables: - - template: variables/global.yml - - template: variables/images.yml - - template: variables/build_switches.yml - -stages: -- stage: Dep - jobs: - - job: vcpkg - strategy: - matrix: -# Win Mingw64: -# imageName: ${{ variables.windows_image }} -# TRIPLET: x64-mingw -# ARCH: 64 - osx: - imageName: ${{ variables.mac_image }} - TRIPLET: x64-osx - pool: - vmImage: $(imageName) - steps: - - template: templates/dep-vcpkg-steps.yml - parameters: - vcpkg_key_cache: $(CACHE_VCPKG_KEY) - triplet: $(TRIPLET) - arch: $(ARCH) - -- stage: mingw - variables: - BUILD_EXAMPLES: OFF - BUILD_SHARED_LIBS: OFF - jobs: - # - template: 'templates/sonarcloud-job.yml' - # parameters: - # imageName: ${{ variables.windows_image }} - # jobName: SonarCloud_win_gcc - # jobDisplayName: SonarCloud (WIN GCC) - # vcpkg_key_cache: $(CACHE_VCPKG_KEY) - # triplet: x64-mingw - # arch: 64 - # build_type: Debug - # sonar_wrapper_url: 'https://sonarcloud.io/static/cpp/build-wrapper-win-x86.zip' - # build_wrapper: 'build-wrapper-win-x86\build-wrapper-win-x86-64.exe' - # build_wrapper_path: build/build-wrapper-win-x86 - - - template: 'templates/sonarcloud-job.yml' - parameters: - imageName: ${{ variables.mac_image }} - jobName: SonarCloud_macos - jobDisplayName: SonarCloud (macOS) - vcpkg_key_cache: $(CACHE_VCPKG_KEY) - triplet: x64-osx - build_type: Debug - sonar_wrapper_url: 'https://sonarcloud.io/static/cpp/build-wrapper-macosx-x86.zip' - build_wrapper: 'build-wrapper-macosx-x86/build-wrapper-macosx-x86' - build_wrapper_path: build/build-wrapper-macosx-x86 - # - job: container - # pool: - # vmImage: ${{ variables.windows_image }} - # container: ubuntu:16.04 - # steps: - # - script: echo "hello" - # - script: cat /proc/cpu - diff --git a/sdl2-vga-terminal/CMakeLists.txt b/sdl2-vga-terminal/CMakeLists.txt index c2524dbc..46716446 100644 --- a/sdl2-vga-terminal/CMakeLists.txt +++ b/sdl2-vga-terminal/CMakeLists.txt @@ -153,28 +153,35 @@ endif() 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 PUBLIC /W4 /WX + target_compile_options(vga-terminal-static PRIVATE /W4 #/WX $<$:/Od /GR /GS /Gs /guard:cf /RTC1c /D_ALLOW_RTCc_IN_STL> $<$:/O2 /Ot /GA /GL /Gw> ) - #if (BUILD_SHARED_LIBS) - # target_compile_options(vga-terminal PRIVATE /W4 /WX - # $<$:/Od /GR /GS /Gs /guard:cf /RTC1c /D_ALLOW_RTCc_IN_STL> - # $<$:/O2 /Ot /GA /GL /Gw> - # ) - #endif() + if (BUILD_SHARED_LIBS) + target_compile_options(vga-terminal PRIVATE /W4 #/WX + $<$:/Od /GR /GS /Gs /guard:cf /RTC1c /D_ALLOW_RTCc_IN_STL> + $<$:/O2 /Ot /GA /GL /Gw> + ) + endif() elseif(CMAKE_CXX_COMPILER_ID MATCHES "^GNU") - target_compile_options(vga-terminal-static PUBLIC -Wall -Wextra -pedantic -fPIC + target_compile_options(vga-terminal-static PRIVATE -Wall -Wextra -pedantic -fPIC $<$: -O0;-D_GLIBCXX_DEBUG;-D_GLIBCXX_ASSERTIONS;-fexceptions; -W; -Wshadow; -Wunused-variable; -Wunused-parameter; -Wunused-function; -Wunused; -Wno-system-headers; - -Wno-deprecated; -Woverloaded-virtual; -Wwrite-strings; -fprofile-arcs; -ftest-coverage; + -Wno-deprecated; -Woverloaded-virtual; -Wwrite-strings; > #$<$:-O2;-fexceptions;-fstack-clash-protection;-D_FORTIFY_SOURCE=2> $<$:-O2;-fexceptions;-D_FORTIFY_SOURCE=2> ) #-Werror) - target_link_options(vga-terminal-static INTERFACE $<$:-fprofile-arcs; -ftest-coverage; --coverage;>) + + if (ENABLE_CODE_COVERAGE) + target_compile_options(vga-terminal-static PRIVATE + $<$: -fprofile-arcs; -ftest-coverage;> + ) + target_link_options(vga-terminal-static PRIVATE $<$:-fprofile-arcs; -ftest-coverage; --coverage;>) + endif() + #if (BUILD_SHARED_LIBS) # target_compile_options(vga-terminal INTERAFCE # $<$: @@ -190,36 +197,26 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "^GNU") elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang") target_compile_options(vga-terminal-static PRIVATE -WCL4 -Wabstract-vbase-init -Wassign-enum - -Watomic-implicit-seq-cst -Watomic-properties -Wbad-function-cast -Wbinary-literal - -fPIC - $<$: - -g; - > - $<$: - -O2; - > - ) #-Weverything #-Werror - - - ### This if Clang is shipped with VS2019 CE + -Watomic-implicit-seq-cst -Watomic-properties -Wbad-function-cast -Wbinary-literal + ) + if (WIN32) set(LINK_SUBSYS_WIN /subsystem:windows) message(STATUS ${LINK_SUBSYS_WIN}) - target_link_options(vga-terminal-static INTERFACE ${LINK_SUBSYS_WIN}) + target_link_options(vga-terminal-static PUBLIC ${LINK_SUBSYS_WIN}) elseif(UNIX) - #target_compile_options(vga-terminal-static PUBLIC -fprofile-instr-generate -fcoverage-mapping) - target_compile_options(vga-terminal-static INTERFACE - $<$: - #-flto; -fsanitize=address; -fsanitize=thread; -fsanitize=memory; -fsanitize=undefined; -fsanitize=dataflow; - #-fsanitize=cfi; -fsanitize=safe-stack; - #-fprofile-instr-generate; -fcoverage-mapping; - -c -ftest-coverage; - > - $<$: - > + target_compile_options(vga-terminal-static PRIVATE -fPIC + $<$: -g;> + $<$:-O2;> ) + + if(ENABLE_CODE_COVERAGE) + target_compile_options(vga-terminal-static PRIVATE + $<$:-c;-fprofile-arcs; -ftest-coverage;> + ) + target_link_options(vga-terminal-static PUBLIC $<$: -ftest-coverage;-fprofile-arcs; --coverage;>) #target_link_options(vga-terminal-static PUBLIC $<$: -fprofile-instr-generate; -fcoverage-mapping;>) - target_link_options(vga-terminal-static INTERFACE $<$: -ftest-coverage; --coverage;>) + endif() else() message(ERROR "Unknown OS") endif() diff --git a/sonar-project.properties b/sonar-project.properties index 2403a9e9..c5cf681a 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -7,4 +7,4 @@ sonar.cfamily.build-wrapper-output=build/bw-output sonar.cfamily.threads=2 sonar.cfamily.cache.enabled=false sonar.cfamily.gcov.reportsPath=build -sonar.cfamily.llvm-cov.reportPath= +#sonar.cfamily.llvm-cov.reportPath=build From ecb0d75a95ffce783183ddb7f3c081ee571b8774 Mon Sep 17 00:00:00 2001 From: Raffaello Bertini Date: Tue, 12 May 2020 19:27:39 +0100 Subject: [PATCH 15/15] Apply suggestions from code review --- appveyor.yml | 4 ++-- sdl2-vga-terminal/CMakeLists.txt | 23 ----------------------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 6843ff53..2c5e09a5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -47,13 +47,13 @@ for: environment: WS: /Users/appveyor/projects TRIPLET: $PLATFORM-osx - ENABLE_CODE_COVERAGE: ON +# ENABLE_CODE_COVERAGE: ON cache: #- $WS/vcpkg - $WS/vcpkg/installed init: - sh: if [ $PLATFORM = "x86" ]; then exit 1; fi - - sh: brew install p7zip lcov + - sh: brew install p7zip #lcov - sh: cd $WS && git clone https://github.com/Microsoft/vcpkg.git - sh: cd $APPVEYOR_BUILD_FOLDER # /Library/Developer/CommandLineTools/usr/bin/llvm-cov diff --git a/sdl2-vga-terminal/CMakeLists.txt b/sdl2-vga-terminal/CMakeLists.txt index 46716446..aaf19f06 100644 --- a/sdl2-vga-terminal/CMakeLists.txt +++ b/sdl2-vga-terminal/CMakeLists.txt @@ -145,10 +145,6 @@ 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 @@ -181,20 +177,6 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "^GNU") ) target_link_options(vga-terminal-static PRIVATE $<$:-fprofile-arcs; -ftest-coverage; --coverage;>) endif() - - #if (BUILD_SHARED_LIBS) - # target_compile_options(vga-terminal INTERAFCE - # $<$: - # -O0;-D_GLIBCXX_DEBUG;-D_GLIBCXX_ASSERTIONS;-fexceptions; - # -W; -Wshadow; -Wunused-variable; - # -Wunused-parameter; -Wunused-function; -Wunused; -Wno-system-headers; - # -Wno-deprecated; -Woverloaded-virtual; -Wwrite-strings; -fprofile-arcs; -ftest-coverage; - # > - # $<$:-fexceptions;-D_FORTIFY_SOURCE=2> - # ) #-Werror) - # target_link_options(vga-terminal INTERFACE $<$:-fprofile-arcs; -ftest-coverage>;) - #endif() - elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang") target_compile_options(vga-terminal-static PRIVATE -WCL4 -Wabstract-vbase-init -Wassign-enum -Watomic-implicit-seq-cst -Watomic-properties -Wbad-function-cast -Wbinary-literal @@ -228,11 +210,6 @@ message("target interface compiler 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) -# get_target_property(vga-terminal_copts vga-terminal COMPILE_OPTIONS) -# message(STATUS "vga-terminal " ${vga-terminal_copts}) -# unset(vga-terminal_copts) -#endif()