blob: ebc3dc818897dfc85c3b18a6693487c00f671d7c [file] [log] [blame]
The Android Open Source Project55a2c712009-03-03 19:29:09 -08001#!/bin/bash
Siva Velusamy6ca42e82011-12-08 14:25:37 -08002# This script copies the .jar files that each plugin depends on into the plugins libs folder.
3# By default, on Mac & Linux, this script creates symlinks from the libs folder to the jar file.
4# Since Windows does not support symlinks, the jar files are copied.
5# Use option "-f" to copy files rather than creating symlinks on the Mac/Linux platforms.
The Android Open Source Project55a2c712009-03-03 19:29:09 -08006
Raphaele7e9d052011-11-07 13:39:29 -08007echo "## Running $0"
8# CD to the top android directory
9PROG_DIR=`dirname "$0"`
10cd "${PROG_DIR}/../../../"
11
12HOST=`uname`
Siva Velusamy6ca42e82011-12-08 14:25:37 -080013USE_COPY="" # force copy dependent jar files rather than creating symlinks
The Android Open Source Project55a2c712009-03-03 19:29:09 -080014
15function die() {
Raphaele7e9d052011-11-07 13:39:29 -080016 echo "Error: $*"
17 exit 1
The Android Open Source Project55a2c712009-03-03 19:29:09 -080018}
19
Siva Velusamy6ca42e82011-12-08 14:25:37 -080020## parse arguments
21while [ $# -gt 0 ]; do
22 if [ "$1" == "-f" ]; then
23 USE_COPY="1"
24 fi
25 shift
26done
Raphaele7e9d052011-11-07 13:39:29 -080027
Siva Velusamy6ca42e82011-12-08 14:25:37 -080028if [ "$HOST" == "Linux" ]; then
29 PLATFORM="linux-x86"
30elif [ "$HOST" == "Darwin" ]; then
31 PLATFORM="darwin-x86"
32elif [ "${HOST:0:6}" == "CYGWIN" ]; then
33 USE_COPY="1" # We can't use symlinks under Cygwin
34 PLATFORM="windows-x86"
35else
36 echo "Unsupported platform ($HOST). Aborting."
37 exit 1
38fi
39
40if [ "$USE_COPY" == "1" ]; then
Raphaele7e9d052011-11-07 13:39:29 -080041 function cpfile { # $1=source $2=dest
42 cp -fv $1 $2/
43 }
44
45 function cpdir() { # $1=source $2=dest
46 rsync -avW --delete-after $1 $2
47 }
48else
Raphaele7e9d052011-11-07 13:39:29 -080049 # computes the "reverse" path, e.g. "a/b/c" => "../../.."
50 function back() {
51 echo $1 | sed 's@[^/]*@..@g'
52 }
53
54 function cpfile { # $1=source $2=dest
55 ln -svf `back $2`/$1 $2/
56 }
57
58 function cpdir() { # $1=source $2=dest
59 ln -svf `back $2`/$1 $2
60 }
61fi
The Android Open Source Project55a2c712009-03-03 19:29:09 -080062
Raphaelf1d64e22009-11-18 11:27:35 -080063DEST="sdk/eclipse/scripts"
The Android Open Source Project55a2c712009-03-03 19:29:09 -080064
65set -e # fail early
66
Raphaele7e9d052011-11-07 13:39:29 -080067LIBS=""
68CP_FILES=""
69
70### ADT ###
71
72ADT_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.adt/libs"
73ADT_LIBS="sdkstats androidprefs common layoutlib_api lint_api lint_checks ide_common rule_api ninepatch sdklib sdkuilib assetstudio"
74ADT_PREBUILTS="\
75 prebuilt/common/kxml2/kxml2-2.3.0.jar \
76 prebuilt/common/commons-compress/commons-compress-1.0.jar \
77 prebuilt/common/http-client/httpclient-4.1.1.jar \
78 prebuilt/common/http-client/httpcore-4.1.jar \
79 prebuilt/common/http-client/httpmime-4.1.1.jar \
80 prebuilt/common/http-client/commons-logging-1.1.1.jar \
81 prebuilt/common/http-client/commons-codec-1.4.jar"
82
83LIBS="$LIBS $ADT_LIBS"
84CP_FILES="$CP_FILES @:$ADT_DEST $ADT_LIBS $ADT_PREBUILTS"
85
86
87### DDMS ###
88
89DDMS_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.ddms/libs"
90DDMS_LIBS="ddmlib ddmuilib swtmenubar"
91
92DDMS_PREBUILTS="\
93 prebuilt/common/jfreechart/jcommon-1.0.12.jar \
94 prebuilt/common/jfreechart/jfreechart-1.0.9.jar \
95 prebuilt/common/jfreechart/jfreechart-1.0.9-swt.jar"
96
97LIBS="$LIBS $DDMS_LIBS"
98CP_FILES="$CP_FILES @:$DDMS_DEST $DDMS_LIBS $DDMS_PREBUILTS"
99
100
101### TEST ###
102
103TEST_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.tests"
104TEST_LIBS="easymock"
105TEST_PREBUILTS="prebuilt/common/kxml2/kxml2-2.3.0.jar"
106
107LIBS="$LIBS $TEST_LIBS"
108CP_FILES="$CP_FILES @:$TEST_DEST $TEST_LIBS $TEST_PREBUILTS"
109
110
111### BRIDGE ###
112
113if [[ $PLATFORM != "windows-x86" ]]; then
114 # We can't build enough of the platform on Cygwin to create layoutlib
115 BRIDGE_LIBS="layoutlib ninepatch"
116
117 LIBS="$LIBS $BRIDGE_LIBS"
118fi
119
120
121
122### HIERARCHYVIEWER ###
123
124HV_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/libs"
125HV_LIBS="hierarchyviewerlib swtmenubar"
126
127LIBS="$LIBS $HV_LIBS"
128CP_FILES="$CP_FILES @:$HV_DEST $HV_LIBS"
129
130
131### TRACEVIEW ###
132
133TV_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.traceview/libs"
134TV_LIBS="traceview"
135
136LIBS="$LIBS $TV_LIBS"
137CP_FILES="$CP_FILES @:$TV_DEST $TV_LIBS"
138
139
140### SDKMANAGER ###
141
142SDMAN_LIBS="swtmenubar"
143
144LIBS="$LIBS $SDKMAN_LIBS"
145
Siva Velusamy6ca42e82011-12-08 14:25:37 -0800146### MONITOR ###
147
148MONITOR_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.monitor/libs"
149MONITOR_LIBS="sdklib sdkstats androidprefs"
150
151LIBS="$LIBS $MONITOR_LIBS"
152CP_FILES="$CP_FILES @:$MONITOR_DEST $MONITOR_LIBS"
Raphaele7e9d052011-11-07 13:39:29 -0800153
154### GL DEBUGGER ###
155
156if [[ $PLATFORM != "windows-x86" ]]; then
157 # liblzf doesn't build under cygwin. If necessary, this should be fixed first.
158
159 GLD_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.gldebugger/libs"
Siva Velusamyc527b7e2011-11-13 11:47:12 -0800160 GLD_LIBS="host-libprotobuf-java-2.3.0-lite liblzf sdklib ddmlib"
Raphaele7e9d052011-11-07 13:39:29 -0800161
162 LIBS="$LIBS $GLD_LIBS"
163 CP_FILES="$CP_FILES @:$GLD_DEST $GLD_LIBS"
164fi
165
Raphaelf1c02632011-11-23 09:09:03 -0800166# Make sure we have lunch sdk-<something>
167if [[ ! "$TARGET_PRODUCT" ]]; then
Siva Velusamy6ca42e82011-12-08 14:25:37 -0800168 echo "## TARGET_PRODUCT is not set, running build/envsetup.sh"
Raphaelf1c02632011-11-23 09:09:03 -0800169 . build/envsetup.sh
Siva Velusamy6ca42e82011-12-08 14:25:37 -0800170 echo "## lunch sdk-eng"
Raphaelf1c02632011-11-23 09:09:03 -0800171 lunch sdk-eng
172fi
173
Raphaele7e9d052011-11-07 13:39:29 -0800174# Run make on all libs
175
176J="4"
177[[ $(uname) == "Darwin" ]] && J=$(sysctl hw.ncpu | cut -d : -f 2 | tr -d ' ')
178[[ $(uname) == "Linux" ]] && J=$(cat /proc/cpuinfo | grep processor | wc -l)
179
180echo "## Building libs: make -j$J $LIBS"
181make -j${J} $LIBS
182
183# Copy resulting files
184
185DEST=""
186for SRC in $CP_FILES; do
187 if [[ "${SRC:0:2}" == "@:" ]]; then
188 DEST="${SRC:2}"
189 mkdir -vp "$DEST"
190 continue
191 fi
192 if [[ ! -f "$SRC" ]]; then
193 SRC="out/host/$PLATFORM/framework/$SRC.jar"
194 fi
195 if [[ -f "$SRC" ]]; then
196 if [[ ! -d "$DEST" ]]; then
197 die "Invalid cp_file dest directory: $DEST"
198 fi
199
200 cpfile "$SRC" "$DEST"
201 else
202 die "## Unknown file '$SRC' to copy in '$DEST'"
203 fi
204done
205
206# OS-specific post operations
207
208if [ "${HOST:0:6}" == "CYGWIN" ]; then
209 chmod -v a+rx "$ADT_DEST"/*.jar
210fi
The Android Open Source Project55a2c712009-03-03 19:29:09 -0800211
212echo "### $0 done"