Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add a MAINTAINER_MODE in CMake.

Build with gcc and clang in maintainer mode in github CI.
  • Loading branch information
marcalff committed Oct 3, 2022
1 parent f21b3a0 commit 5871e92
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,38 @@ jobs:
sudo ./ci/setup_thrift.sh
./ci/do_ci.sh cmake.test
cmake_gcc_maintainer_test:
name: CMake gcc (maintainer mode)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: setup
run: |
sudo ./ci/setup_cmake.sh
sudo ./ci/setup_ci_environment.sh
- name: run cmake gcc (maintainer mode)
run: |
sudo ./ci/setup_thrift.sh
./ci/do_ci.sh cmake.maintainer.test
cmake_clang_maintainer_test:
name: CMake clang (maintainer mode)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: setup
run: |
sudo ./ci/setup_cmake.sh
sudo ./ci/setup_ci_environment.sh
- name: run cmake clang (maintainer mode)
run: |
sudo ./ci/setup_thrift.sh
CC=/usr/bin/clang CXX=/usr/bin/clang++ ./ci/do_ci.sh cmake.maintainer.test
cmake_deprecated_metrics_test:
name: CMake test (without otlp-exporter and with deprecated metrics)
runs-on: ubuntu-latest
Expand Down
48 changes: 48 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,54 @@ option(BUILD_TESTING "Whether to enable tests" ON)

option(BUILD_W3CTRACECONTEXT_TEST "Whether to build w3c trace context" OFF)

option(MAINTAINER_MODE "Build in maintainer mode (-Wall -Werror)" OFF)

if(MAINTAINER_MODE)

add_compile_options(-Wall)
add_compile_options(-Werror)
add_compile_options(-Wextra)

if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")

# Tested with GCC 9.4,
# compiling options most likely are available
# on older compilers as well.
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.4)
# Relaxed warnings

# Enforced warnings
endif()

endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")

# Tested with CLang 12.0.1,
# compiling options most likely are available
# on older compilers as well.
# FIXME: figure out which version is used in github ci.
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 1.0)
# Relaxed warnings
add_compile_options(-Wno-error=unused-private-field)

# Relaxed warning, for GRPC generated code.
add_compile_options(-Wno-error=shadow-field)

# Enforced warnings
add_compile_options(-Wconditional-uninitialized)
add_compile_options(-Wextra-semi)
add_compile_options(-Wheader-hygiene)
add_compile_options(-Wnon-virtual-dtor)
add_compile_options(-Wundefined-reinterpret-cast)
add_compile_options(-Wrange-loop-analysis)
add_compile_options(-Winconsistent-missing-destructor-override)
add_compile_options(-Winconsistent-missing-override)
add_compile_options(-Wnewline-eof)
endif()
endif()
endif(MAINTAINER_MODE)

if(WIN32)
if(BUILD_TESTING)
if(MSVC)
Expand Down
1 change: 1 addition & 0 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CI tests can be run on docker by invoking the script `./ci/run_docker.sh
./ci/do_ci.sh {TARGET}` where the targets are:

* `cmake.test`: build cmake targets and run tests.
* `cmake.maintainer.test`: build with cmake and test, in maintainer mode.
* `cmake.legacy.test`: build cmake targets with gcc 4.8 and run tests.
* `cmake.c++20.test`: build cmake targets with the C++20 standard and run tests.
* `cmake.test_example_plugin`: build and test an example OpenTelemetry plugin.
Expand Down
16 changes: 16 additions & 0 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,22 @@ if [[ "$1" == "cmake.test" ]]; then
make
make test
exit 0
elif [[ "$1" == "cmake.maintainer.test" ]]; then
cd "${BUILD_DIR}"
rm -rf *
cmake -DCMAKE_BUILD_TYPE=Debug \
-DWITH_PROMETHEUS=ON \
-DWITH_ZIPKIN=ON \
-DWITH_JAEGER=ON \
-DWITH_ELASTICSEARCH=ON \
-DWITH_LOGS_PREVIEW=ON \
-DWITH_METRICS_PREVIEW=OFF \
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
-DMAINTAINER_MODE=ON \
"${SRC_DIR}"
make
make test
exit 0
elif [[ "$1" == "cmake.with_async_export.test" ]]; then
cd "${BUILD_DIR}"
rm -rf *
Expand Down

0 comments on commit 5871e92

Please sign in to comment.