xref: /aosp_15_r20/build/bazel/scripts/incremental_build/canonical_perf.sh (revision 7594170e27e0732bc44b93d1440d87a54b6ffe7c)
1*7594170eSAndroid Build Coastguard Worker#!/bin/bash
2*7594170eSAndroid Build Coastguard Worker#
3*7594170eSAndroid Build Coastguard Worker# Copyright (C) 2022 The Android Open Source Project
4*7594170eSAndroid Build Coastguard Worker#
5*7594170eSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License");
6*7594170eSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License.
7*7594170eSAndroid Build Coastguard Worker# You may obtain a copy of the License at
8*7594170eSAndroid Build Coastguard Worker#
9*7594170eSAndroid Build Coastguard Worker#      http://www.apache.org/licenses/LICENSE-2.0
10*7594170eSAndroid Build Coastguard Worker#
11*7594170eSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
12*7594170eSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS,
13*7594170eSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*7594170eSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and
15*7594170eSAndroid Build Coastguard Worker# limitations under the License.
16*7594170eSAndroid Build Coastguard Worker
17*7594170eSAndroid Build Coastguard Worker#
18*7594170eSAndroid Build Coastguard Worker# Gather and print top-line performance metrics for the android build
19*7594170eSAndroid Build Coastguard Worker#
20*7594170eSAndroid Build Coastguard Workerreadonly TOP="$(realpath "$(dirname "$0")/../../../..")"
21*7594170eSAndroid Build Coastguard Worker
22*7594170eSAndroid Build Coastguard Workerusage() {
23*7594170eSAndroid Build Coastguard Worker  cat <<EOF
24*7594170eSAndroid Build Coastguard Workerusage: $0 [-l LOG_DIR] [BUILD_TYPES]
25*7594170eSAndroid Build Coastguard Worker  -l    LOG_DIR should be outside of source tree, including not in out/,
26*7594170eSAndroid Build Coastguard Worker        because the whole tree will be cleaned during testing.
27*7594170eSAndroid Build Coastguard Workerexample:
28*7594170eSAndroid Build Coastguard Worker $0 soong prod
29*7594170eSAndroid Build Coastguard WorkerEOF
30*7594170eSAndroid Build Coastguard Worker  exit 1
31*7594170eSAndroid Build Coastguard Worker}
32*7594170eSAndroid Build Coastguard Worker
33*7594170eSAndroid Build Coastguard Workerdeclare -a build_types
34*7594170eSAndroid Build Coastguard Workerwhile getopts "l:" opt; do
35*7594170eSAndroid Build Coastguard Worker  case "$opt" in
36*7594170eSAndroid Build Coastguard Worker  l) log_dir=$OPTARG ;;
37*7594170eSAndroid Build Coastguard Worker  ?) usage ;;
38*7594170eSAndroid Build Coastguard Worker  esac
39*7594170eSAndroid Build Coastguard Workerdone
40*7594170eSAndroid Build Coastguard Workershift $((OPTIND - 1))
41*7594170eSAndroid Build Coastguard Workerreadonly -a build_types=("$@")
42*7594170eSAndroid Build Coastguard Worker
43*7594170eSAndroid Build Coastguard Workerlog_dir=${log_dir:-"$TOP/../timing-$(date +%b%d-%H%M)"}
44*7594170eSAndroid Build Coastguard Workerlog_dir=$(realpath "$log_dir")
45*7594170eSAndroid Build Coastguard Worker
46*7594170eSAndroid Build Coastguard Workerfunction build() {
47*7594170eSAndroid Build Coastguard Worker  date
48*7594170eSAndroid Build Coastguard Worker  set -x
49*7594170eSAndroid Build Coastguard Worker  if ! "$TOP/build/bazel/scripts/incremental_build/incremental_build.sh" \
50*7594170eSAndroid Build Coastguard Worker    --ignore-repo-diff --log-dir "$log_dir" \
51*7594170eSAndroid Build Coastguard Worker    ${build_types:+--build-types "${build_types[@]}"} \
52*7594170eSAndroid Build Coastguard Worker    "$@"; then
53*7594170eSAndroid Build Coastguard Worker    echo "See logs for errors"
54*7594170eSAndroid Build Coastguard Worker    exit 1
55*7594170eSAndroid Build Coastguard Worker  fi
56*7594170eSAndroid Build Coastguard Worker  set +x
57*7594170eSAndroid Build Coastguard Worker}
58*7594170eSAndroid Build Coastguard Workerbuild --cujs clean 'no change' 'create bionic/unreferenced.txt' 'modify Android.bp' -- droid
59*7594170eSAndroid Build Coastguard Workerbuild --cujs 'modify bionic/.*/stdio.cpp' --append-csv libc
60*7594170eSAndroid Build Coastguard Workerbuild --cujs 'modify .*/adb/daemon/main.cpp' --append-csv adbd
61*7594170eSAndroid Build Coastguard Workerbuild --cujs 'modify frameworks/.*/View.java' --append-csv framework
62*7594170eSAndroid Build Coastguard Workerbuild --cujs 'modify frameworks/.*/Settings.java' --append-csv framework-minus-apex
63