1#!/bin/bash -ex 2 3# This script updates the prebuilt test_framework-sdkextension.jar, which is 4# required when the "new APIs" added change. 5 6function gettop() { 7 local p=$(pwd) 8 while [[ ! -e "${p}/build/envsetup.sh" ]]; do 9 p="${p}/.." 10 done 11 echo $(readlink -f $p) 12} 13 14function is_aosp() { 15 grep -q 'https://android-review.googlesource.com' $(gettop)/.repo/manifests/default.xml 16} 17 18if [[ -z "$OUT" ]]; then 19 echo "lunch first" 20 exit 1 21fi 22 23dir=$(dirname $(readlink -f $BASH_SOURCE)) 24bps="${dir}/../framework/Android.bp" 25# AOSP does not use combined stubs, so needs special treatment. 26if is_aosp; then 27 bps="$bps $(gettop)/frameworks/base/Android.bp" 28fi 29 30for bp in $bps; do 31 if ! test -e $bp; then 32 echo $bp does not exist 33 exit 1 34 elif test -e "${bp}.bak"; then 35 echo "skipping ${bp} modification because ${bp}.bak exists" 36 continue 37 fi 38 cp $bp "${bp}.bak" 39 sed -i -e 's|":framework-sdkextensions-sources"|":framework-sdkextensions-sources",":test_framework-sdkextensions-sources"|' $bp 40done 41 42$(gettop)/build/soong/soong_ui.bash --make-mode framework-sdkextensions 43 44for bp in $bps; do mv "${bp}.bak" $bp ; touch $bp; done 45cp "${OUT}/apex/com.android.sdkext/javalib/framework-sdkextensions.jar" "${dir}/test_framework-sdkextensions.jar" 46