Jeff Gaston | 8aa46b3 | 2018-09-27 16:14:14 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -e |
Jeff Gaston | 8aa46b3 | 2018-09-27 16:14:14 -0400 | [diff] [blame] | 3 | |
Jeff Gaston | c104704 | 2019-07-17 16:48:16 -0400 | [diff] [blame] | 4 | DO_PROMPT=true |
| 5 | if [ "$1" == "-y" ]; then |
| 6 | DO_PROMPT=false |
| 7 | shift |
| 8 | fi |
| 9 | |
Jeff Gaston | 8aa46b3 | 2018-09-27 16:14:14 -0400 | [diff] [blame] | 10 | goals="$@" |
| 11 | |
| 12 | function usage() { |
Jeff Gaston | c104704 | 2019-07-17 16:48:16 -0400 | [diff] [blame] | 13 | echo |
| 14 | echo "Usage: $0 [-y] <tasks>" |
Jeff Gaston | 8aa46b3 | 2018-09-27 16:14:14 -0400 | [diff] [blame] | 15 | echo "Runs a clean build of <tasks>" |
Jeff Gaston | adffce4 | 2019-04-02 15:19:40 -0400 | [diff] [blame] | 16 | echo |
Jeff Gaston | c104704 | 2019-07-17 16:48:16 -0400 | [diff] [blame] | 17 | echo |
Jeff Gaston | adffce4 | 2019-04-02 15:19:40 -0400 | [diff] [blame] | 18 | echo "For example:" |
| 19 | echo |
| 20 | echo " $0 assembleDebug # or any other arguments you would normally give to ./gradlew" |
Jeff Gaston | c104704 | 2019-07-17 16:48:16 -0400 | [diff] [blame] | 21 | echo |
| 22 | echo |
| 23 | echo "-y" |
| 24 | echo " Don't prompt the user to confirm that they want to run a clean build" |
Jeff Gaston | 8aa46b3 | 2018-09-27 16:14:14 -0400 | [diff] [blame] | 25 | exit 1 |
| 26 | } |
| 27 | |
| 28 | if [ "$goals" == "" ]; then |
| 29 | usage |
| 30 | fi |
| 31 | |
Jeff Gaston | 3230825 | 2019-07-10 13:28:54 -0400 | [diff] [blame] | 32 | if [ ! -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 |
| 36 | fi |
| 37 | |
Jeff Gaston | cc0993d | 2019-04-02 18:02:44 -0400 | [diff] [blame] | 38 | function 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 Gaston | baa2b20 | 2021-04-23 15:44:59 -0400 | [diff] [blame] | 42 | echo "Press <Enter> to run a clean build (./gradlew --clean $goals) or Ctrl-C to cancel" |
Jeff Gaston | c104704 | 2019-07-17 16:48:16 -0400 | [diff] [blame] | 43 | if [ "$DO_PROMPT" == "true" ]; then |
| 44 | read response |
| 45 | fi |
Jeff Gaston | cc0993d | 2019-04-02 18:02:44 -0400 | [diff] [blame] | 46 | } |
| 47 | confirm |
| 48 | |
Jeff Gaston | 561cac2 | 2019-11-27 17:57:20 -0500 | [diff] [blame] | 49 | scriptDir="$(cd $(dirname $0) && pwd)" |
| 50 | checkoutDir="$(cd $scriptDir/../.. && pwd)" |
| 51 | export OUT_DIR="$checkoutDir/out" |
Jeff Gaston | 8aa46b3 | 2018-09-27 16:14:14 -0400 | [diff] [blame] | 52 | |
Jeff Gaston | baa2b20 | 2021-04-23 15:44:59 -0400 | [diff] [blame] | 53 | ./gradlew --clean $goals |