blob: 1130b2fd598757488cfb2d42ecc1ab6e14d164c3 [file] [log] [blame]
Jeff Gaston8aa46b32018-09-27 16:14:14 -04001#!/bin/bash
2set -e
Jeff Gaston8aa46b32018-09-27 16:14:14 -04003
4echo "IF THIS SCRIPT FIXES YOUR BUILD; OPEN A BUG."
Jeff Gastoncc0993d2019-04-02 18:02:44 -04005echo "In nearly all cases, it should not be necessary to run a clean build."
6echo
7echo "You may be more interested in running:"
8echo
9echo " ./development/diagnose-build-failure/diagnose-build-failure.sh $*"
10echo
11echo "which attempts to diagnose more details about build failures"
Jeff Gaston8aa46b32018-09-27 16:14:14 -040012# one case where it is convenient to have a clean build is for double-checking that a build failure isn't due to an incremental build failure
13# another case where it is convenient to have a clean build is for performance testing
14# another case where it is convenient to have a clean build is when you're modifying the build and may have introduced some errors but haven't shared your changes yet (at which point you should have fixed the errors)
15echo
16
17goals="$@"
18
19function usage() {
20 echo "Usage: $0 <tasks>"
21 echo "Runs a clean build of <tasks>"
Jeff Gastonadffce42019-04-02 15:19:40 -040022 echo
23 echo "For example:"
24 echo
25 echo " $0 assembleDebug # or any other arguments you would normally give to ./gradlew"
Jeff Gaston8aa46b32018-09-27 16:14:14 -040026 exit 1
27}
28
29if [ "$goals" == "" ]; then
30 usage
31fi
32
Jeff Gaston32308252019-07-10 13:28:54 -040033if [ ! -e "./gradlew" ]; then
34 echo "Error; ./gradlew does not exist. Must cd to a dir containing a ./gradlew first"
35 # so that this script knows which gradlew to use (in frameworks/support or frameworks/support/ui)
36 exit 1
37fi
38
39
40
Jeff Gastoncc0993d2019-04-02 18:02:44 -040041function confirm() {
42 # Confirm whether the user wants to run this script instead of diagnose-build-failure.sh
43 # Recall that we already mentioned the existence of diagnose-build-failure.sh above
44 echo
45 echo "Press <Enter> to run a clean build or Ctrl-C to cancel"
46 read response
47}
48confirm
49
Jeff Gaston8aa46b32018-09-27 16:14:14 -040050export OUT_DIR=../../out
51function removeCaches() {
Jeff Gastoncc0993d2019-04-02 18:02:44 -040052 echo removing caches
Jeff Gaston79a43f22019-04-09 16:19:12 -040053 rm -rf .gradle
George Mount34ddc312018-10-24 13:53:18 -070054 rm -rf buildSrc/.gradle
Jeff Gaston8aa46b32018-09-27 16:14:14 -040055 rm -f local.properties
George Mount34ddc312018-10-24 13:53:18 -070056 rm -rf ../../out
Jeff Gaston8aa46b32018-09-27 16:14:14 -040057}
58removeCaches
59
60echo running build
61GRADLE_USER_HOME=../../out ./gradlew --no-daemon $goals