| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| Raphael Moll | d9b2cbd | 2012-01-25 13:33:57 -0800 | [diff] [blame] | 2 | # See usage() below for the description. |
| 3 | |
| 4 | function usage() { |
| 5 | cat <<EOF |
| Siva Velusamy | 6ca42e8 | 2011-12-08 14:25:37 -0800 | [diff] [blame] | 6 | # 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 Moll | d9b2cbd | 2012-01-25 13:33:57 -0800 | [diff] [blame] | 9 | # |
| 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]) |
| 18 | EOF |
| 19 | } |
| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 20 | |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 21 | # CD to the top android directory |
| 22 | PROG_DIR=`dirname "$0"` |
| 23 | cd "${PROG_DIR}/../../../" |
| 24 | |
| 25 | HOST=`uname` |
| Raphael Moll | d9b2cbd | 2012-01-25 13:33:57 -0800 | [diff] [blame] | 26 | USE_COPY="" # force copy dependent jar files rather than creating symlinks |
| 27 | ONLY_SHOW_DEPS="" # only report make dependencies but don't build them nor copy. |
| 28 | ONLY_COPY_DEPS="" # only copy dependencies built by make; uses -f as needed. |
| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 29 | |
| 30 | function die() { |
| Raphael Moll | d9b2cbd | 2012-01-25 13:33:57 -0800 | [diff] [blame] | 31 | echo "Error: $*" >/dev/stderr |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 32 | exit 1 |
| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 33 | } |
| 34 | |
| Raphael Moll | d9b2cbd | 2012-01-25 13:33:57 -0800 | [diff] [blame] | 35 | function 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 Velusamy | 6ca42e8 | 2011-12-08 14:25:37 -0800 | [diff] [blame] | 42 | ## parse arguments |
| 43 | while [ $# -gt 0 ]; do |
| Raphael Moll | d9b2cbd | 2012-01-25 13:33:57 -0800 | [diff] [blame] | 44 | 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 Velusamy | 6ca42e8 | 2011-12-08 14:25:37 -0800 | [diff] [blame] | 58 | shift |
| 59 | done |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 60 | |
| Raphael Moll | d9b2cbd | 2012-01-25 13:33:57 -0800 | [diff] [blame] | 61 | warn "## Running $0" |
| 62 | |
| 63 | if [[ "${HOST:0:6}" == "CYGWIN" || "$USE_MINGW" == "1" ]]; then |
| 64 | # This is either Cygwin or Linux/Mingw cross-compiling to Windows. |
| Siva Velusamy | 6ca42e8 | 2011-12-08 14:25:37 -0800 | [diff] [blame] | 65 | PLATFORM="windows-x86" |
| Raphael Moll | d9b2cbd | 2012-01-25 13:33:57 -0800 | [diff] [blame] | 66 | if [[ "${HOST:0:6}" == "CYGWIN" ]]; then |
| 67 | # We can't use symlinks under Cygwin |
| 68 | USE_COPY="1" |
| 69 | fi |
| 70 | elif [[ "$HOST" == "Linux" ]]; then |
| 71 | PLATFORM="linux-x86" |
| 72 | elif [[ "$HOST" == "Darwin" ]]; then |
| 73 | PLATFORM="darwin-x86" |
| Siva Velusamy | 6ca42e8 | 2011-12-08 14:25:37 -0800 | [diff] [blame] | 74 | else |
| Raphael Moll | d9b2cbd | 2012-01-25 13:33:57 -0800 | [diff] [blame] | 75 | die "Unsupported platform ($HOST). Aborting." |
| Siva Velusamy | 6ca42e8 | 2011-12-08 14:25:37 -0800 | [diff] [blame] | 76 | fi |
| 77 | |
| Raphael Moll | d9b2cbd | 2012-01-25 13:33:57 -0800 | [diff] [blame] | 78 | if [[ "$USE_COPY" == "1" ]]; then |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 79 | 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 | } |
| 86 | else |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 87 | # 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 | } |
| 99 | fi |
| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 100 | |
| Raphael | f1d64e2 | 2009-11-18 11:27:35 -0800 | [diff] [blame] | 101 | DEST="sdk/eclipse/scripts" |
| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 102 | |
| 103 | set -e # fail early |
| 104 | |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 105 | LIBS="" |
| 106 | CP_FILES="" |
| 107 | |
| Siva Velusamy | 8e6fabf | 2012-03-29 14:43:49 -0700 | [diff] [blame] | 108 | ### BASE ### |
| 109 | |
| 110 | BASE_PLUGIN_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.base/libs" |
| 111 | BASE_PLUGIN_LIBS="common sdkstats androidprefs sdklib" |
| 112 | BASE_PLUGIN_PREBUILTS="\ |
| Xavier Ducrohet | 8c39e29 | 2012-04-16 18:12:13 -0700 | [diff] [blame] | 113 | prebuilts/tools/common/commons-compress/commons-compress-1.0.jar \ |
| Siva Velusamy | 8e6fabf | 2012-03-29 14:43:49 -0700 | [diff] [blame] | 114 | prebuilts/tools/common/guava-tools/guava-10.0.1.jar \ |
| Xavier Ducrohet | 8c39e29 | 2012-04-16 18:12:13 -0700 | [diff] [blame] | 115 | 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 Velusamy | 8e6fabf | 2012-03-29 14:43:49 -0700 | [diff] [blame] | 120 | |
| 121 | LIBS="$LIBS $BASE_PLUGIN_LIBS" |
| 122 | CP_FILES="$CP_FILES @:$BASE_PLUGIN_DEST $BASE_PLUGIN_LIBS $BASE_PLUGIN_PREBUILTS" |
| 123 | |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 124 | ### ADT ### |
| 125 | |
| 126 | ADT_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.adt/libs" |
| Xavier Ducrohet | d542e65 | 2012-05-08 18:23:25 -0700 | [diff] [blame] | 127 | ADT_LIBS="ant-glob assetstudio ide_common layoutlib_api lint_api lint_checks ninepatch propertysheet rule_api sdkuilib swtmenubar manifmerger" |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 128 | ADT_PREBUILTS="\ |
| Jean-Baptiste Queru | 5bd2815 | 2012-04-30 17:35:28 -0700 | [diff] [blame] | 129 | prebuilts/misc/common/kxml2/kxml2-2.3.0.jar \ |
| Tor Norbye | 7dd444e | 2012-05-07 16:55:46 -0700 | [diff] [blame] | 130 | prebuilts/tools/common/freemarker/freemarker-2.3.19.jar \ |
| Tor Norbye | faab591 | 2011-12-03 13:41:39 -0800 | [diff] [blame] | 131 | prebuilts/tools/common/asm-tools/asm-4.0.jar \ |
| 132 | prebuilts/tools/common/asm-tools/asm-tree-4.0.jar \ |
| Siva Velusamy | 8e6fabf | 2012-03-29 14:43:49 -0700 | [diff] [blame] | 133 | prebuilts/tools/common/lombok-ast/lombok-ast-0.2.jar" |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 134 | |
| 135 | LIBS="$LIBS $ADT_LIBS" |
| 136 | CP_FILES="$CP_FILES @:$ADT_DEST $ADT_LIBS $ADT_PREBUILTS" |
| 137 | |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 138 | ### DDMS ### |
| 139 | |
| 140 | DDMS_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.ddms/libs" |
| 141 | DDMS_LIBS="ddmlib ddmuilib swtmenubar" |
| 142 | |
| 143 | DDMS_PREBUILTS="\ |
| Raphael Moll | c4098ae | 2012-04-04 19:23:37 -0700 | [diff] [blame] | 144 | prebuilts/tools/common/jfreechart/jcommon-1.0.12.jar \ |
| 145 | prebuilts/tools/common/jfreechart/jfreechart-1.0.9.jar \ |
| 146 | prebuilts/tools/common/jfreechart/jfreechart-1.0.9-swt.jar" |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 147 | |
| 148 | LIBS="$LIBS $DDMS_LIBS" |
| 149 | CP_FILES="$CP_FILES @:$DDMS_DEST $DDMS_LIBS $DDMS_PREBUILTS" |
| 150 | |
| 151 | |
| 152 | ### TEST ### |
| 153 | |
| 154 | TEST_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.tests" |
| 155 | TEST_LIBS="easymock" |
| Jean-Baptiste Queru | 5bd2815 | 2012-04-30 17:35:28 -0700 | [diff] [blame] | 156 | TEST_PREBUILTS="prebuilts/misc/common/kxml2/kxml2-2.3.0.jar" |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 157 | |
| 158 | LIBS="$LIBS $TEST_LIBS" |
| 159 | CP_FILES="$CP_FILES @:$TEST_DEST $TEST_LIBS $TEST_PREBUILTS" |
| 160 | |
| 161 | |
| 162 | ### BRIDGE ### |
| 163 | |
| 164 | if [[ $PLATFORM != "windows-x86" ]]; then |
| 165 | # We can't build enough of the platform on Cygwin to create layoutlib |
| 166 | BRIDGE_LIBS="layoutlib ninepatch" |
| 167 | |
| 168 | LIBS="$LIBS $BRIDGE_LIBS" |
| 169 | fi |
| 170 | |
| 171 | |
| 172 | |
| 173 | ### HIERARCHYVIEWER ### |
| 174 | |
| 175 | HV_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/libs" |
| 176 | HV_LIBS="hierarchyviewerlib swtmenubar" |
| 177 | |
| 178 | LIBS="$LIBS $HV_LIBS" |
| 179 | CP_FILES="$CP_FILES @:$HV_DEST $HV_LIBS" |
| 180 | |
| 181 | |
| 182 | ### TRACEVIEW ### |
| 183 | |
| 184 | TV_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.traceview/libs" |
| 185 | TV_LIBS="traceview" |
| 186 | |
| 187 | LIBS="$LIBS $TV_LIBS" |
| 188 | CP_FILES="$CP_FILES @:$TV_DEST $TV_LIBS" |
| 189 | |
| 190 | |
| 191 | ### SDKMANAGER ### |
| 192 | |
| 193 | SDMAN_LIBS="swtmenubar" |
| 194 | |
| 195 | LIBS="$LIBS $SDKMAN_LIBS" |
| 196 | |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 197 | ### GL DEBUGGER ### |
| 198 | |
| 199 | if [[ $PLATFORM != "windows-x86" ]]; then |
| 200 | # liblzf doesn't build under cygwin. If necessary, this should be fixed first. |
| 201 | |
| 202 | GLD_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.gldebugger/libs" |
| Siva Velusamy | 8e6fabf | 2012-03-29 14:43:49 -0700 | [diff] [blame] | 203 | GLD_LIBS="host-libprotobuf-java-2.3.0-lite liblzf" |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 204 | |
| 205 | LIBS="$LIBS $GLD_LIBS" |
| Siva Velusamy | 8e6fabf | 2012-03-29 14:43:49 -0700 | [diff] [blame] | 206 | CP_FILES="$CP_FILES @:$GLD_DEST $GLD_LIBS" |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 207 | fi |
| 208 | |
| Raphael Moll | d9b2cbd | 2012-01-25 13:33:57 -0800 | [diff] [blame] | 209 | # In the mode to only echo dependencies, output them and we're done |
| 210 | if [[ -n $ONLY_SHOW_DEPS ]]; then |
| 211 | echo $LIBS |
| 212 | exit 0 |
| Raphael | f1c0263 | 2011-11-23 09:09:03 -0800 | [diff] [blame] | 213 | fi |
| 214 | |
| Raphael Moll | d9b2cbd | 2012-01-25 13:33:57 -0800 | [diff] [blame] | 215 | if [[ -z $ONLY_COPY_DEPS ]]; then |
| 216 | # Make sure we have lunch sdk-<something> |
| 217 | if [[ ! "$TARGET_PRODUCT" ]]; then |
| 218 | warn "## TARGET_PRODUCT is not set, running build/envsetup.sh" |
| 219 | . build/envsetup.sh |
| 220 | warn "## lunch sdk-eng" |
| 221 | lunch sdk-eng |
| 222 | fi |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 223 | |
| Raphael Moll | d9b2cbd | 2012-01-25 13:33:57 -0800 | [diff] [blame] | 224 | # Run make on all libs |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 225 | |
| Raphael Moll | d9b2cbd | 2012-01-25 13:33:57 -0800 | [diff] [blame] | 226 | J="4" |
| 227 | [[ $(uname) == "Darwin" ]] && J=$(sysctl hw.ncpu | cut -d : -f 2 | tr -d ' ') |
| 228 | [[ $(uname) == "Linux" ]] && J=$(cat /proc/cpuinfo | grep processor | wc -l) |
| 229 | |
| 230 | warn "## Building libs: make -j$J $LIBS" |
| 231 | make -j${J} $LIBS |
| 232 | fi |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 233 | |
| 234 | # Copy resulting files |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 235 | DEST="" |
| 236 | for SRC in $CP_FILES; do |
| 237 | if [[ "${SRC:0:2}" == "@:" ]]; then |
| 238 | DEST="${SRC:2}" |
| 239 | mkdir -vp "$DEST" |
| 240 | continue |
| 241 | fi |
| 242 | if [[ ! -f "$SRC" ]]; then |
| Xavier Ducrohet | 34dbc5d | 2012-04-05 14:23:00 -0700 | [diff] [blame] | 243 | ORIG_SRC="$SRC" |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 244 | SRC="out/host/$PLATFORM/framework/$SRC.jar" |
| 245 | fi |
| 246 | if [[ -f "$SRC" ]]; then |
| 247 | if [[ ! -d "$DEST" ]]; then |
| 248 | die "Invalid cp_file dest directory: $DEST" |
| 249 | fi |
| 250 | |
| 251 | cpfile "$SRC" "$DEST" |
| 252 | else |
| Xavier Ducrohet | 34dbc5d | 2012-04-05 14:23:00 -0700 | [diff] [blame] | 253 | die "## Unknown source '$ORIG_SRC' to copy in '$DEST'" |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 254 | fi |
| 255 | done |
| 256 | |
| 257 | # OS-specific post operations |
| 258 | |
| 259 | if [ "${HOST:0:6}" == "CYGWIN" ]; then |
| 260 | chmod -v a+rx "$ADT_DEST"/*.jar |
| 261 | fi |
| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 262 | |
| 263 | echo "### $0 done" |