mirror of https://github.com/nextcloud/desktop
Enable warnings as errors when compiling with Clang and GCC
Signed-off-by: Felix Weilbach <felix.weilbach@nextcloud.com>
This commit is contained in:
parent
0074d6c40a
commit
88e7861239
|
@ -9,7 +9,7 @@ steps:
|
|||
path: /drone/build
|
||||
commands:
|
||||
- cd /drone/build
|
||||
- cmake -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_BUILD_TYPE=Debug -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DECM_ENABLE_SANITIZERS=address ../src
|
||||
- cmake -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_BUILD_TYPE=Debug -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DECM_ENABLE_SANITIZERS=address -DCMAKE_CXX_FLAGS=-Werror ../src
|
||||
- name: compile
|
||||
image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-2
|
||||
volumes:
|
||||
|
@ -53,7 +53,7 @@ steps:
|
|||
path: /drone/build
|
||||
commands:
|
||||
- cd /drone/build
|
||||
- cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_C_COMPILER=clang-10 -DCMAKE_CXX_COMPILER=clazy -DCMAKE_BUILD_TYPE=Debug -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DECM_ENABLE_SANITIZERS=address ../src
|
||||
- cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_C_COMPILER=clang-10 -DCMAKE_CXX_COMPILER=clang++-10 -DCMAKE_BUILD_TYPE=Debug -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DECM_ENABLE_SANITIZERS=address -DCMAKE_CXX_FLAGS=-Werror ../src
|
||||
- name: compile
|
||||
image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-2
|
||||
volumes:
|
||||
|
@ -61,7 +61,7 @@ steps:
|
|||
path: /drone/build
|
||||
commands:
|
||||
- cd /drone/build
|
||||
- ninja 2>1 | /drone/src/admin/linux/count_compiler_warnings.py /drone/src
|
||||
- ninja
|
||||
- name: test
|
||||
image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-2
|
||||
volumes:
|
||||
|
@ -149,4 +149,4 @@ trigger:
|
|||
- master
|
||||
event:
|
||||
- pull_request
|
||||
- push
|
||||
- push
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# Small script that counts the warnings which the compiler emits
|
||||
# and takes care that not more warnings are added.
|
||||
|
||||
import sys
|
||||
import re
|
||||
import requests
|
||||
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print(f"Usage: {sys.argv[0]} REPOSITORY_PATH")
|
||||
sys.exit(1)
|
||||
|
||||
repository_path = sys.argv[1]
|
||||
warning_regex = re.compile(r'warning:', re.M)
|
||||
max_allowed_warnings_count_response = requests.get(
|
||||
"https://nextclouddesktopwarningscount.felixweilbach.de")
|
||||
|
||||
if max_allowed_warnings_count_response.status_code != 200:
|
||||
print('Can not get maximum number of allowed warnings')
|
||||
sys.exit(1)
|
||||
|
||||
max_allowed_warnings_count = int(max_allowed_warnings_count_response.content)
|
||||
|
||||
print("Max number of allowed warnings:", max_allowed_warnings_count)
|
||||
|
||||
warnings_count = 0
|
||||
|
||||
for line in sys.stdin:
|
||||
if warning_regex.findall(line):
|
||||
warnings_count += 1
|
||||
|
||||
print(line, end="")
|
||||
|
||||
if warnings_count > max_allowed_warnings_count:
|
||||
print("Error: Too many warnings! You probably introduced a new warning!")
|
||||
sys.exit(1)
|
||||
|
||||
print("Total number of warnings:", warnings_count)
|
|
@ -27,7 +27,4 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
|
||||
endif()
|
||||
|
||||
if(DEFINED MIRALL_FATAL_WARNINGS)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
||||
endif(DEFINED MIRALL_FATAL_WARNINGS)
|
||||
endif()
|
||||
|
|
Loading…
Reference in New Issue