From 40a438be3e0463b23984eb8b6debb4e84180ed63 Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Sun, 24 Feb 2019 15:31:46 -0500 Subject: [PATCH] FreeBSD fixes, GitLab CI build improvements. - use sccache for build caching - add coverage reports as build artifacts - add lcov-summary for coverage summary - clean up/refactor CI yaml This resolves the FreeBSD part of #754. --- .gitlab-ci.yml | 454 +++++++++++++++--- .travis.yml | 1 + cmake/CodeCoverage.cmake | 28 +- cmake/Conky.cmake | 8 + cmake/ConkyPlatformChecks.cmake | 5 +- src/conky.cc | 7 +- src/core.cc | 8 +- src/freebsd.cc | 30 +- src/iconv_tools.cc | 2 +- src/llua.cc | 3 + src/luamm.cc | 6 +- src/luamm.hh | 3 +- src/net_stat.cc | 6 + tests/CMakeLists.txt | 11 +- tests/dockerfiles/Dockerfile.centos6-base | 7 + tests/dockerfiles/Dockerfile.centos7-base | 7 + ...os7-clang-7 => Dockerfile.centos7-clang-5} | 2 + tests/dockerfiles/Dockerfile.fedora-base | 13 +- tests/dockerfiles/Dockerfile.fedora-clang-7 | 11 +- tests/dockerfiles/Dockerfile.ubuntu-base | 27 +- tests/dockerfiles/Dockerfile.ubuntu-clang-7 | 8 +- tests/llvm-gcov.sh | 17 +- 22 files changed, 537 insertions(+), 127 deletions(-) rename tests/dockerfiles/{Dockerfile.centos7-clang-7 => Dockerfile.centos7-clang-5} (71%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 93f9a14a..21ee6e3f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,6 @@ +--- stages: + - pull - base - dependencies - build @@ -6,10 +8,51 @@ stages: - deploy variables: - CC: clang-7 - CXX: clang++-7 + SCCACHE_GCS_BUCKET: btm-build-cache + SCCACHE_GCS_RW_MODE: READ_WRITE + SCCACHE_GCS_KEY_PATH: /tmp/storage-key.json DOCKER_DRIVER: overlay2 - DOCKER_HOST: tcp://localhost:2375/ + +before_script: + - echo $GCS_STORAGE_KEY > $SCCACHE_GCS_KEY_PATH + +.pull_images: &pull_images + stage: pull + allow_failure: true + image: docker:stable + services: + - docker:dind + script: + - set -- $CI_JOB_NAME + - export DISTRO=$2 + - export COMPILER=$3 + - "echo \"Distro: ${DISTRO}\nCompiler: ${COMPILER}\"" + - export DOCKER_HOST="${DOCKER_HOST:-tcp://localhost:2375/}" + - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY + # Pull either the last ref slug, or latest, depending on which exists + - docker pull $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_REF_SLUG || docker pull $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:latest + # If ref slug exists, use that, otherwise fallback to latest tag + - > + docker tag + $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_REF_SLUG + $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA || + docker tag + $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:latest + $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA + - docker push $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA + +pull ubuntu clang-7: *pull_images +pull ubuntu clang-8: *pull_images +pull ubuntu gcc-5: *pull_images +pull ubuntu gcc-6: *pull_images +pull ubuntu gcc-7: *pull_images +pull ubuntu gcc-8: *pull_images +pull fedora gcc-8: *pull_images +pull fedora clang-7: *pull_images +pull centos6 gcc-7: *pull_images +pull centos7 gcc-7: *pull_images +pull centos7 gcc-8: *pull_images +pull centos7 clang-5: *pull_images .docker_base_builder: &docker_base_builder retry: @@ -17,23 +60,33 @@ variables: when: - runner_system_failure - stuck_or_timeout_failure + - unknown_failure + - api_failure stage: base image: docker:stable - services: - - docker:dind only: changes: - - tests/dockerfiles/Dockerfile.$2-base + - tests/dockerfiles/* + services: + - docker:dind before_script: - set -- $CI_JOB_NAME - export DISTRO=$2 - "echo \"Distro: ${DISTRO}\nDocker base: ${DOCKER_BASE_IMAGE}\"" + - export DOCKER_HOST="${DOCKER_HOST:-tcp://localhost:2375/}" - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - docker pull $CI_REGISTRY_IMAGE/builder/$DISTRO-base:latest || true + - > + docker pull $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_REF_SLUG + || true script: - cd tests/dockerfiles - docker pull $DOCKER_BASE_IMAGE || true - - docker build -f Dockerfile.$DISTRO-base --cache-from $CI_REGISTRY_IMAGE/builder/$DISTRO-base:latest --tag $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_REF_SLUG . + - > + docker build -f Dockerfile.$DISTRO-base + --cache-from $CI_REGISTRY_IMAGE/builder/$DISTRO-base:latest + --tag $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_SHA + --tag $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_REF_SLUG . - docker push $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_SHA - docker push $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_REF_SLUG @@ -66,11 +119,26 @@ builder centos7 base: - export COMPILER=$3 - "echo \"Distro: ${DISTRO}\nCompiler: ${COMPILER}\"" - cd tests/dockerfiles - - docker pull $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:latest || true - - docker pull $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_REF_SLUG || true - - docker build -f Dockerfile.$DISTRO-$COMPILER --build-arg IMAGE=$CI_REGISTRY_IMAGE --cache-from $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:latest --cache-from $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_REF_SLUG --tag $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_REF_SLUG . + - > + docker tag $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_REF_SLUG + $CI_REGISTRY_IMAGE/builder/$DISTRO-base:latest + - > + docker pull $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_REF_SLUG + || true + - > + docker pull + $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_REF_SLUG + || true + - > + docker build -f Dockerfile.$DISTRO-$COMPILER + --build-arg IMAGE=$CI_REGISTRY_IMAGE + --cache-from $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_REF_SLUG + --tag $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA + --tag $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_REF_SLUG . - docker push ${CI_REGISTRY_IMAGE}/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA - - docker push ${CI_REGISTRY_IMAGE}/builder/$DISTRO-$COMPILER:$CI_COMMIT_REF_SLUG + - > + docker push + ${CI_REGISTRY_IMAGE}/builder/$DISTRO-$COMPILER:$CI_COMMIT_REF_SLUG builder ubuntu clang-7: *docker_builder builder ubuntu clang-8: *docker_builder @@ -83,7 +151,7 @@ builder fedora clang-7: *docker_builder builder centos6 gcc-7: *docker_builder builder centos7 gcc-7: *docker_builder builder centos7 gcc-8: *docker_builder -builder centos7 clang-7: *docker_builder +builder centos7 clang-5: *docker_builder .build_stages: &build_stages retry: @@ -91,32 +159,36 @@ builder centos7 clang-7: *docker_builder when: - runner_system_failure - stuck_or_timeout_failure - image: $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:latest + - unknown_failure + - api_failure + image: $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA stage: build script: - "echo \"Distro: ${DISTRO}\nCompiler: ${COMPILER}\nCC: $CC\nCXX: $CXX\"" - mkdir build - cd build - - | - cmake \ - -DCMAKE_EXE_LINKER_FLAGS=$LINKER_FLAGS \ - -DMAINTAINER_MODE=ON \ - -DBUILD_AUDACIOUS=$BUILD_AUDACIOUS \ - -DBUILD_MYSQL=ON \ - -DBUILD_LUA_IMLIB2=ON \ - -DBUILD_LUA_RSVG=$BUILD_LUA_RSVG \ - -DBUILD_LUA_CAIRO=$BUILD_LUA_CAIRO \ - -DBUILD_XMMS2=$BUILD_XMMS2 \ - -DBUILD_ICAL=ON \ - -DBUILD_IRC=ON \ - -DBUILD_HTTP=ON \ - -DBUILD_ICONV=ON \ - -DBUILD_PULSEAUDIO=ON \ - -DBUILD_JOURNAL=$BUILD_JOURNAL \ - -DBUILD_RSS=ON \ - -DBUILD_IRC=ON \ - -DBUILD_NVIDIA=$BUILD_NVIDIA \ - .. + - > + cmake + -DCMAKE_EXE_LINKER_FLAGS=$LINKER_FLAGS + -DCMAKE_C_COMPILER_LAUNCHER=sccache + -DCMAKE_CXX_COMPILER_LAUNCHER=sccache + -DMAINTAINER_MODE=ON + -DBUILD_AUDACIOUS=$BUILD_AUDACIOUS + -DBUILD_MYSQL=ON + -DBUILD_LUA_IMLIB2=ON + -DBUILD_LUA_RSVG=$BUILD_LUA_RSVG + -DBUILD_LUA_CAIRO=$BUILD_LUA_CAIRO + -DBUILD_XMMS2=$BUILD_XMMS2 + -DBUILD_ICAL=ON + -DBUILD_IRC=ON + -DBUILD_HTTP=ON + -DBUILD_ICONV=ON + -DBUILD_PULSEAUDIO=ON + -DBUILD_JOURNAL=$BUILD_JOURNAL + -DBUILD_RSS=ON + -DBUILD_IRC=ON + -DBUILD_NVIDIA=$BUILD_NVIDIA + .. - make -j4 .build_variables: &build_variables @@ -136,10 +208,8 @@ ubuntu clang-7: <<: *build_variables DISTRO: ubuntu COMPILER: clang-7 - artifacts: - expire_in: 1 day - paths: - - build/ + CC: clang-7 + CXX: clang++-7 ubuntu clang-8: <<: *build_stages @@ -258,12 +328,12 @@ centos7 gcc-8: before_script: - source /opt/rh/devtoolset-8/enable -centos7 clang-7: +centos7 clang-5: <<: *build_stages variables: <<: *build_variables DISTRO: centos7 - COMPILER: clang-7 + COMPILER: clang-5 CC: clang CXX: clang++ BUILD_AUDACIOUS: "OFF" @@ -273,40 +343,299 @@ centos7 clang-7: before_script: - source /opt/rh/llvm-toolset-7/enable +.freebsd_deps: &freebsd_deps + retry: + max: 2 + when: + - runner_system_failure + - stuck_or_timeout_failure + - unknown_failure + - api_failure + tags: + - freebsd12 + before_script: + # Try up to 5 times until installation succeeds. It may be locked. + - > + for i in {1..5}; do + sudo pkg install -y -q + cairo + docbook-xsl + docbook2X + gettext-runtime + imlib2 + lcov + libical + libiconv + libinotify + libircclient + libmicrohttpd + librsvg2 + libX11 + libXdamage + libXext + libXfixes + libXft + libXinerama + libxslt + lua53 + mysql80-client + pkgconf + xmms2 + $COMPILER_PACKAGE + && break || sleep $(expr $i \* $i + 1); done + +.freebsd_build_script: &freebsd_build_script + script: + - mkdir build + - cd build + - > + cmake + -DCMAKE_REQUIRED_INCLUDES="/usr/include;/usr/local/include" + -DCMAKE_EXE_LINKER_FLAGS=$LINKER_FLAGS + -DCMAKE_C_COMPILER_LAUNCHER=sccache + -DCMAKE_CXX_COMPILER_LAUNCHER=sccache + -DMAINTAINER_MODE=ON + -DBUILD_MYSQL=ON + -DBUILD_LUA_IMLIB2=ON + -DBUILD_LUA_RSVG=ON + -DBUILD_LUA_CAIRO=ON + -DBUILD_XMMS2=ON + -DBUILD_ICAL=ON + -DBUILD_IRC=ON + -DBUILD_HTTP=ON + -DBUILD_ICONV=ON + -DBUILD_RSS=ON + -DBUILD_IRC=ON + .. + - make -j4 + +freebsd12 gcc-8: + <<: *freebsd_deps + stage: build + variables: + DISTRO: freebsd12 + CC: gcc + CXX: g++ + COMPILER_PACKAGE: gcc + <<: *freebsd_build_script + +freebsd12 clang-7: + <<: *freebsd_deps + stage: build + variables: + DISTRO: freebsd12 + CC: clang + CXX: clang++ + COMPILER_PACKAGE: llvm70 + <<: *freebsd_build_script + .test_stages: &test_stages retry: max: 2 when: - runner_system_failure - stuck_or_timeout_failure + - unknown_failure + - api_failure + image: $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA + stage: test + +.test_run: &test_run + script: + - "echo \"Distro: ${DISTRO}\nCompiler: ${COMPILER}\nCC: $CC\nCXX: $CXX\"" + - mkdir build + - cd build + - > + cmake + -DCMAKE_C_COMPILER_LAUNCHER=sccache + -DCMAKE_CXX_COMPILER_LAUNCHER=sccache + -DMAINTAINER_MODE=ON + -DBUILD_TESTS=ON + .. + - make -j4 + - make -j4 test + - if [ "$COMPILER" == "clang-7" ] ; then make -j4 test-conky-coverage-txt ; fi + - if [ "$COMPILER" == "clang-7" ] ; then make -j4 test-conky-coverage-html ; fi + - if [ "$COMPILER" == "clang-7" ] ; then lcov-summary test-conky-coverage-html.info.cleaned ; fi + coverage: '/Total Coverage:\s+(\d+\.\d+)%/' + artifacts: + name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME-coverage-report" + paths: + - build/test-conky-coverage-html/ + +test ubuntu clang-7: + <<: *test_stages + <<: *test_run + variables: + DISTRO: ubuntu + COMPILER: clang-7 + CC: clang-7 + CXX: clang++-7 + +test ubuntu clang-8: + <<: *test_stages + <<: *test_run + variables: + DISTRO: ubuntu + COMPILER: clang-8 + CC: clang-8 + CXX: clang++-8 + +test ubuntu gcc-5: + <<: *test_stages + <<: *test_run + variables: + DISTRO: ubuntu + COMPILER: gcc-5 + CC: gcc-5 + CXX: g++-5 + +test ubuntu gcc-6: + <<: *test_stages + <<: *test_run + variables: + DISTRO: ubuntu + COMPILER: gcc-6 + CC: gcc-6 + CXX: g++-6 + +test ubuntu gcc-7: + <<: *test_stages + <<: *test_run + variables: + DISTRO: ubuntu + COMPILER: gcc-7 + CC: gcc-7 + CXX: g++-7 + +test ubuntu gcc-8: + <<: *test_stages + <<: *test_run + variables: + DISTRO: ubuntu + COMPILER: gcc-8 + CC: gcc-8 + CXX: g++-8 + +test fedora clang-7: + <<: *test_stages + <<: *test_run + variables: + DISTRO: fedora + COMPILER: clang-7 + CC: clang + CXX: clang++ + +test fedora gcc-8: + <<: *test_stages + <<: *test_run + variables: + DISTRO: fedora + COMPILER: gcc-8 + CC: gcc + CXX: g++ + +test centos6 gcc-7: + <<: *test_stages + <<: *test_run + variables: + DISTRO: centos7 + COMPILER: gcc-7 + CC: gcc + CXX: g++ + before_script: + - source /opt/rh/devtoolset-7/enable + +test centos7 clang-5: + <<: *test_stages + <<: *test_run + variables: + DISTRO: centos7 + COMPILER: clang-5 + CC: clang + CXX: clang++ + before_script: + - source /opt/rh/llvm-toolset-7/enable + +test centos7 gcc-7: + <<: *test_stages + <<: *test_run + variables: + DISTRO: centos7 + COMPILER: gcc-7 + CC: gcc + CXX: g++ + before_script: + - source /opt/rh/devtoolset-7/enable + +test centos7 gcc-8: + <<: *test_stages + <<: *test_run + variables: + DISTRO: centos7 + COMPILER: gcc-8 + CC: gcc + CXX: g++ + before_script: + - source /opt/rh/devtoolset-8/enable + +test freebsd12 clang-7: + <<: *freebsd_deps + <<: *test_run + variables: + DISTRO: freebsd12 + COMPILER: clang-7 + COMPILER_PACKAGE: llvm70 + CC: clang + CXX: clang++ + +test freebsd12 gcc-8: + <<: *freebsd_deps + <<: *test_run + variables: + DISTRO: freebsd12 + COMPILER: gcc-8 + COMPILER_PACKAGE: gcc + CC: gcc + CXX: g++ + +check clang-tidy: + <<: *test_stages variables: COMPILER: clang-7 DISTRO: ubuntu - image: $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_REF_SLUG - stage: test - -test and coverage: - <<: *test_stages + CC: clang-7 + CXX: clang++-7 script: - - "echo \"Distro: ${DISTRO}\nCompiler: ${COMPILER}\nCC: $CC\nCXX: $CXX\"" + - mkdir build - cd build - - cmake -DCMAKE_SOURCE_DIR=$(dirname `pwd`) -DCMAKE_BINARY_DIR=`pwd` -DMAINTAINER_MODE=ON -DBUILD_TESTS=ON .. + - > + cmake + -DCMAKE_C_COMPILER_LAUNCHER=sccache + -DCMAKE_CXX_COMPILER_LAUNCHER=sccache + -DMAINTAINER_MODE=ON + -DCHECK_CODE_QUALITY=ON + .. - make -j4 - - make -j4 test - - make -j4 test-conky-coverage-txt - -check-clang-tidy: - <<: *test_stages - script: - - cd build - - cmake -DCMAKE_SOURCE_DIR=$(dirname `pwd`) -DCMAKE_BINARY_DIR=`pwd` -DMAINTAINER_MODE=ON -DCHECK_CODE_QUALITY=ON .. - make -j4 check-clang-tidy -check-clang-format: +check clang-format: <<: *test_stages + variables: + COMPILER: clang-7 + DISTRO: ubuntu + CC: clang-7 + CXX: clang++-7 script: + - mkdir build - cd build - - cmake -DCMAKE_SOURCE_DIR=$(dirname `pwd`) -DCMAKE_BINARY_DIR=`pwd` -DMAINTAINER_MODE=ON -DCHECK_CODE_QUALITY=ON .. + - > + cmake + -DCMAKE_C_COMPILER_LAUNCHER=sccache + -DCMAKE_CXX_COMPILER_LAUNCHER=sccache + -DMAINTAINER_MODE=ON + -DCHECK_CODE_QUALITY=ON + .. - make -j4 check-clang-format .push_base_images: &push_base_images @@ -315,6 +644,8 @@ check-clang-format: when: - runner_system_failure - stuck_or_timeout_failure + - unknown_failure + - api_failure stage: deploy image: docker:stable services: @@ -324,13 +655,16 @@ check-clang-format: - master - tags before_script: + - export DOCKER_HOST="${DOCKER_HOST:-tcp://localhost:2375/}" - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY script: - set -- $CI_JOB_NAME - export DISTRO=$2 - 'echo "Distro: ${DISTRO}"' - docker pull $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_SHA - - docker tag $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE/builder/$DISTRO-base:latest + - > + docker tag $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_SHA + $CI_REGISTRY_IMAGE/builder/$DISTRO-base:latest - docker push $CI_REGISTRY_IMAGE/builder/$DISTRO-base:latest push ubuntu base: *push_base_images @@ -350,7 +684,9 @@ push fedora base: *push_base_images - export COMPILER=$3 - "echo \"Distro: ${DISTRO}\nCompiler: ${COMPILER}\"" - docker pull $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA - - docker tag $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:latest + - > + docker tag $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA + $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:latest - docker push $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:latest push ubuntu clang-7: *push_images @@ -364,4 +700,4 @@ push fedora clang-7: *push_images push centos6 gcc-7: *push_images push centos7 gcc-7: *push_images push centos7 gcc-8: *push_images -push centos7 clang-7: *push_images +push centos7 clang-5: *push_images diff --git a/.travis.yml b/.travis.yml index 7681b184..98ec7e0e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +--- language: cpp matrix: include: diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake index 621f924e..a95e85db 100644 --- a/cmake/CodeCoverage.cmake +++ b/cmake/CodeCoverage.cmake @@ -59,15 +59,29 @@ include(CMakeParseArguments) # Check prereqs -find_program(GCOV_PATH ${CMAKE_SOURCE_DIR}/tests/llvm-gcov.sh gcov) +find_program(GCOV_PATH + NAMES ${CMAKE_SOURCE_DIR}/tests/llvm-gcov.sh gcov + PATHS ENV PATH) find_program(LCOV_PATH NAMES lcov lcov.bat lcov.exe - lcov.perl) -find_program(LLVM_COV_PATH NAMES llvm-cov-7 llvm-cov-6 llvm-profdata) + lcov.perl + PATHS ENV PATH) +find_program(LLVM_COV_PATH + NAMES llvm-cov80 + llvm-cov-8 + llvm-cov70 + llvm-cov-7 + llvm-cov + PATHS ENV PATH) find_program(LLVM_PROFDATA_PATH - NAMES llvm-profdata-7 llvm-profdata-6 llvm-profdata) + NAMES llvm-profdata80 + llvm-profdata-8 + llvm-profdata70 + llvm-profdata-7 + llvm-profdata + PATHS ENV PATH) find_program(GENHTML_PATH NAMES genhtml genhtml.perl genhtml.bat) find_program(GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/scripts/test) find_program(SIMPLE_PYTHON_EXECUTABLE python) @@ -186,8 +200,7 @@ function(SETUP_TARGET_FOR_COVERAGE_LCOV_HTML) ${PROJECT_BINARY_DIR}/${Coverage_NAME}.info.cleaned # Clean up COMMAND ${CMAKE_COMMAND} -E remove ${Coverage_NAME}.base - ${Coverage_NAME}.total - ${PROJECT_BINARY_DIR}/${Coverage_NAME}.info.cleaned + ${Coverage_NAME}.total ${PROJECT_BINARY_DIR}/${Coverage_NAME}.info WORKING_DIRECTORY ${PROJECT_BINARY_DIR} DEPENDS ${Coverage_DEPENDENCIES} COMMENT @@ -198,7 +211,8 @@ function(SETUP_TARGET_FOR_COVERAGE_LCOV_HTML) add_custom_command( TARGET ${Coverage_NAME} POST_BUILD COMMAND ; - COMMENT "Lcov code coverage info report saved in ${Coverage_NAME}.info.") + COMMENT + "Lcov code coverage info report saved in ${Coverage_NAME}.info.cleaned") # Show info where to find the report add_custom_command( diff --git a/cmake/Conky.cmake b/cmake/Conky.cmake index 2d3cc04a..c8f9ffa2 100644 --- a/cmake/Conky.cmake +++ b/cmake/Conky.cmake @@ -105,6 +105,14 @@ if(NOT OS_DARWIN) ) endif(NOT OS_DARWIN) +if(OS_FREEBSD) + add_definitions(-D__BSD_VISIBLE=1 -D_XOPEN_SOURCE=700) + set( + CMAKE_REQUIRED_DEFINITIONS + "${CMAKE_REQUIRED_DEFINITIONS} -D_LARGEFILE64_SOURCE -D_POSIX_C_SOURCE=200809L -D__BSD_VISIBLE=1 -D_XOPEN_SOURCE=700" + ) +endif(OS_FREEBSD) + if(OS_DRAGONFLY) set(conky_libs ${conky_libs} -L/usr/pkg/lib) set(conky_includes ${conky_includes} -I/usr/pkg/include) diff --git a/cmake/ConkyPlatformChecks.cmake b/cmake/ConkyPlatformChecks.cmake index 2c452c18..49f5640f 100644 --- a/cmake/ConkyPlatformChecks.cmake +++ b/cmake/ConkyPlatformChecks.cmake @@ -61,7 +61,10 @@ endif(CMAKE_SYSTEM_NAME MATCHES "Linux") if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") set(OS_FREEBSD true) - set(conky_libs ${conky_libs} -lkvm -ldevstat -lbsd) + set(conky_libs ${conky_libs} -lkvm -ldevstat -lintl -linotify) + if(BUILD_IRC) + set(conky_libs ${conky_libs} -lssl -lcrypto) + endif(BUILD_IRC) endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") if(CMAKE_SYSTEM_NAME MATCHES "DragonFly") diff --git a/src/conky.cc b/src/conky.cc index 9ab764b7..d17a5484 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -49,7 +49,10 @@ #include #include #ifdef HAVE_SYS_INOTIFY_H +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wc99-extensions" #include +#pragma clang diagnostic pop #endif /* HAVE_SYS_INOTIFY_H */ #ifdef BUILD_X11 #pragma GCC diagnostic push @@ -131,10 +134,6 @@ #include #endif /* BUILD_HTTP */ -#if defined(__FreeBSD_kernel__) -#include -#endif - #ifdef BUILD_OLD_CONFIG #include "convertconf.h" #endif /* BUILD_OLD_CONFIG */ diff --git a/src/core.cc b/src/core.cc index f0b6228b..a7c32238 100644 --- a/src/core.cc +++ b/src/core.cc @@ -1098,11 +1098,11 @@ struct text_object *construct_text_object(char *s, const char *arg, long line, obj->callbacks.print = &print_sip_status; obj->callbacks.free = &gen_free_opaque; #else - END OBJ_IF_ARG( - if_running, 0, - "if_running needs an argument") char buf[text_buffer_size.get(*state)]; + END OBJ_IF_ARG(if_running, 0, "if_running needs an argument") - snprintf(buf, text_buffer_size.get(*state), "pidof %s >/dev/null", arg); + char buf[DEFAULT_TEXT_BUFFER_SIZE]; + + snprintf(buf, DEFAULT_TEXT_BUFFER_SIZE, "pidof %s >/dev/null", arg); obj->data.s = STRNDUP_ARG; /* XXX: maybe use a different callback here */ obj->callbacks.iftest = &if_running_iftest; diff --git a/src/freebsd.cc b/src/freebsd.cc index 008e3bee..5e5dcb8b 100644 --- a/src/freebsd.cc +++ b/src/freebsd.cc @@ -274,7 +274,6 @@ int update_running_processes(void) { void get_cpu_count(void) { int cpu_count = 0; - size_t cpu_count_len = sizeof(cpu_count); if (GETSYSCTL("hw.ncpu", cpu_count) == 0) { info.cpu_count = cpu_count; @@ -350,7 +349,7 @@ int update_cpu_usage(void) { fprintf(stderr, "Cannot get kern.cp_times\n"); } - for (i = 0; i < info.cpu_count; i++) { + for (i = 0; i < (int)info.cpu_count; i++) { total = 0; for (j = 0; j < CPUSTATES; j++) total += cp_time[i * CPUSTATES + j]; @@ -451,26 +450,7 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item) { } } -static int check_bat(const char *bat) { - int batnum, numbatts; - char *endptr; - if (GETSYSCTL("hw.acpi.battery.units", numbatts)) { - fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.units\"\n"); - return -1; - } - if (numbatts <= 0) { - fprintf(stderr, "No battery unit detected\n"); - return -1; - } - if (!bat || (batnum = strtol(bat, &endptr, 10)) < 0 || bat == endptr || - batnum > numbatts) { - fprintf(stderr, "Wrong battery unit %s requested\n", bat ? bat : ""); - return -1; - } - return batnum; -} - -int get_battery_perct(const char *bat) { +int get_battery_perct(const char *) { int batcapacity; get_battery_stats(nullptr, &batcapacity, NULL, NULL); @@ -602,7 +582,7 @@ int update_diskio(void) { struct device_selection *dev_select = nullptr; long select_generation; static struct statinfo statinfo_cur; - char device_name[text_buffer_size.get(*state)]; + char device_name[DEFAULT_TEXT_BUFFER_SIZE]; struct diskio_stat *cur; unsigned int reads, writes; unsigned int total_reads = 0, total_writes = 0; @@ -627,7 +607,7 @@ int update_diskio(void) { di = dev_select[dn].position; dev = &statinfo_cur.dinfo->devices[di]; - snprintf(device_name, text_buffer_size.get(*state), "%s%d", + snprintf(device_name, DEFAULT_TEXT_BUFFER_SIZE, "%s%d", dev_select[dn].device_name, dev_select[dn].unit_number); total_reads += (reads = dev->bytes[DEVSTAT_READ] / 512); @@ -661,7 +641,7 @@ void get_top_info(void) { p = kvm_getprocs(kd, KERN_PROC_PROC, 0, &n_processes); for (i = 0; i < n_processes; i++) { - if (!((p[i].ki_flag & P_SYSTEM)) && p[i].ki_comm != nullptr) { + if (!(p[i].ki_flag & P_SYSTEM)) { proc = get_process(p[i].ki_pid); proc->time_stamp = g_time; diff --git a/src/iconv_tools.cc b/src/iconv_tools.cc index c4ad0e01..a6d4bbb6 100644 --- a/src/iconv_tools.cc +++ b/src/iconv_tools.cc @@ -72,7 +72,7 @@ void free_iconv(struct text_object *obj) { void iconv_convert(size_t *a, char *buff_in, char *p, size_t p_max_size) { int bytes; size_t dummy1, dummy2; -#if defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__DragonFly__) const char *ptr = buff_in; #else char *ptr = buff_in; diff --git a/src/llua.cc b/src/llua.cc index 74f76bf5..e852c465 100644 --- a/src/llua.cc +++ b/src/llua.cc @@ -32,7 +32,10 @@ extern "C" { } #ifdef HAVE_SYS_INOTIFY_H +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wc99-extensions" #include +#pragma clang diagnostic pop void llua_append_notify(const char *name); void llua_rm_notifies(void); diff --git a/src/luamm.cc b/src/luamm.cc index 03bbc644..a7efc6cb 100644 --- a/src/luamm.cc +++ b/src/luamm.cc @@ -314,7 +314,7 @@ int state::gc(int what, int data) { pushinteger(what); pushinteger(data); call(2, 1, 0); - assert(isnumber(-1)); + assert(state::_isnumber(-1)); int r = tointeger(-1); pop(); return r; @@ -389,7 +389,7 @@ bool state::next(int index) { call(2, MULTRET, 0); - assert(isnumber(-1)); + assert(state::_isnumber(-1)); int r = tointeger(-1); pop(); return r != 0; @@ -427,7 +427,7 @@ bool state::safe_compare(lua_CFunction trampoline, int index1, int index2) { pushvalue(index1); pushvalue(index2); call(2, 1, 0); - assert(isnumber(-1)); + assert(state::_isnumber(-1)); int r = tointeger(-1); pop(); return r != 0; diff --git a/src/luamm.hh b/src/luamm.hh index acf65ff5..380d8e05 100644 --- a/src/luamm.hh +++ b/src/luamm.hh @@ -203,7 +203,8 @@ class state : private std::mutex { } bool isnil(int index) throw() { return lua_isnil(cobj.get(), index); } bool isnone(int index) throw() { return lua_isnone(cobj.get(), index); } - bool isnumber(int index) throw() { return lua_isnumber(cobj.get(), index); } + /* isnumber conflicts with some headers on BSD systems */ + bool _isnumber(int index) throw() { return lua_isnumber(cobj.get(), index); } bool isstring(int index) throw() { return lua_isstring(cobj.get(), index); } void pop(int n = 1) throw() { lua_pop(cobj.get(), n); } void pushboolean(bool b) throw() { lua_pushboolean(cobj.get(), b); } diff --git a/src/net_stat.cc b/src/net_stat.cc index 0a1c7ad1..699afc77 100644 --- a/src/net_stat.cc +++ b/src/net_stat.cc @@ -118,8 +118,10 @@ struct net_stat *get_net_stat(const char *dev, void * /*free_at_crash1*/, void parse_net_stat_arg(struct text_object *obj, const char *arg, void *free_at_crash) { +#ifdef BUILD_IPV6 bool shownetmask = false; bool showscope = false; +#endif /* BUILD_IPV6 */ char nextarg[21]; // longest arg possible is a devname (max 20 chars) int i = 0; struct net_stat *netstat = nullptr; @@ -152,6 +154,7 @@ void parse_net_stat_arg(struct text_object *obj, const char *arg, } while (sscanf(arg + i, " %20s", nextarg) == 1) { +#ifdef BUILD_IPV6 if (strcmp(nextarg, "-n") == 0 || strcmp(nextarg, "--netmask") == 0) { shownetmask = true; } else if (strcmp(nextarg, "-s") == 0 || strcmp(nextarg, "--scope") == 0) { @@ -162,8 +165,11 @@ void parse_net_stat_arg(struct text_object *obj, const char *arg, if (nextarg[j] == 's') { showscope = true; } } } else { +#endif /* BUILD_IPV6 */ netstat = get_net_stat(nextarg, obj, free_at_crash); +#ifdef BUILD_IPV6 } +#endif /* BUILD_IPV6 */ i += strlen(nextarg); // skip this arg while ( !((isspace(static_cast(arg[i])) != 0) || arg[i] == 0)) { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c6dbc62c..5a70b0d3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -20,11 +20,12 @@ catch_discover_tests(test-conky) if(USING_CLANG_7) set(COVERAGE_LCOV_EXCLUDES - "v1/*" - "/usr/include/**" - "/usr/lib/**" - "/usr/local/include/**" - "/usr/local/lib/**" + "*/include/c++/v1/*" + "/usr/include/*" + "/usr/lib/*" + "/usr/local/Cellar/*" + "/usr/local/include/*" + "/usr/local/lib/*" "/usr/include/libkern/i386/*" "/usr/include/sys/_types/*" "/usr/local/opt/gettext/include/*" diff --git a/tests/dockerfiles/Dockerfile.centos6-base b/tests/dockerfiles/Dockerfile.centos6-base index 85c33605..29518af3 100644 --- a/tests/dockerfiles/Dockerfile.centos6-base +++ b/tests/dockerfiles/Dockerfile.centos6-base @@ -1,5 +1,7 @@ FROM centos:6 +ENV SCCACHE_VER=0.2.8 + RUN yum update -y -q \ && yum -y -q install \ epel-release \ @@ -28,9 +30,14 @@ RUN yum update -y -q \ man \ mysql-devel \ ncurses-devel \ + openssl-devel \ patch \ pulseaudio-libs-devel \ readline-devel \ + && curl -sL https://github.com/mozilla/sccache/releases/download/${SCCACHE_VER}/sccache-${SCCACHE_VER}-x86_64-unknown-linux-musl.tar.gz -o sccache-${SCCACHE_VER}-x86_64-unknown-linux-musl.tar.gz \ + && tar xf sccache-${SCCACHE_VER}-x86_64-unknown-linux-musl.tar.gz \ + && cp sccache-${SCCACHE_VER}-x86_64-unknown-linux-musl/sccache /usr/bin \ + && rm -rf sccache-${SCCACHE_VER}-x86_64-unknown-linux-musl* \ && curl -L https://github.com/Kitware/CMake/releases/download/v3.13.4/cmake-3.13.4-Linux-x86_64.sh -o cmake-3.13.4-Linux-x86_64.sh \ && chmod +x cmake-3.13.4-Linux-x86_64.sh \ && ./cmake-3.13.4-Linux-x86_64.sh --prefix=/usr --skip-license \ diff --git a/tests/dockerfiles/Dockerfile.centos7-base b/tests/dockerfiles/Dockerfile.centos7-base index 7c27f63e..b8f0bb1e 100644 --- a/tests/dockerfiles/Dockerfile.centos7-base +++ b/tests/dockerfiles/Dockerfile.centos7-base @@ -1,5 +1,7 @@ FROM centos:7 +ENV SCCACHE_VER=0.2.8 + RUN yum update -y -q \ && yum -y -q install \ epel-release \ @@ -28,9 +30,14 @@ RUN yum update -y -q \ man \ mysql-devel \ ncurses-devel \ + openssl-devel \ patch \ pulseaudio-libs-devel \ readline-devel \ + && curl -sL https://github.com/mozilla/sccache/releases/download/${SCCACHE_VER}/sccache-${SCCACHE_VER}-x86_64-unknown-linux-musl.tar.gz -o sccache-${SCCACHE_VER}-x86_64-unknown-linux-musl.tar.gz \ + && tar xf sccache-${SCCACHE_VER}-x86_64-unknown-linux-musl.tar.gz \ + && cp sccache-${SCCACHE_VER}-x86_64-unknown-linux-musl/sccache /usr/bin \ + && rm -rf sccache-${SCCACHE_VER}-x86_64-unknown-linux-musl* \ && curl -L https://github.com/Kitware/CMake/releases/download/v3.13.4/cmake-3.13.4-Linux-x86_64.sh -o cmake-3.13.4-Linux-x86_64.sh \ && chmod +x cmake-3.13.4-Linux-x86_64.sh \ && ./cmake-3.13.4-Linux-x86_64.sh --prefix=/usr --skip-license \ diff --git a/tests/dockerfiles/Dockerfile.centos7-clang-7 b/tests/dockerfiles/Dockerfile.centos7-clang-5 similarity index 71% rename from tests/dockerfiles/Dockerfile.centos7-clang-7 rename to tests/dockerfiles/Dockerfile.centos7-clang-5 index b60404a8..66c9899c 100644 --- a/tests/dockerfiles/Dockerfile.centos7-clang-7 +++ b/tests/dockerfiles/Dockerfile.centos7-clang-5 @@ -3,4 +3,6 @@ FROM ${IMAGE}/builder/centos7-base:latest RUN yum -y -q install \ llvm-toolset-7-clang \ + llvm-toolset-7-llvm \ + llvm-toolset-7-clang-tools-extra \ && yum clean all diff --git a/tests/dockerfiles/Dockerfile.fedora-base b/tests/dockerfiles/Dockerfile.fedora-base index 64e358fd..a5fa5b6e 100644 --- a/tests/dockerfiles/Dockerfile.fedora-base +++ b/tests/dockerfiles/Dockerfile.fedora-base @@ -1,7 +1,9 @@ FROM fedora:latest -RUN yum update -y -q \ - && yum -y -q install \ +ENV SCCACHE_VER=0.2.8 + +RUN dnf update -y -q \ + && dnf -y -q install \ audacious-devel \ cairo-devel \ cmake \ @@ -28,8 +30,13 @@ RUN yum update -y -q \ man \ mysql-devel \ ncurses-devel \ + openssl-devel \ patch \ pulseaudio-libs-devel \ readline-devel \ systemd-devel \ - xmms2-devel + xmms2-devel \ + && curl -sL https://github.com/mozilla/sccache/releases/download/${SCCACHE_VER}/sccache-${SCCACHE_VER}-x86_64-unknown-linux-musl.tar.gz -o sccache-${SCCACHE_VER}-x86_64-unknown-linux-musl.tar.gz \ + && tar xf sccache-${SCCACHE_VER}-x86_64-unknown-linux-musl.tar.gz \ + && cp sccache-${SCCACHE_VER}-x86_64-unknown-linux-musl/sccache /usr/bin \ + && rm -rf sccache-${SCCACHE_VER}-x86_64-unknown-linux-musl* diff --git a/tests/dockerfiles/Dockerfile.fedora-clang-7 b/tests/dockerfiles/Dockerfile.fedora-clang-7 index a02bcc84..4023386c 100644 --- a/tests/dockerfiles/Dockerfile.fedora-clang-7 +++ b/tests/dockerfiles/Dockerfile.fedora-clang-7 @@ -1,8 +1,15 @@ ARG IMAGE=registry.gitlab.com/brndnmtthws-oss/conky FROM ${IMAGE}/builder/fedora-base:latest -RUN yum -y -q install \ +RUN dnf -y -q install \ + llvm \ clang \ libcxx-devel \ libcxxabi-devel \ - && yum clean all + && dnf clean all \ + && curl -Ls https://rpm.nodesource.com/setup_11.x -o npm.sh \ + && bash npm.sh \ + && rm npm.sh \ + && dnf -y -q install npm \ + && npm install -g lcov-summary \ + && npm cache clean --force diff --git a/tests/dockerfiles/Dockerfile.ubuntu-base b/tests/dockerfiles/Dockerfile.ubuntu-base index 1c8833f2..fb13e981 100644 --- a/tests/dockerfiles/Dockerfile.ubuntu-base +++ b/tests/dockerfiles/Dockerfile.ubuntu-base @@ -1,14 +1,18 @@ FROM ubuntu:bionic +ENV SCCACHE_VER=0.2.8 + RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive \ apt-get install -qy --no-install-recommends \ - software-properties-common \ - wget \ - gpg-agent \ - cmake \ - git \ audacious-dev \ + cmake \ + docbook2x \ + git \ + gpg \ + gpg-agent \ + lcov \ + less \ libaudclient-dev \ libcairo2-dev \ libcurl4-openssl-dev \ @@ -21,6 +25,7 @@ RUN apt-get update \ libmysqlclient-dev \ libpulse-dev \ librsvg2-dev \ + libssl-dev \ libsystemd-dev \ libxdamage-dev \ libxext-dev \ @@ -29,8 +34,12 @@ RUN apt-get update \ libxml2-dev \ libxmmsclient-dev \ libxnvctrl-dev \ - ncurses-dev \ - lcov \ - docbook2x \ man \ - less + ncurses-dev \ + software-properties-common \ + wget \ + && wget -q https://github.com/mozilla/sccache/releases/download/${SCCACHE_VER}/sccache-${SCCACHE_VER}-x86_64-unknown-linux-musl.tar.gz -O sccache-${SCCACHE_VER}-x86_64-unknown-linux-musl.tar.gz \ + && tar xf sccache-${SCCACHE_VER}-x86_64-unknown-linux-musl.tar.gz \ + && cp sccache-${SCCACHE_VER}-x86_64-unknown-linux-musl/sccache /usr/bin \ + && rm -rf sccache-${SCCACHE_VER}-x86_64-unknown-linux-musl* + diff --git a/tests/dockerfiles/Dockerfile.ubuntu-clang-7 b/tests/dockerfiles/Dockerfile.ubuntu-clang-7 index 035ea6e2..47aef529 100644 --- a/tests/dockerfiles/Dockerfile.ubuntu-clang-7 +++ b/tests/dockerfiles/Dockerfile.ubuntu-clang-7 @@ -15,4 +15,10 @@ RUN wget -q https://apt.llvm.org/llvm-snapshot.gpg.key \ clang-format-7 \ clang-tidy-7 \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* \ + && wget https://deb.nodesource.com/setup_11.x -O npm.sh \ + && bash npm.sh \ + && rm npm.sh \ + && apt-get install -y nodejs \ + && npm install -g lcov-summary \ + && npm cache clean --force diff --git a/tests/llvm-gcov.sh b/tests/llvm-gcov.sh index 0f79fb36..2cf68539 100755 --- a/tests/llvm-gcov.sh +++ b/tests/llvm-gcov.sh @@ -1,2 +1,15 @@ -#!/bin/bash -exec llvm-cov-7 gcov "$@" +#!/usr/bin/env bash + +if hash llvm-cov 2>/dev/null; then + llvm_cov="llvm-cov" +elif hash llvm-cov-7 2>/dev/null; then + llvm_cov="llvm-cov-7" +elif hash llvm-cov-8 2>/dev/null; then + llvm_cov="llvm-cov-8" +elif hash llvm-cov70 2>/dev/null; then + llvm_cov="llvm-cov70" +elif hash llvm-cov80 2>/dev/null; then + llvm_cov="llvm-cov80" +fi + +exec $llvm_cov gcov "$@"