blob: f7421efc4ce9384bc52198f7d6fd44c9ceedb522 [file] [log] [blame]
Qiwen Zhaof5537ba2015-06-18 15:35:37 -07001#!/bin/bash
2
3set -e
4
5usage() {
6
7cat <<EOF
8 $0
9 --sdk <SDK file path>
10 --system <system sdk file path>
11 --support <support library file path>
12EOF
13 exit 2
14
15}
16
17banner() {
18 echo "**************************************************"
19 echo "Updating $1 "
20 echo "**************************************************"
21}
22
23update_sdk() {
24 if [ -f "$SDK" ]
25 then
26 banner "SDK"
27 cd $ROOT_DIR/current
28 rm -f android.jar uiautomator.jar framework.aidl
29 unzip -j $SDK */android.jar */uiautomator.jar */framework.aidl
30 fi
31}
32
33update_system_sdk() {
34 if [ -f "$SYSTEM_SDK" ]
35 then
36 banner "system SDK"
37 cp -f $SYSTEM_SDK $ROOT_DIR/system_current/android.jar
38 fi
39}
40
41update_support_lib() {
42 if [ -f "$SUPPORT" ]
43 then
44 banner "support library"
45 rm -rf $ROOT_DIR/current/support/
Qiwen Zhaoc1ee0e02015-07-08 09:02:57 -070046 cd $ROOT_DIR/current
Qiwen Zhaof5537ba2015-06-18 15:35:37 -070047 unzip $SUPPORT >/dev/null
48
49 # Remove duplicates
50 rm -f support/v7/appcompat/libs/android-support-v4.jar
51 rm -f support/multidex/instrumentation/libs/android-support-multidex.jar
52
53 # Remove samples
54 rm -rf support/samples
55
56 # Remove source files
57 find support -name "*.java" \
58 -o -name "*.aidl" \
59 -o -name AndroidManifest.xml \
60 | xargs rm
61
62 # Other misc files we don't need
63 find support -name "*.gradle" \
64 -o -name ".classpath" \
65 -o -name ".project" \
66 -o -name "project.properties" \
67 -o -name "source.properties" \
68 -o -name ".readme" \
69 -o -name "README.txt" \
70 -o -name "package.html" \
71 -o -name "NOTICE.txt" \
72 | xargs rm
73
74 # Now we can remove empty dirs
75 find . -type d -empty -delete
76 fi
77}
78
79main() {
80 while [ "$#" -gt 0 ]
81 do
82 case "$1" in
83 --help|-h)
84 usage
85 ;;
86 --sdk)
87 export SDK="$2"
88 shift; shift
89 ;;
90 --system)
91 export SYSTEM_SDK="$2"
92 shift; shift
93 ;;
94 --support)
95 export SUPPORT="$2"
96 shift; shift
97 ;;
98 -*)
99 usage
100 ;;
101 *)
102 break
103 ;;
104 esac
105 done
106
107 ROOT_DIR=$(realpath $(dirname $0))
108
109 update_sdk
110 update_system_sdk
111 update_support_lib
112}
113
114main $*