blob: 3ab01d3e7a9ced8bfc0fa63ff5cea8f830187c8a [file] [log] [blame]
The Android Open Source Project55a2c712009-03-03 19:29:09 -08001#!/bin/bash
Raphael Molld9b2cbd2012-01-25 13:33:57 -08002# See usage() below for the description.
3
4function usage() {
5 cat <<EOF
Siva Velusamy6ca42e82011-12-08 14:25:37 -08006# This script copies the .jar files that each plugin depends on into the plugins libs folder.
7# By default, on Mac & Linux, this script creates symlinks from the libs folder to the jar file.
8# Since Windows does not support symlinks, the jar files are copied.
Raphael Molld9b2cbd2012-01-25 13:33:57 -08009#
10# Options:
11# -f : to copy files rather than creating symlinks on the Mac/Linux platforms.
12# -d : print make dependencies instead of running make; doesn't copy files.
13# -c : copy files expected after make dependencies (reported by -d) have been built.
14#
15# The purpose of -d/-c is to include the workflow in a make file:
16# - the make rule should depend on \$(shell create_all_symlinks -d)
17# - the rule body should perform \$(shell create_all_symlinks -c [-f])
18EOF
19}
The Android Open Source Project55a2c712009-03-03 19:29:09 -080020
Raphaele7e9d052011-11-07 13:39:29 -080021# CD to the top android directory
22PROG_DIR=`dirname "$0"`
23cd "${PROG_DIR}/../../../"
24
25HOST=`uname`
Raphael Molld9b2cbd2012-01-25 13:33:57 -080026USE_COPY="" # force copy dependent jar files rather than creating symlinks
27ONLY_SHOW_DEPS="" # only report make dependencies but don't build them nor copy.
28ONLY_COPY_DEPS="" # only copy dependencies built by make; uses -f as needed.
The Android Open Source Project55a2c712009-03-03 19:29:09 -080029
30function die() {
Raphael Molld9b2cbd2012-01-25 13:33:57 -080031 echo "Error: $*" >/dev/stderr
Raphaele7e9d052011-11-07 13:39:29 -080032 exit 1
The Android Open Source Project55a2c712009-03-03 19:29:09 -080033}
34
Raphael Molld9b2cbd2012-01-25 13:33:57 -080035function warn() {
36 # Only print something if not in show-deps mode
37 if [[ -z $ONLY_SHOW_DEPS ]]; then
38 echo "$*"
39 fi
40}
41
Siva Velusamy6ca42e82011-12-08 14:25:37 -080042## parse arguments
43while [ $# -gt 0 ]; do
Raphael Molld9b2cbd2012-01-25 13:33:57 -080044 case "$1" in
45 "-f" )
46 USE_COPY="1"
47 ;;
48 "-d" )
49 ONLY_SHOW_DEPS="1"
50 ;;
51 "-c" )
52 ONLY_COPY_DEPS="1"
53 ;;
54 * )
55 usage
56 exit 2
57 esac
Siva Velusamy6ca42e82011-12-08 14:25:37 -080058 shift
59done
Raphaele7e9d052011-11-07 13:39:29 -080060
Raphael Molld9b2cbd2012-01-25 13:33:57 -080061warn "## Running $0"
62
63if [[ "${HOST:0:6}" == "CYGWIN" || "$USE_MINGW" == "1" ]]; then
64 # This is either Cygwin or Linux/Mingw cross-compiling to Windows.
Siva Velusamy6ca42e82011-12-08 14:25:37 -080065 PLATFORM="windows-x86"
Raphael Molld9b2cbd2012-01-25 13:33:57 -080066 if [[ "${HOST:0:6}" == "CYGWIN" ]]; then
67 # We can't use symlinks under Cygwin
68 USE_COPY="1"
69 fi
70elif [[ "$HOST" == "Linux" ]]; then
71 PLATFORM="linux-x86"
72elif [[ "$HOST" == "Darwin" ]]; then
73 PLATFORM="darwin-x86"
Siva Velusamy6ca42e82011-12-08 14:25:37 -080074else
Raphael Molld9b2cbd2012-01-25 13:33:57 -080075 die "Unsupported platform ($HOST). Aborting."
Siva Velusamy6ca42e82011-12-08 14:25:37 -080076fi
77
Raphael Molld9b2cbd2012-01-25 13:33:57 -080078if [[ "$USE_COPY" == "1" ]]; then
Raphaele7e9d052011-11-07 13:39:29 -080079 function cpfile { # $1=source $2=dest
80 cp -fv $1 $2/
81 }
82
83 function cpdir() { # $1=source $2=dest
84 rsync -avW --delete-after $1 $2
85 }
86else
Raphaele7e9d052011-11-07 13:39:29 -080087 # computes the "reverse" path, e.g. "a/b/c" => "../../.."
88 function back() {
89 echo $1 | sed 's@[^/]*@..@g'
90 }
91
92 function cpfile { # $1=source $2=dest
93 ln -svf `back $2`/$1 $2/
94 }
95
96 function cpdir() { # $1=source $2=dest
97 ln -svf `back $2`/$1 $2
98 }
99fi
The Android Open Source Project55a2c712009-03-03 19:29:09 -0800100
Raphaelf1d64e22009-11-18 11:27:35 -0800101DEST="sdk/eclipse/scripts"
The Android Open Source Project55a2c712009-03-03 19:29:09 -0800102
103set -e # fail early
104
Raphaele7e9d052011-11-07 13:39:29 -0800105LIBS=""
106CP_FILES=""
107
Siva Velusamy8e6fabf2012-03-29 14:43:49 -0700108### BASE ###
109
110BASE_PLUGIN_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.base/libs"
111BASE_PLUGIN_LIBS="common sdkstats androidprefs sdklib"
112BASE_PLUGIN_PREBUILTS="\
Xavier Ducrohet8c39e292012-04-16 18:12:13 -0700113 prebuilts/tools/common/commons-compress/commons-compress-1.0.jar \
Siva Velusamy8e6fabf2012-03-29 14:43:49 -0700114 prebuilts/tools/common/guava-tools/guava-10.0.1.jar \
Xavier Ducrohet8c39e292012-04-16 18:12:13 -0700115 prebuilts/tools/common/http-client/commons-logging-1.1.1.jar \
116 prebuilts/tools/common/http-client/commons-codec-1.4.jar \
117 prebuilts/tools/common/http-client/httpclient-4.1.1.jar \
118 prebuilts/tools/common/http-client/httpcore-4.1.jar \
119 prebuilts/tools/common/http-client/httpmime-4.1.1.jar"
Siva Velusamy8e6fabf2012-03-29 14:43:49 -0700120
121LIBS="$LIBS $BASE_PLUGIN_LIBS"
122CP_FILES="$CP_FILES @:$BASE_PLUGIN_DEST $BASE_PLUGIN_LIBS $BASE_PLUGIN_PREBUILTS"
123
Raphaele7e9d052011-11-07 13:39:29 -0800124### ADT ###
125
126ADT_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.adt/libs"
Tor Norbye9bd06942012-04-04 18:41:06 -0700127ADT_LIBS="layoutlib_api lint_api lint_checks ide_common rule_api ninepatch sdkuilib assetstudio propertysheet"
Raphaele7e9d052011-11-07 13:39:29 -0800128ADT_PREBUILTS="\
129 prebuilt/common/kxml2/kxml2-2.3.0.jar \
Tor Norbyefaab5912011-12-03 13:41:39 -0800130 prebuilts/tools/common/asm-tools/asm-4.0.jar \
131 prebuilts/tools/common/asm-tools/asm-tree-4.0.jar \
Siva Velusamy8e6fabf2012-03-29 14:43:49 -0700132 prebuilts/tools/common/lombok-ast/lombok-ast-0.2.jar"
Raphaele7e9d052011-11-07 13:39:29 -0800133
134LIBS="$LIBS $ADT_LIBS"
135CP_FILES="$CP_FILES @:$ADT_DEST $ADT_LIBS $ADT_PREBUILTS"
136
Raphaele7e9d052011-11-07 13:39:29 -0800137### DDMS ###
138
139DDMS_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.ddms/libs"
140DDMS_LIBS="ddmlib ddmuilib swtmenubar"
141
142DDMS_PREBUILTS="\
Raphael Mollc4098ae2012-04-04 19:23:37 -0700143 prebuilts/tools/common/jfreechart/jcommon-1.0.12.jar \
144 prebuilts/tools/common/jfreechart/jfreechart-1.0.9.jar \
145 prebuilts/tools/common/jfreechart/jfreechart-1.0.9-swt.jar"
Raphaele7e9d052011-11-07 13:39:29 -0800146
147LIBS="$LIBS $DDMS_LIBS"
148CP_FILES="$CP_FILES @:$DDMS_DEST $DDMS_LIBS $DDMS_PREBUILTS"
149
150
151### TEST ###
152
153TEST_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.tests"
154TEST_LIBS="easymock"
155TEST_PREBUILTS="prebuilt/common/kxml2/kxml2-2.3.0.jar"
156
157LIBS="$LIBS $TEST_LIBS"
158CP_FILES="$CP_FILES @:$TEST_DEST $TEST_LIBS $TEST_PREBUILTS"
159
160
161### BRIDGE ###
162
163if [[ $PLATFORM != "windows-x86" ]]; then
164 # We can't build enough of the platform on Cygwin to create layoutlib
165 BRIDGE_LIBS="layoutlib ninepatch"
166
167 LIBS="$LIBS $BRIDGE_LIBS"
168fi
169
170
171
172### HIERARCHYVIEWER ###
173
174HV_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/libs"
175HV_LIBS="hierarchyviewerlib swtmenubar"
176
177LIBS="$LIBS $HV_LIBS"
178CP_FILES="$CP_FILES @:$HV_DEST $HV_LIBS"
179
180
181### TRACEVIEW ###
182
183TV_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.traceview/libs"
184TV_LIBS="traceview"
185
186LIBS="$LIBS $TV_LIBS"
187CP_FILES="$CP_FILES @:$TV_DEST $TV_LIBS"
188
189
190### SDKMANAGER ###
191
192SDMAN_LIBS="swtmenubar"
193
194LIBS="$LIBS $SDKMAN_LIBS"
195
Raphaele7e9d052011-11-07 13:39:29 -0800196### GL DEBUGGER ###
197
198if [[ $PLATFORM != "windows-x86" ]]; then
199 # liblzf doesn't build under cygwin. If necessary, this should be fixed first.
200
201 GLD_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.gldebugger/libs"
Siva Velusamy8e6fabf2012-03-29 14:43:49 -0700202 GLD_LIBS="host-libprotobuf-java-2.3.0-lite liblzf"
Raphaele7e9d052011-11-07 13:39:29 -0800203
204 LIBS="$LIBS $GLD_LIBS"
Siva Velusamy8e6fabf2012-03-29 14:43:49 -0700205 CP_FILES="$CP_FILES @:$GLD_DEST $GLD_LIBS"
Raphaele7e9d052011-11-07 13:39:29 -0800206fi
207
Raphael Molld9b2cbd2012-01-25 13:33:57 -0800208# In the mode to only echo dependencies, output them and we're done
209if [[ -n $ONLY_SHOW_DEPS ]]; then
210 echo $LIBS
211 exit 0
Raphaelf1c02632011-11-23 09:09:03 -0800212fi
213
Raphael Molld9b2cbd2012-01-25 13:33:57 -0800214if [[ -z $ONLY_COPY_DEPS ]]; then
215 # Make sure we have lunch sdk-<something>
216 if [[ ! "$TARGET_PRODUCT" ]]; then
217 warn "## TARGET_PRODUCT is not set, running build/envsetup.sh"
218 . build/envsetup.sh
219 warn "## lunch sdk-eng"
220 lunch sdk-eng
221 fi
Raphaele7e9d052011-11-07 13:39:29 -0800222
Raphael Molld9b2cbd2012-01-25 13:33:57 -0800223 # Run make on all libs
Raphaele7e9d052011-11-07 13:39:29 -0800224
Raphael Molld9b2cbd2012-01-25 13:33:57 -0800225 J="4"
226 [[ $(uname) == "Darwin" ]] && J=$(sysctl hw.ncpu | cut -d : -f 2 | tr -d ' ')
227 [[ $(uname) == "Linux" ]] && J=$(cat /proc/cpuinfo | grep processor | wc -l)
228
229 warn "## Building libs: make -j$J $LIBS"
230 make -j${J} $LIBS
231fi
Raphaele7e9d052011-11-07 13:39:29 -0800232
233# Copy resulting files
Raphaele7e9d052011-11-07 13:39:29 -0800234DEST=""
235for SRC in $CP_FILES; do
236 if [[ "${SRC:0:2}" == "@:" ]]; then
237 DEST="${SRC:2}"
238 mkdir -vp "$DEST"
239 continue
240 fi
241 if [[ ! -f "$SRC" ]]; then
Xavier Ducrohet34dbc5d2012-04-05 14:23:00 -0700242 ORIG_SRC="$SRC"
Raphaele7e9d052011-11-07 13:39:29 -0800243 SRC="out/host/$PLATFORM/framework/$SRC.jar"
244 fi
245 if [[ -f "$SRC" ]]; then
246 if [[ ! -d "$DEST" ]]; then
247 die "Invalid cp_file dest directory: $DEST"
248 fi
249
250 cpfile "$SRC" "$DEST"
251 else
Xavier Ducrohet34dbc5d2012-04-05 14:23:00 -0700252 die "## Unknown source '$ORIG_SRC' to copy in '$DEST'"
Raphaele7e9d052011-11-07 13:39:29 -0800253 fi
254done
255
256# OS-specific post operations
257
258if [ "${HOST:0:6}" == "CYGWIN" ]; then
259 chmod -v a+rx "$ADT_DEST"/*.jar
260fi
The Android Open Source Project55a2c712009-03-03 19:29:09 -0800261
262echo "### $0 done"