Debian Codegraph @

utils/health/clang-tidy-run-common.sh

raw symbols SCIP
1 #!/bin/bash -e
2
3 # Copyright (c) 2014-2022, The Monero Project
4 #
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without modification, are
8 # permitted provided that the following conditions are met:
9 #
10 # 1. Redistributions of source code must retain the above copyright notice, this list of
11 # conditions and the following disclaimer.
12 #
13 # 2. Redistributions in binary form must reproduce the above copyright notice, this list
14 # of conditions and the following disclaimer in the documentation and/or other
15 # materials provided with the distribution.
16 #
17 # 3. Neither the name of the copyright holder nor the names of its contributors may be
18 # used to endorse or promote products derived from this software without specific
19 # prior written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
22 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
24 # THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
29 # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 # clang-tidy runs lint checks on C & C++ sources and headers.
32 # Don't use this script directly but call clang-tidy-run-cc.sh or clang-tidy-run-cpp.sh instead
33
34 DIR_BUILD_BASE="build/clang-tidy"
35 RESULT_BASE="clang-tidy-result"
36
37 function tidy_for_language() {
38 LANG="${1}"
39 DIR_BUILD="${DIR_BUILD_BASE}-${LANG}"
40 RESULT="${RESULT_BASE}-${LANG}.txt"
41
42 mkdir -p "$DIR_BUILD" && pushd "$DIR_BUILD"
43 rm `find . -name "CMakeCache.txt"` || true
44
45 cmake ../.. \
46 -DCMAKE_C_COMPILER=clang \
47 -DCMAKE_CXX_COMPILER=clang++ \
48 -DUSE_CCACHE=ON \
49 -DUSE_CLANG_TIDY_${LANG}=ON \
50 -DBUILD_SHARED_LIBS=ON \
51 -DBUILD_TESTS=ON
52
53 make clean # Clean up, so that the result can be regenerated from scratch
54 time make -k 2>&1 | tee "$RESULT" # Build and store the result. -k means: ignore errors
55 #time make -k easylogging 2>&1 | tee "$RESULT" # Quick testing: build a single target
56 KPI=$(cat "$RESULT" | wc -l)
57 tar -cJvf "$RESULT.txz" "$RESULT" # Zip the result, because it's huge.
58 rm -v "$RESULT"
59 echo ""
60 echo "Readable result stored in: $DIR_BUILD/$RESULT.txz"
61
62 echo "$KPI" > "kpis.txt"
63
64 popd
65 }