Debian Codegraph @

utils/health/clang-build-time-analyzer-run.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 # ClangBuildAnalyzer is able to analyze the aggregate build time of particular headers.
32
33 DIR_THIS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
34
35 # Build variables
36 PROG="ClangBuildAnalyzer"
37 PROG_PATH="$DIR_THIS/bin/$PROG"
38 DIR_BUILD="build/clang-build-analyser"
39
40 # ClangBuildAnalyzer variables
41 DIR_MONITORED="."
42 RESULT="cba-result.txt"
43 TRACE="cba-trace.txt"
44
45 if [ -f "$PROG_PATH" ]; then
46 echo "Found: $PROG_PATH"
47 else
48 echo "Couldn't find: $PROG_PATH"
49 echo "Please run the below script to clone and build $PROG:"
50 echo "$DIR_THIS/build-scripts/clang-build-time-analyzer-clone-build.sh"
51 exit 1
52 fi
53
54 mkdir -p "$DIR_BUILD" && cd "$DIR_BUILD"
55
56 cmake ../.. \
57 -DCMAKE_C_COMPILER=clang \
58 -DCMAKE_CXX_COMPILER=clang++ \
59 -DUSE_CCACHE=OFF \
60 -DUSE_COMPILATION_TIME_PROFILER=ON \
61 -DBUILD_SHARED_LIBS=ON \
62 -DBUILD_TESTS=ON
63
64 make clean # Clean up, so that the trace can be regenerated from scratch
65 $PROG_PATH --start $DIR_MONITORED # Start monitoring
66 time make # Build
67 #time make easylogging # Quick testing: build a single target
68 $PROG_PATH --stop $DIR_MONITORED $TRACE # Stop and output to trace file
69 $PROG_PATH --analyze $TRACE | tee $RESULT # Analyze the trace, and store it in a readable format
70 gzip -f $TRACE # Zip the trace, because it's huge. -f overwrites the previously generated trace
71
72 echo ""
73 echo "Readable result stored in: $DIR_BUILD/$RESULT"
74 echo "The trace (analyser's input data) in: $DIR_BUILD/$TRACE.gz"
75