Skip to content

Commit

Permalink
-Werror param support for CI building
Browse files Browse the repository at this point in the history
  • Loading branch information
qdrvm-ci committed Jul 28, 2024
1 parent fa28047 commit b113682
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 26 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/zombie-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,20 @@ on:
- Release
- Debug
- RelWithDebInfo
werror:
description: 'Enable -Werror'
required: true
default: 'OFF'
type: 'choice'
options:
- 'ON'
- 'OFF'

env:
DOCKER_REGISTRY_PATH: ${{ secrets.GCP_REGISTRY }}/${{ secrets.GCP_PROJECT }}/kagome-dev/
BUILD_DIR: build
CTEST_OUTPUT_ON_FAILURE: 1
CI: true

CACHE_VERSION: v01
CACHE_PATH: ./build/cache
Expand Down Expand Up @@ -85,7 +94,8 @@ jobs:
DOCKER_REGISTRY_PATH=${DOCKER_REGISTRY_PATH} \
GITHUB_HUNTER_USERNAME=${{ secrets.HUNTER_USERNAME }} \
GITHUB_HUNTER_TOKEN=${{ secrets.HUNTER_TOKEN }} \
BUILD_TYPE=${{ github.event.inputs.build_type }}
BUILD_TYPE=${{ github.event.inputs.build_type }} \
WERROR=${{ github.event.inputs.werror }}

- name: "Push Kagome APT Package"
if: env.package_exist == 'False'
Expand Down
53 changes: 29 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ option(EMBEDDINGS "Embed developers assets" ON)
option(PROFILING "Enable internal profiling instruments" OFF)
option(BACKWARD "Enable stacktrace logging instruments" ON)
option(CLEAR_OBJS "Clear object files" OFF)
option(WERROR "Turn all warnings into errors" OFF)

if (NOT ($ENV{CI}) OR NOT ($ENV{GITHUB_ACTIONS}))
set(_EXTERNAL_PROJECT_DEFAULT ON)
Expand Down Expand Up @@ -125,31 +126,35 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(AppleClang|Clang|GNU)$")
add_flag(-Wno-format-nonliteral) # prints way too many warnings from spdlog
add_flag(-Wno-gnu-zero-variadic-macro-arguments) # https://stackoverflow.com/questions/21266380/is-the-gnu-zero-variadic-macro-arguments-safe-to-ignore

# cmake-format: on
if ((("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(AppleClang|Clang)$")
AND (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "12.0"))
OR (("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(GNU)$")
AND (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "9.0")))
# use new options format for clang >= 12 and gnu >= 9
# cmake-format: off
add_flag(-Werror=unused-lambda-capture) # error if lambda capture is unused
add_flag(-Werror=return-type) # warning: control reaches end of non-void function [-Wreturn-type]
add_flag(-Werror=sign-compare) # warn the user if they compare a signed and unsigned numbers
# breaks soralog headers
# add_flag(-Werror=reorder) # field '$1' will be initialized after field '$2'
add_flag(-Werror=mismatched-tags) # warning: class '$1' was previously declared as struct
add_flag(-Werror=switch) # unhandled values in a switch statement
# cmake-format: on
else ()
# promote to errors
# cmake-format: off
add_flag(-Werror-unused-lambda-capture) # error if lambda capture is unused
add_flag(-Werror-return-type) # warning: control reaches end of non-void function [-Wreturn-type]
add_flag(-Werror-non-virtual-dtor) # warn the user if a class with virtual functions has a non-virtual destructor. This helps catch hard to track down memory errors
add_flag(-Werror-sign-compare) # warn the user if they compare a signed and unsigned numbers
add_flag(-Werror-reorder) # field '$1' will be initialized after field '$2'
add_flag(-Werror-switch) # unhandled values in a switch statement
if(WERROR)
add_flag(-Werror) # turn all warnings into errors
else()
# cmake-format: on
if ((("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(AppleClang|Clang)$")
AND (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "12.0"))
OR (("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(GNU)$")
AND (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "9.0")))
# use new options format for clang >= 12 and gnu >= 9
# cmake-format: off
add_flag(-Werror=unused-lambda-capture) # error if lambda capture is unused
add_flag(-Werror=return-type) # warning: control reaches end of non-void function [-Wreturn-type]
add_flag(-Werror=sign-compare) # warn the user if they compare a signed and unsigned numbers
# breaks soralog headers
# add_flag(-Werror=reorder) # field '$1' will be initialized after field '$2'
add_flag(-Werror=mismatched-tags) # warning: class '$1' was previously declared as struct
add_flag(-Werror=switch) # unhandled values in a switch statement
# cmake-format: on
else ()
# promote to errors
# cmake-format: off
add_flag(-Werror-unused-lambda-capture) # error if lambda capture is unused
add_flag(-Werror-return-type) # warning: control reaches end of non-void function [-Wreturn-type]
add_flag(-Werror-non-virtual-dtor) # warn the user if a class with virtual functions has a non-virtual destructor. This helps catch hard to track down memory errors
add_flag(-Werror-sign-compare) # warn the user if they compare a signed and unsigned numbers
add_flag(-Werror-reorder) # field '$1' will be initialized after field '$2'
add_flag(-Werror-switch) # unhandled values in a switch statement
# cmake-format: on
endif ()
endif ()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# https://github.com/lefticus/cppbestpractices/blob/master/02-Use_the_Tools_Available.md#msvc
Expand Down
3 changes: 2 additions & 1 deletion housekeeping/docker/kagome-dev/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ DEPENDENCIES ?= libstdc++6, zlib1g, libgcc-s1, libc6, libtinfo6, libseccomp2, li
GITHUB_HUNTER_USERNAME ?=
GITHUB_HUNTER_TOKEN ?=
CTEST_OUTPUT_ON_FAILURE ?= 1
WERROR ?= OFF

# kagome_runtime_cache Variables
KAGOME_PACKAGE_VERSION ?=
Expand Down Expand Up @@ -94,7 +95,7 @@ kagome_dev_docker_build:
source /venv/bin/activate && \
git submodule update --init && \
echo \"Building in $$(pwd)\" && \
cmake . -B\"$(BUILD_DIR)\" -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=\"$(BUILD_TYPE)\" -DBACKWARD=OFF && \
cmake . -B\"$(BUILD_DIR)\" -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=\"$(BUILD_TYPE)\" -DBACKWARD=OFF -DWERROR=$(WERROR) && \
cmake --build \"$(BUILD_DIR)\" --target kagome -- -j${BUILD_THREADS} && \
mkdir -p /tmp/kagome && \
cp /opt/kagome/$(BUILD_DIR)/node/kagome /tmp/kagome/kagome && \
Expand Down

0 comments on commit b113682

Please sign in to comment.