Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More analyzers (cppcheck, clang-tidy, iwyu) #2078

Merged
merged 7 commits into from
Feb 15, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
Checks: ''
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ set(OGS_CPU_ARCHITECTURE "native" CACHE STRING "Processor architecture, \
option(OGS_ENABLE_AVX2 "Enable the use of AVX2 instructions" OFF)
option(OGS_BUILD_TESTS "Should the test executables be built?" ON)
option(OGS_USE_PCH "Should pre-compiled headers be used?" ON)
if(DEFINED CMAKE_CXX_CLANG_TIDY)
set(OGS_USE_PCH OFF CACHE INTERNAL "")
endif()
option(OGS_USE_CONAN "Should Conan package manager be used?" OFF)
set(OGS_CONAN_BUILD "missing" CACHE STRING "Possible values: all, missing, \
never or list of libs to build" )
Expand Down
6 changes: 2 additions & 4 deletions GeoLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ if(Qt5XmlPatterns_FOUND)
endif()

# Create the library
add_library(GeoLib ${SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/tetgen/predicates.cxx
)
add_library(GeoLib ${SOURCES})

target_link_libraries(GeoLib PUBLIC BaseLib MathLib logog)
target_link_libraries(GeoLib PUBLIC BaseLib MathLib logog PRIVATE tet)

if(Qt5XmlPatterns_FOUND)
target_link_libraries(GeoLib PUBLIC Qt5::Xml Qt5::XmlPatterns)
Expand Down
13 changes: 8 additions & 5 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,11 @@ pipeline {
stage('Master') {
when { environment name: 'JOB_NAME', value: 'ufz/ogs/master' }
parallel {
// ************************ Check-Header *******************************
stage('Check-Header') {
// ************************* Analyzers *********************************
stage('Analyzers') {
agent {
dockerfile {
filename 'Dockerfile.gcc.full'
filename 'Dockerfile.clang.full'
dir 'scripts/docker'
label 'docker'
args '-v ccache:/home/jenkins/cache/ccache -v conan-cache:/home/jenkins/cache/conan'
Expand All @@ -335,8 +335,11 @@ pipeline {
cmakeOptions =
'-DOGS_USE_CONAN=ON ' +
'-DOGS_CONAN_BUILD=never ' +
'"-DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=/usr/local/bin/include-what-you-use;--transitive_includes_only" '
config = 'Debug'
'"-DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=include-what-you-use" ' +
'-DCMAKE_LINK_WHAT_YOU_USE=ON ' +
'"-DCMAKE_CXX_CPPCHECK=cppcheck;--std=c++11;--language=c++;--suppress=syntaxError;--suppress=preprocessorErrorDirective:*/ThirdParty/*;--suppress=preprocessorErrorDirective:*conan*/package/*" ' +
'-DCMAKE_CXX_CLANG_TIDY=clang-tidy-3.9 '
config = 'Release'
}
}
build { target = 'check-header' }
Expand Down
3 changes: 3 additions & 0 deletions ThirdParty/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
# Disable all checks, one check has to be enabled (hack)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the hack?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no enabled check clang-tidy (at least in the way it is invoked by CMake) prints out its usage instructions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not find another way to specify that this folder should be ignored.

Copy link
Member

@endJunction endJunction Feb 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I neither do know. ;(
Just add this comment to the "hack", so we are not wondering why...

Checks: '-*,boost-use-to-string'
86 changes: 86 additions & 0 deletions scripts/docker/Dockerfile.clang.full
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
FROM ubuntu:16.04

RUN apt-get update && apt-get install -y software-properties-common curl \
&& add-apt-repository -y ppa:ubuntu-toolchain-r/test \
&& curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash \
&& apt-get update \
&& apt-get -y install \
build-essential \
ccache \
clang-3.9 \
git git-lfs \
python-pip \
sudo \
unzip \
xz-utils

RUN python -m pip install --upgrade pip \
&& python -m pip install cmake conan>=1.0.0

# Ninja
RUN curl -L -o ninja-linux.zip https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip \
&& unzip ninja-linux.zip \
&& mv ninja /usr/local/bin/ninja \
&& rm ninja-linux.zip

ENV CC=clang-3.9
ENV CXX=clang++-3.9

# Lis
RUN curl -L -o lis.tar.gz http://www.ssisc.org/lis/dl/lis-1.7.9.tar.gz \
&& tar xf lis.tar.gz \
&& cd lis-1.7.9 \
&& ./configure \
&& make -j$(nproc) install \
&& cd .. && rm -rf lis-1.7.9 lis.tar.gz

# Add user jenkins to the image
RUN adduser --uid 500 --disabled-password --gecos "" jenkins \
# Add user jenkins to sudoers with NOPASSWD
&& echo "jenkins ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \
# Set password for the jenkins user (you may want to alter this).
&& echo "jenkins:jenkins" | chpasswd

USER jenkins
ENV CCACHE_DIR=/home/jenkins/cache/ccache
RUN mkdir -p $CCACHE_DIR
ENV CCACHE_MAXSIZE=15G
ENV CCACHE_SLOPPINESS=pch_defines,time_macros
ENV CONAN_USER_HOME=/home/jenkins/cache/conan
WORKDIR /home/jenkins
RUN conan user

### END clang.minimal ###
USER root

RUN apt-get update \
&& apt-get -y install apt-transport-https curl \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" \
| tee /etc/apt/sources.list.d/yarn.list \
&& curl -s https://deb.nodesource.com/setup_8.x | bash \
&& apt-get update && apt-get install -y \
biber \
clang-tidy-3.9 \
cppcheck \
doxygen \
graphviz \
libxml2-utils \
nodejs \
pandoc-citeproc \
yarn

RUN update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10

# Hugo
RUN curl -L -o hugo.tar.gz https://github.com/gohugoio/hugo/releases/download/v0.32.3/hugo_0.32.3_Linux-64bit.tar.gz \
&& tar xf hugo.tar.gz \
&& mv hugo /usr/local/bin/hugo \
&& rm -rf hugo.tar.gz LICENSE.md README.md

# Include-what-you-use
RUN curl https://include-what-you-use.org/downloads/include-what-you-use-0.8-x86_64-linux-gnu-ubuntu-16.04.tar.gz -O \
&& tar xf include-what-you-use-0.8-x86_64-linux-gnu-ubuntu-16.04.tar.gz -C /usr/ --strip-components=1 \
&& rm include-what-you-use-0.8-x86_64-linux-gnu-ubuntu-16.04.tar.gz

USER jenkins
34 changes: 4 additions & 30 deletions scripts/docker/Dockerfile.clang.minimal
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ RUN apt-get update && apt-get install -y software-properties-common curl \
&& apt-get -y install \
build-essential \
ccache \
clang-3.9 \
git git-lfs \
python-pip \
sudo \
Expand All @@ -22,35 +23,8 @@ RUN curl -L -o ninja-linux.zip https://github.com/ninja-build/ninja/releases/dow
&& mv ninja /usr/local/bin/ninja \
&& rm ninja-linux.zip

# Install LLVM, see http://llvm.org/docs/CMake.html
RUN curl -L -o llvm.tar.xz http://releases.llvm.org/3.9.0/llvm-3.9.0.src.tar.xz \
&& tar -Jxf llvm.tar.xz \
&& mkdir build-llvm && cd build-llvm \
&& cmake ../llvm-3.9.0.src -DCMAKE_BUILD_TYPE=Release \
&& make -j$(nproc) install \
&& cd .. && rm -rf build-llvm llvm-3.9.0.src llvm.tar.xz

# Clang
RUN curl -L -o cfe-tar-xz http://releases.llvm.org/3.9.0/cfe-3.9.0.src.tar.xz \
&& tar -Jxf cfe-tar-xz \
&& mkdir build-cfe && cd build-cfe \
&& cmake ../cfe-3.9.0.src -DCMAKE_BUILD_TYPE=Release -DLLVM_CONFIG_PATH=/usr/local/bin/llvm-config \
&& make -j$(nproc) install \
&& cd .. && rm -rf build-cfe cfe-3.9.0.src cfe-tar-xz

ENV CC=clang
ENV CXX=clang++

# Compiler-rt
RUN curl -L -o compiler-rt.tar.xz http://releases.llvm.org/3.9.0/compiler-rt-3.9.0.src.tar.xz \
&& tar -Jxf compiler-rt.tar.xz \
&& mkdir build-compiler-rt && cd build-compiler-rt \
&& cmake ../compiler-rt-3.9.0.src -DCMAKE_BUILD_TYPE=Release -DLLVM_CONFIG_PATH=/usr/local/bin/llvm-config \
&& make -j$(nproc) install \
&& cd .. && rm -rf build-compiler-rt compiler-rt-3.9.0.src compiler-rt.tar.xz

RUN mkdir /usr/local/lib/clang/3.9.0/lib
RUN ln -s /usr/local/lib/linux /usr/local/lib/clang/3.9.0/lib/linux
ENV CC=clang-3.9
ENV CXX=clang++-3.9

# Lis
RUN curl -L -o lis.tar.gz http://www.ssisc.org/lis/dl/lis-1.7.9.tar.gz \
Expand All @@ -60,7 +34,7 @@ RUN curl -L -o lis.tar.gz http://www.ssisc.org/lis/dl/lis-1.7.9.tar.gz \
&& make -j$(nproc) install \
&& cd .. && rm -rf lis-1.7.9 lis.tar.gz

# Add user jenkins to the image
# Add user jenkins to the image
RUN adduser --uid 500 --disabled-password --gecos "" jenkins \
# Add user jenkins to sudoers with NOPASSWD
&& echo "jenkins ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \
Expand Down
4 changes: 3 additions & 1 deletion scripts/docker/Dockerfile.gcc.full
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ RUN apt-get update \
&& curl -s https://deb.nodesource.com/setup_8.x | bash \
&& apt-get update && apt-get install -y \
biber \
clang-tidy \
cppcheck \
doxygen \
graphviz \
libxml2-utils \
Expand All @@ -68,7 +70,7 @@ RUN curl -L -o hugo.tar.gz https://github.com/gohugoio/hugo/releases/download/v0

# Include-what-you-use
RUN curl https://include-what-you-use.org/downloads/include-what-you-use-0.8-x86_64-linux-gnu-ubuntu-16.04.tar.gz -O \
&& tar xf include-what-you-use-0.8-x86_64-linux-gnu-ubuntu-16.04.tar.gz -C /usr/local/ --strip-components=1 \
&& tar xf include-what-you-use-0.8-x86_64-linux-gnu-ubuntu-16.04.tar.gz -C /usr/ --strip-components=1 \
&& rm include-what-you-use-0.8-x86_64-linux-gnu-ubuntu-16.04.tar.gz

USER jenkins