File indexing completed on 2024-05-12 04:44:28

0001 #!/bin/bash
0002 
0003 # SPDX-FileCopyrightText: 2020-2023 Lukas Sommer <sommerluk@gmail.com>
0004 # SPDX-License-Identifier: BSD-2-Clause OR MIT
0005 
0006 
0007 
0008 
0009 
0010 ################# Configure #################
0011 
0012 # The “.” command will execute the given script within the context of
0013 # the current script, which is necessary in order to preserve the
0014 # environment variables that are set by the given script.
0015 . scripts/export-environment.sh
0016 
0017 
0018 
0019 
0020 
0021 ################# Run static code analysis #################
0022 
0023 # There are various applications available that do style checking, like
0024 # kwstyle (from Kitware) or cpplint (Google coding style). However,
0025 # this project follows KDE’s coding style, which is ensured by clang-format.
0026 # Because clang-format can also auto-correct the source code, it does not
0027 # make sense integrate it here. Use the build target “clang-format” to
0028 # correct automatically your code.
0029 
0030 # NOTE cppcheck is currently not used, though there is CMake support for it:
0031 # cmake “-DCMAKE_CXX_CPPCHECK=/usr/bin/cppcheck;–std=c++11” ../path/to/source
0032 # However, it seems that quite some configuration is necessary
0033 # to avoid too many false-positives when running it.
0034 
0035 # TODO Add (and compile, but only if necessary) dummy cpp files for each header
0036 #      that does not have an own cpp file. This will make static analysis more
0037 #      reliably.
0038 
0039 mkdir --parents build \
0040     && rm --recursive --force build/* \
0041     && cd build \
0042     \
0043     && echo "clazy, clang-tidy, iwyu started." \
0044     && cmake \
0045         -DCMAKE_CXX_COMPILER=clazy \
0046         -DCMAKE_CXX_CLANG_TIDY=/usr/bin/clang-tidy \
0047         -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=/usr/bin/iwyu \
0048             -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=FALSE \
0049         -DADDITIONAL_WARNINGS=ON \
0050         -DBUILD_WITH_QT6=ON \
0051         .. \
0052         > /dev/null \
0053     && nice --adjustment 19 \
0054         make --jobs $PARALLEL_PROCESSES --keep-going \
0055         > /dev/null \
0056     && echo "clazy, clang-tidy, iwyu finished." \
0057     \
0058     && cd .. \
0059     && rm --recursive --force build/* \
0060     \
0061 
0062 # Clean the directory even if one of the commands below has failed:
0063 mkdir --parents build \
0064     && rm --recursive --force build/* \