xref: /aosp_15_r20/external/robolectric/scripts/sync-android.sh (revision e6ba16074e6af37d123cb567d575f496bf0a58ee)
1*e6ba1607SAndroid Build Coastguard Worker#!/bin/bash
2*e6ba1607SAndroid Build Coastguard Worker#
3*e6ba1607SAndroid Build Coastguard Worker# This script sync and builds the AOSP source for a specified platform version.
4*e6ba1607SAndroid Build Coastguard Worker#
5*e6ba1607SAndroid Build Coastguard Worker# Usage:
6*e6ba1607SAndroid Build Coastguard Worker#   sync-android.sh <src root> <android version>
7*e6ba1607SAndroid Build Coastguard Worker#
8*e6ba1607SAndroid Build Coastguard Worker# This will create a <src root>/aosp-<android version>, sync the source for that version, and
9*e6ba1607SAndroid Build Coastguard Worker# attempt to build.
10*e6ba1607SAndroid Build Coastguard Worker#
11*e6ba1607SAndroid Build Coastguard Worker# You may need to customize the JAVA_6 or JAVA_7 install locations environment variables, or ensure
12*e6ba1607SAndroid Build Coastguard Worker# the right version of java is in your PATH when versions earlier than nougat. See
13*e6ba1607SAndroid Build Coastguard Worker# https://source.android.com/source/requirements#jdk for more details.
14*e6ba1607SAndroid Build Coastguard Worker#
15*e6ba1607SAndroid Build Coastguard Worker# See README.md for additional instructions
16*e6ba1607SAndroid Build Coastguard Worker
17*e6ba1607SAndroid Build Coastguard WorkerJAVA_6=/usr/lib/jvm/jdk1.6.0_45/bin
18*e6ba1607SAndroid Build Coastguard WorkerJAVA_7=/usr/lib/jvm/java-7-openjdk-amd64/bin
19*e6ba1607SAndroid Build Coastguard Worker
20*e6ba1607SAndroid Build Coastguard Workerfunction usage() {
21*e6ba1607SAndroid Build Coastguard Worker    echo "Usage: ${0} <android root path> <android-version> <parallel jobs>"
22*e6ba1607SAndroid Build Coastguard Worker}
23*e6ba1607SAndroid Build Coastguard Worker
24*e6ba1607SAndroid Build Coastguard Workerif [[ $# -ne 3 ]]; then
25*e6ba1607SAndroid Build Coastguard Worker    usage
26*e6ba1607SAndroid Build Coastguard Worker    exit 1
27*e6ba1607SAndroid Build Coastguard Workerfi
28*e6ba1607SAndroid Build Coastguard Worker
29*e6ba1607SAndroid Build Coastguard Workerset -ex
30*e6ba1607SAndroid Build Coastguard Worker
31*e6ba1607SAndroid Build Coastguard WorkerANDROID_VERSION=$2
32*e6ba1607SAndroid Build Coastguard WorkerSRC_ROOT=$1/aosp-$ANDROID_VERSION
33*e6ba1607SAndroid Build Coastguard WorkerJ=$3
34*e6ba1607SAndroid Build Coastguard Worker
35*e6ba1607SAndroid Build Coastguard Workersync_source() {
36*e6ba1607SAndroid Build Coastguard Worker    repo init -q --depth=1 -uhttps://android.googlesource.com/platform/manifest -b android-$ANDROID_VERSION
37*e6ba1607SAndroid Build Coastguard Worker    repo sync -cq -j$J
38*e6ba1607SAndroid Build Coastguard Worker}
39*e6ba1607SAndroid Build Coastguard Worker
40*e6ba1607SAndroid Build Coastguard Workerbuild_source() {
41*e6ba1607SAndroid Build Coastguard Worker    source build/envsetup.sh
42*e6ba1607SAndroid Build Coastguard Worker
43*e6ba1607SAndroid Build Coastguard Worker    if [[ "${ANDROID_VERSION}" == "4.1.2_r1" ]]; then
44*e6ba1607SAndroid Build Coastguard Worker        lunch generic_x86-eng
45*e6ba1607SAndroid Build Coastguard Worker        export PATH=$JAVA_6:$PATH
46*e6ba1607SAndroid Build Coastguard Worker        make -j$J
47*e6ba1607SAndroid Build Coastguard Worker    elif [[ "${ANDROID_VERSION}" == "4.2.2_r1.2" ]]; then
48*e6ba1607SAndroid Build Coastguard Worker        lunch generic_x86-eng
49*e6ba1607SAndroid Build Coastguard Worker        export PATH=$JAVA_6:$PATH
50*e6ba1607SAndroid Build Coastguard Worker        make -j$J
51*e6ba1607SAndroid Build Coastguard Worker    elif [[ "${ANDROID_VERSION}" == "4.3_r2" ]]; then
52*e6ba1607SAndroid Build Coastguard Worker        lunch aosp_x86-eng
53*e6ba1607SAndroid Build Coastguard Worker        export PATH=$JAVA_6:$PATH
54*e6ba1607SAndroid Build Coastguard Worker        make -j$J
55*e6ba1607SAndroid Build Coastguard Worker    elif [[ "${ANDROID_VERSION}" == "4.4_r1" ]]; then
56*e6ba1607SAndroid Build Coastguard Worker        lunch aosp_x86-eng
57*e6ba1607SAndroid Build Coastguard Worker        export PATH=$JAVA_6:$PATH
58*e6ba1607SAndroid Build Coastguard Worker        make -j$J
59*e6ba1607SAndroid Build Coastguard Worker    elif [[ "${ANDROID_VERSION}" == "5.0.2_r3" ]]; then
60*e6ba1607SAndroid Build Coastguard Worker        lunch aosp_x86-eng
61*e6ba1607SAndroid Build Coastguard Worker        tapas core-libart services services.accessibility telephony-common framework ext framework-res
62*e6ba1607SAndroid Build Coastguard Worker        export PATH=$JAVA_7:$PATH
63*e6ba1607SAndroid Build Coastguard Worker        ANDROID_COMPILE_WITH_JACK=false make -j$J
64*e6ba1607SAndroid Build Coastguard Worker    elif [[ "${ANDROID_VERSION}" == "5.1.1_r9" ]]; then
65*e6ba1607SAndroid Build Coastguard Worker        tapas core-libart services services.accessibility telephony-common framework ext framework-res
66*e6ba1607SAndroid Build Coastguard Worker        export PATH=$JAVA_7:$PATH
67*e6ba1607SAndroid Build Coastguard Worker        ANDROID_COMPILE_WITH_JACK=false make -j$J
68*e6ba1607SAndroid Build Coastguard Worker    elif [[ "${ANDROID_VERSION}" == "6.0.1_r3" ]]; then
69*e6ba1607SAndroid Build Coastguard Worker        tapas core-libart services services.accessibility telephony-common framework ext icu4j-icudata-jarjar framework-res
70*e6ba1607SAndroid Build Coastguard Worker        export PATH=$JAVA_7:$PATH
71*e6ba1607SAndroid Build Coastguard Worker        ANDROID_COMPILE_WITH_JACK=false make -j$J
72*e6ba1607SAndroid Build Coastguard Worker    elif [[ "${ANDROID_VERSION}" == "7.0.0_r1" ]]; then
73*e6ba1607SAndroid Build Coastguard Worker        cd ../..
74*e6ba1607SAndroid Build Coastguard Worker        lunch aosp_x86-eng
75*e6ba1607SAndroid Build Coastguard Worker        make -j$J
76*e6ba1607SAndroid Build Coastguard Worker        make -j$J out/target/common/obj/JAVA_LIBRARIES/services_intermediates/classes.jar out/host/linux-x86/framework/icu4j-icudata-host-jarjar.jar out/host/linux-x86/framework/icu4j-icutzdata-host-jarjar.jar
77*e6ba1607SAndroid Build Coastguard Worker    elif [[ "${ANDROID_VERSION}" == "7.1.0_r7" ]]; then
78*e6ba1607SAndroid Build Coastguard Worker        cd frameworks/base && git fetch https://android.googlesource.com/platform/frameworks/base refs/changes/75/310575/1 && git cherry-pick FETCH_HEAD && git commit -a -m "patch shortcut service"
79*e6ba1607SAndroid Build Coastguard Worker        cd ../..
80*e6ba1607SAndroid Build Coastguard Worker        lunch aosp_x86-eng
81*e6ba1607SAndroid Build Coastguard Worker        make -j$J
82*e6ba1607SAndroid Build Coastguard Worker        make -j$J out/target/common/obj/JAVA_LIBRARIES/services_intermediates/classes.jar out/host/linux-x86/framework/icu4j-icudata-host-jarjar.jar out/host/linux-x86/framework/icu4j-icutzdata-host-jarjar.jar
83*e6ba1607SAndroid Build Coastguard Worker    elif [[ "${ANDROID_VERSION}" == "8.0.0_r4" ]]; then
84*e6ba1607SAndroid Build Coastguard Worker        cd external/robolectric && git fetch https://android.googlesource.com/platform/external/robolectric refs/changes/24/516524/1 && git cherry-pick FETCH_HEAD
85*e6ba1607SAndroid Build Coastguard Worker        cd ../..
86*e6ba1607SAndroid Build Coastguard Worker        lunch aosp_x86-eng
87*e6ba1607SAndroid Build Coastguard Worker        make -j$J robolectric_android-all
88*e6ba1607SAndroid Build Coastguard Worker    else
89*e6ba1607SAndroid Build Coastguard Worker        echo "Robolectric: No match for version: ${ANDROID_VERSION}"
90*e6ba1607SAndroid Build Coastguard Worker        exit 1
91*e6ba1607SAndroid Build Coastguard Worker    fi
92*e6ba1607SAndroid Build Coastguard Worker}
93*e6ba1607SAndroid Build Coastguard Worker
94*e6ba1607SAndroid Build Coastguard Workermkdir -p $SRC_ROOT
95*e6ba1607SAndroid Build Coastguard Workercd $SRC_ROOT
96*e6ba1607SAndroid Build Coastguard Worker
97*e6ba1607SAndroid Build Coastguard Workersync_source
98*e6ba1607SAndroid Build Coastguard Workerbuild_source
99*e6ba1607SAndroid Build Coastguard Worker
100*e6ba1607SAndroid Build Coastguard Workerecho "Done building $SRC_ROOT!!"
101*e6ba1607SAndroid Build Coastguard Worker
102