[go: nahoru, domu]

blob: a9f5b1a6c1afad2213cafe1bedc3acbc1535c819 [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 Gastonf41aff52022-03-10 11:25:53 -050039 (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}
42hashOutDir
43
Jeff Gaston436e8d62021-09-24 11:44:09 -040044# If we encounter a failure in postsubmit, we try a few things to determine if the failure is
45# reproducible
46DIAGNOSE_ARG=""
47if [ "$PRESUBMIT" == "false" ]; then
48 DIAGNOSE_ARG="--diagnose"
49fi
50
Jeff Gaston07d7d692021-06-14 10:50:04 -040051EXIT_VALUE=0
Alan Viveretteb3587572022-04-14 15:27:59 +000052
53# Validate translation exports, if present
54if ! impl/check_translations.sh; then
55 echo check_translations failed
Jeff Gaston8dc5c802021-10-20 17:12:01 -040056 EXIT_VALUE=1
Alan Viveretteb3587572022-04-14 15:27:59 +000057else
58 # Run Gradle
Jeff Gastone92d4d32022-09-19 12:35:15 -040059 if impl/build.sh $DIAGNOSE_ARG buildOnServer checkExternalLicenses listTaskOutputs \
Alan Viveretteb3587572022-04-14 15:27:59 +000060 --profile "$@"; then
61 echo build succeeded
62 EXIT_VALUE=0
63 else
64 echo build failed
65 EXIT_VALUE=1
66 fi
67
68 # 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 -050069 impl/parse_profile_data.sh
Jeff Gaston05918862021-05-19 16:57:42 -040070fi
Jeff Gastonc58f3152021-04-09 12:45:53 -040071
Alan Viveretteb3587572022-04-14 15:27:59 +000072echo "Completing $0 at $(date) with exit value $EXIT_VALUE"
Jeff Gaston07d7d692021-06-14 10:50:04 -040073
74exit "$EXIT_VALUE"