aboutsummaryrefslogtreecommitdiff
path: root/maintainers/buildtime_report.sh
blob: 3f17ef5cec0c7363a267442a326bbc327abe49f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env bash

# Generates a report of build time based on a meson build using -ftime-trace in
# Clang.
if [ $# -lt 1 ]; then
    echo "usage: $0 BUILD-DIR [filename]" >&2
    exit 1
fi

scriptdir=$(cd "$(dirname -- "$0")" || exit ; pwd -P)
filename=${2:-$scriptdir/../buildtime.bin}

if [ "$(meson introspect "$1" --buildoptions | jq -r '.[]  | select(.name == "profile-build") | .value')" != enabled ]; then
    echo 'This build was not done with profile-build enabled, so cannot generate a report' >&2
    # shellcheck disable=SC2016
    echo 'Run `meson configure build -Dprofile-build=enabled` then rebuild, first' >&2
    exit 1
fi

ClangBuildAnalyzer --all "$1" "$filename" && ClangBuildAnalyzer --analyze "$filename"