blob: f83a1a9807791c81bdf6d49bc63ab54ace6e8ec0 [file] [log] [blame]
Jeff Gastonc58f3152021-04-09 12:45:53 -04001#!/bin/bash
2set -e
3
4echo "Starting $0 at $(date)"
5
6cd "$(dirname $0)"
7
8CHECKOUT_DIR="$(cd ../../.. && pwd)"
9OUT_DIR="$CHECKOUT_DIR/out"
10if [ "$DIST_DIR" == "" ]; then
11 DIST_DIR="$OUT_DIR/dist"
12fi
Jeff Gastonc095a4b2022-01-14 12:25:49 -050013if [ "$MANIFEST" == "" ]; then
14 export MANIFEST="$DIST_DIR/manifest_${BUILD_NUMBER}.xml"
15fi
Jeff Gastone18bf2a2021-05-11 12:31:42 -040016# move OUT_DIR and DIST_DIR into subdirectories so that if diagnose-build-failure deletes them, it doesn't interfere with any files generated by buildbot code
17export OUT_DIR="$OUT_DIR/incremental"
18mkdir -p "$OUT_DIR"
19export DIST_DIR="$DIST_DIR/incremental"
20mkdir -p "$DIST_DIR"
Jeff Gastonc58f3152021-04-09 12:45:53 -040021
Jeff Gaston436e8d62021-09-24 11:44:09 -040022if echo "$BUILD_NUMBER" | grep "P" >/dev/null; then
23 PRESUBMIT=true
24else
25 PRESUBMIT=false
26fi
27
Jeff Gaston12827d72022-04-26 17:49:20 -040028export USE_ANDROIDX_REMOTE_BUILD_CACHE=gcp
29
Jeff Gastonf41aff52022-03-10 11:25:53 -050030# hash the files in the out dir in case we want to confirm which files changed during the build
Jeff Gastonc58f3152021-04-09 12:45:53 -040031function hashOutDir() {
32 hashFile=out.hashes
33 echo "hashing out dir and saving into $DIST_DIR/$hashFile"
34 # We hash files in parallel for more performance (-P <number>)
35 # We limit the number of files hashed by any one process (-n <number>) to lower the risk of one
36 # process having to do much more work than the others.
37 # We do allow each process to hash multiple files (also -n <number>) to avoid spawning too many processes
38 # It would be nice to copy all files, but that takes a while
Jeff Gaston737977a2023-04-04 14:40:27 +000039 (cd $OUT_DIR && find -type f | grep -v "$hashFile" | xargs --no-run-if-empty -P 32 -n 64 sha1sum > $DIST_DIR/$hashFile)
Jeff Gastonc58f3152021-04-09 12:45:53 -040040 echo "done hashing out dir"
41}
Jeff Gaston737977a2023-04-04 14:40:27 +000042# disable temporarily b/276812697
43# hashOutDir
Jeff Gastonc58f3152021-04-09 12:45:53 -040044
Jeff Gaston436e8d62021-09-24 11:44:09 -040045# If we encounter a failure in postsubmit, we try a few things to determine if the failure is
46# reproducible
47DIAGNOSE_ARG=""
48if [ "$PRESUBMIT" == "false" ]; then
49 DIAGNOSE_ARG="--diagnose"
50fi
51
Jeff Gaston07d7d692021-06-14 10:50:04 -040052EXIT_VALUE=0
Alan Viveretteb3587572022-04-14 15:27:59 +000053
54# Validate translation exports, if present
55if ! impl/check_translations.sh; then
56 echo check_translations failed
Jeff Gaston8dc5c802021-10-20 17:12:01 -040057 EXIT_VALUE=1
Alan Viveretteb3587572022-04-14 15:27:59 +000058else
59 # Run Gradle
Jeff Gastone92d4d32022-09-19 12:35:15 -040060 if impl/build.sh $DIAGNOSE_ARG buildOnServer checkExternalLicenses listTaskOutputs \
Alan Viveretteb3587572022-04-14 15:27:59 +000061 --profile "$@"; then
62 echo build succeeded
63 EXIT_VALUE=0
64 else
65 echo build failed
66 EXIT_VALUE=1
67 fi
68
69 # Parse performance profile reports (generated with the --profile option above) and re-export the metrics in an easily machine-readable format for tracking
Jeff Gaston5248e302022-11-18 15:14:21 -050070 impl/parse_profile_data.sh
Jeff Gaston05918862021-05-19 16:57:42 -040071fi
Jeff Gastonc58f3152021-04-09 12:45:53 -040072
Alan Viveretteb3587572022-04-14 15:27:59 +000073echo "Completing $0 at $(date) with exit value $EXIT_VALUE"
Jeff Gaston07d7d692021-06-14 10:50:04 -040074
75exit "$EXIT_VALUE"