Aurimas Liutikas | e98778c | 2020-03-16 16:29:07 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -e |
| 3 | |
Jeff Gaston | 868c502 | 2020-06-16 17:32:18 -0400 | [diff] [blame] | 4 | echo "Starting $0 at $(date)" |
| 5 | |
Jeff Gaston | d921159 | 2020-06-12 14:02:56 -0400 | [diff] [blame] | 6 | WORKING_DIR="$(pwd)" |
| 7 | SCRIPT_DIR="$(cd $(dirname $0) && pwd)" |
| 8 | cd "$(dirname $0)/../../.." |
Aurimas Liutikas | e98778c | 2020-03-16 16:29:07 -0700 | [diff] [blame] | 9 | echo "Script running from $(pwd)" |
| 10 | |
| 11 | # resolve DIST_DIR |
| 12 | if [ -z "$DIST_DIR" ]; then |
Jeff Gaston | d921159 | 2020-06-12 14:02:56 -0400 | [diff] [blame] | 13 | DIST_DIR="$WORKING_DIR/out/dist" |
Aurimas Liutikas | e98778c | 2020-03-16 16:29:07 -0700 | [diff] [blame] | 14 | fi |
| 15 | mkdir -p "$DIST_DIR" |
| 16 | |
Jeff Gaston | d921159 | 2020-06-12 14:02:56 -0400 | [diff] [blame] | 17 | export OUT_DIR=$(pwd)/out |
Aurimas Liutikas | 0a3c8f9 | 2020-03-17 09:38:25 -0700 | [diff] [blame] | 18 | export DIST_DIR="$DIST_DIR" |
Aurimas Liutikas | e98778c | 2020-03-16 16:29:07 -0700 | [diff] [blame] | 19 | |
Jeff Gaston | d921159 | 2020-06-12 14:02:56 -0400 | [diff] [blame] | 20 | if [ "$STUDIO_DIR" == "" ]; then |
| 21 | STUDIO_DIR="$WORKING_DIR" |
| 22 | else |
| 23 | STUDIO_DIR="$(cd $STUDIO_DIR && pwd)" |
| 24 | fi |
Aurimas Liutikas | 0a3c8f9 | 2020-03-17 09:38:25 -0700 | [diff] [blame] | 25 | |
Jeff Gaston | d921159 | 2020-06-12 14:02:56 -0400 | [diff] [blame] | 26 | TOOLS_DIR=$STUDIO_DIR/tools |
| 27 | gw=$TOOLS_DIR/gradlew |
| 28 | |
Jeff Gaston | 1a0d0c0 | 2020-11-23 11:40:51 -0500 | [diff] [blame] | 29 | function buildStudio() { |
| 30 | STUDIO_BUILD_LOG="$OUT_DIR/studio.log" |
| 31 | if JAVA_HOME="$STUDIO_DIR/prebuilts/studio/jdk/jdk11/linux" $gw -p $TOOLS_DIR publishLocal --stacktrace > "$STUDIO_BUILD_LOG" 2>&1; then |
| 32 | echo built studio successfully |
| 33 | else |
| 34 | cat "$STUDIO_BUILD_LOG" >&2 |
| 35 | echo failed to build studio |
| 36 | return 1 |
| 37 | fi |
| 38 | } |
| 39 | buildStudio |
Jeff Gaston | d921159 | 2020-06-12 14:02:56 -0400 | [diff] [blame] | 40 | |
| 41 | export GRADLE_PLUGIN_VERSION=`grep -oP "(?<=buildVersion = ).*" $TOOLS_DIR/buildSrc/base/version.properties` |
| 42 | export GRADLE_PLUGIN_REPO="$STUDIO_DIR/out/repo:$STUDIO_DIR/prebuilts/tools/common/m2/repository" |
Jeff Gaston | 4583258 | 2020-06-15 11:47:20 -0400 | [diff] [blame] | 43 | export JAVA_HOME="$(pwd)/prebuilts/jdk/jdk11/linux-x86/" |
Jeff Gaston | d921159 | 2020-06-12 14:02:56 -0400 | [diff] [blame] | 44 | export JAVA_TOOLS_JAR="$JAVA_HOME/lib/tools.jar" |
Aurimas Liutikas | ce5fb5d | 2020-03-30 18:06:01 +0000 | [diff] [blame] | 45 | export LINT_PRINT_STACKTRACE=true |
Aurimas Liutikas | 0a3c8f9 | 2020-03-17 09:38:25 -0700 | [diff] [blame] | 46 | |
Jeff Gaston | bdf9956 | 2020-08-05 14:16:34 -0400 | [diff] [blame] | 47 | function buildAndroidx() { |
Jeff Gaston | 41b9022 | 2020-08-18 11:09:55 -0400 | [diff] [blame] | 48 | LOG_PROCESSOR="$SCRIPT_DIR/../development/build_log_processor.sh" |
| 49 | properties="-Pandroidx.summarizeStderr --no-daemon -Pandroidx.allWarningsAsErrors" |
| 50 | "$LOG_PROCESSOR" $gw $properties -p frameworks/support listTaskOutputs && \ |
Aurimas Liutikas | c3df2c0 | 2021-02-17 17:09:33 +0000 | [diff] [blame] | 51 | "$LOG_PROCESSOR" $gw $properties -p frameworks/support bOS -x lintDebug -x lint -x validateLint -x verifyDependencyVersions --stacktrace -PverifyUpToDate |
Jeff Gaston | bdf9956 | 2020-08-05 14:16:34 -0400 | [diff] [blame] | 52 | } |
Jeff Gaston | 868c502 | 2020-06-16 17:32:18 -0400 | [diff] [blame] | 53 | |
Jeff Gaston | bdf9956 | 2020-08-05 14:16:34 -0400 | [diff] [blame] | 54 | function exportTransformsDir() { |
| 55 | echo exporting transforms directory |
| 56 | destDir="$DIST_DIR/transforms-2/files-2.1" |
| 57 | mkdir -p "$destDir" |
Jeff Gaston | 66d686a | 2020-11-23 16:36:18 -0500 | [diff] [blame] | 58 | zip -r "$DIST_DIR/transforms.zip" "$OUT_DIR/.gradle/caches/transforms-2/files-2.1" |
Jeff Gaston | bdf9956 | 2020-08-05 14:16:34 -0400 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | if buildAndroidx; then |
| 62 | echo build succeeded |
| 63 | else |
| 64 | # b/162260809 export transforms directory to help identify cause of corrupt/missing files |
| 65 | exportTransformsDir |
| 66 | exit 1 |
| 67 | fi |
Jeff Gaston | 868c502 | 2020-06-16 17:32:18 -0400 | [diff] [blame] | 68 | echo "Completing $0 at $(date)" |