xref: /aosp_15_r20/build/bazel/scripts/analyze_build (revision 7594170e27e0732bc44b93d1440d87a54b6ffe7c)
1*7594170eSAndroid Build Coastguard Worker#!/bin/bash -eu
2*7594170eSAndroid Build Coastguard Worker
3*7594170eSAndroid Build Coastguard Worker# analyze_build is the main entry point for the platform build analysis toolkit.
4*7594170eSAndroid Build Coastguard Worker#
5*7594170eSAndroid Build Coastguard Worker# Main features:
6*7594170eSAndroid Build Coastguard Worker#
7*7594170eSAndroid Build Coastguard Worker# usage: analyze_build <one of the following options>
8*7594170eSAndroid Build Coastguard Worker#
9*7594170eSAndroid Build Coastguard Worker# timing: prints timing breakdown of the latest build
10*7594170eSAndroid Build Coastguard Worker# bp2build <module name>: prints if a module is converted by bp2build, or the reason why it is not converted.
11*7594170eSAndroid Build Coastguard Worker# build_files: compresses all generated build files into a tarball
12*7594170eSAndroid Build Coastguard Worker
13*7594170eSAndroid Build Coastguard Workerreadonly TOP="$(realpath "$(dirname "$0")/../../..")"
14*7594170eSAndroid Build Coastguard Workerif [[ -z ${OUT_DIR+x} ]]; then
15*7594170eSAndroid Build Coastguard Worker  OUT_DIR="$TOP/out"
16*7594170eSAndroid Build Coastguard Workerfi
17*7594170eSAndroid Build Coastguard Worker
18*7594170eSAndroid Build Coastguard Workerif [ ! -f ${OUT_DIR}/soong/workspace/WORKSPACE ]; then
19*7594170eSAndroid Build Coastguard Worker  echo "bp2build workspace does not exist. Have you run a Bazel-enabled build since last clean?"
20*7594170eSAndroid Build Coastguard Worker  exit 1
21*7594170eSAndroid Build Coastguard Workerfi
22*7594170eSAndroid Build Coastguard Worker
23*7594170eSAndroid Build Coastguard WorkerANDROID_BUILD_TOP=$TOP "$TOP/build/bazel/bin/bazel" run --config=bp2build --verbose_failures //build/bazel/scripts:print_analysis_metrics -- "$@"
24