blob: 5b330b99184f584d4078c74ae48cd315b5dcfd10 [file] [log] [blame]
Jeff Gaston8aa46b32018-09-27 16:14:14 -04001#!/bin/bash
2set -e
Jeff Gaston8aa46b32018-09-27 16:14:14 -04003
Jeff Gastonc1047042019-07-17 16:48:16 -04004DO_PROMPT=true
5if [ "$1" == "-y" ]; then
6 DO_PROMPT=false
7 shift
8fi
9
Jeff Gaston8aa46b32018-09-27 16:14:14 -040010goals="$@"
11
12function usage() {
Jeff Gastonc1047042019-07-17 16:48:16 -040013 echo
14 echo "Usage: $0 [-y] <tasks>"
Jeff Gaston8aa46b32018-09-27 16:14:14 -040015 echo "Runs a clean build of <tasks>"
Jeff Gastonadffce42019-04-02 15:19:40 -040016 echo
Jeff Gastonc1047042019-07-17 16:48:16 -040017 echo
Jeff Gastonadffce42019-04-02 15:19:40 -040018 echo "For example:"
19 echo
Jeff Gaston6c1bd592021-04-29 12:53:47 -040020 echo " $0 assembleRelease # or any other arguments you would normally give to ./gradlew"
Jeff Gastonc1047042019-07-17 16:48:16 -040021 echo
22 echo
23 echo "-y"
24 echo " Don't prompt the user to confirm that they want to run a clean build"
Jeff Gaston8aa46b32018-09-27 16:14:14 -040025 exit 1
26}
27
28if [ "$goals" == "" ]; then
29 usage
30fi
31
Jeff Gaston32308252019-07-10 13:28:54 -040032if [ ! -e "./gradlew" ]; then
33 echo "Error; ./gradlew does not exist. Must cd to a dir containing a ./gradlew first"
34 # so that this script knows which gradlew to use (in frameworks/support or frameworks/support/ui)
35 exit 1
36fi
37
Jeff Gastoncc0993d2019-04-02 18:02:44 -040038function confirm() {
39 # Confirm whether the user wants to run this script instead of diagnose-build-failure.sh
40 # Recall that we already mentioned the existence of diagnose-build-failure.sh above
41 echo
Jeff Gastonbaa2b202021-04-23 15:44:59 -040042 echo "Press <Enter> to run a clean build (./gradlew --clean $goals) or Ctrl-C to cancel"
Jeff Gastonc1047042019-07-17 16:48:16 -040043 if [ "$DO_PROMPT" == "true" ]; then
44 read response
45 fi
Jeff Gastoncc0993d2019-04-02 18:02:44 -040046}
47confirm
48
Jeff Gaston561cac22019-11-27 17:57:20 -050049scriptDir="$(cd $(dirname $0) && pwd)"
50checkoutDir="$(cd $scriptDir/../.. && pwd)"
51export OUT_DIR="$checkoutDir/out"
Jeff Gaston8aa46b32018-09-27 16:14:14 -040052
Jeff Gastonbaa2b202021-04-23 15:44:59 -040053./gradlew --clean $goals