| 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="\ |
| 113 | prebuilt/common/commons-compress/commons-compress-1.0.jar \ |
| 114 | prebuilts/tools/common/guava-tools/guava-10.0.1.jar \ |
| 115 | prebuilt/common/http-client/commons-logging-1.1.1.jar \ |
| 116 | prebuilt/common/http-client/commons-codec-1.4.jar \ |
| 117 | prebuilt/common/http-client/httpclient-4.1.1.jar \ |
| 118 | prebuilt/common/http-client/httpcore-4.1.jar \ |
| 119 | prebuilt/common/http-client/httpmime-4.1.1.jar" |
| 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" |
| Tor Norbye | 9bd0694 | 2012-04-04 18:41:06 -0700 | [diff] [blame^] | 127 | ADT_LIBS="layoutlib_api lint_api lint_checks ide_common rule_api ninepatch sdkuilib assetstudio propertysheet" |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 128 | ADT_PREBUILTS="\ |
| 129 | prebuilt/common/kxml2/kxml2-2.3.0.jar \ |
| Tor Norbye | faab591 | 2011-12-03 13:41:39 -0800 | [diff] [blame] | 130 | prebuilts/tools/common/asm-tools/asm-4.0.jar \ |
| 131 | prebuilts/tools/common/asm-tools/asm-tree-4.0.jar \ |
| Siva Velusamy | 8e6fabf | 2012-03-29 14:43:49 -0700 | [diff] [blame] | 132 | prebuilts/tools/common/lombok-ast/lombok-ast-0.2.jar" |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 133 | |
| 134 | LIBS="$LIBS $ADT_LIBS" |
| 135 | CP_FILES="$CP_FILES @:$ADT_DEST $ADT_LIBS $ADT_PREBUILTS" |
| 136 | |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 137 | ### DDMS ### |
| 138 | |
| 139 | DDMS_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.ddms/libs" |
| 140 | DDMS_LIBS="ddmlib ddmuilib swtmenubar" |
| 141 | |
| 142 | DDMS_PREBUILTS="\ |
| Raphael Moll | c4098ae | 2012-04-04 19:23:37 -0700 | [diff] [blame] | 143 | 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" |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 146 | |
| 147 | LIBS="$LIBS $DDMS_LIBS" |
| 148 | CP_FILES="$CP_FILES @:$DDMS_DEST $DDMS_LIBS $DDMS_PREBUILTS" |
| 149 | |
| 150 | |
| 151 | ### TEST ### |
| 152 | |
| 153 | TEST_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.tests" |
| 154 | TEST_LIBS="easymock" |
| 155 | TEST_PREBUILTS="prebuilt/common/kxml2/kxml2-2.3.0.jar" |
| 156 | |
| 157 | LIBS="$LIBS $TEST_LIBS" |
| 158 | CP_FILES="$CP_FILES @:$TEST_DEST $TEST_LIBS $TEST_PREBUILTS" |
| 159 | |
| 160 | |
| 161 | ### BRIDGE ### |
| 162 | |
| 163 | if [[ $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" |
| 168 | fi |
| 169 | |
| 170 | |
| 171 | |
| 172 | ### HIERARCHYVIEWER ### |
| 173 | |
| 174 | HV_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/libs" |
| 175 | HV_LIBS="hierarchyviewerlib swtmenubar" |
| 176 | |
| 177 | LIBS="$LIBS $HV_LIBS" |
| 178 | CP_FILES="$CP_FILES @:$HV_DEST $HV_LIBS" |
| 179 | |
| 180 | |
| 181 | ### TRACEVIEW ### |
| 182 | |
| 183 | TV_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.traceview/libs" |
| 184 | TV_LIBS="traceview" |
| 185 | |
| 186 | LIBS="$LIBS $TV_LIBS" |
| 187 | CP_FILES="$CP_FILES @:$TV_DEST $TV_LIBS" |
| 188 | |
| 189 | |
| 190 | ### SDKMANAGER ### |
| 191 | |
| 192 | SDMAN_LIBS="swtmenubar" |
| 193 | |
| 194 | LIBS="$LIBS $SDKMAN_LIBS" |
| 195 | |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 196 | ### GL DEBUGGER ### |
| 197 | |
| 198 | if [[ $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 Velusamy | 8e6fabf | 2012-03-29 14:43:49 -0700 | [diff] [blame] | 202 | GLD_LIBS="host-libprotobuf-java-2.3.0-lite liblzf" |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 203 | |
| 204 | LIBS="$LIBS $GLD_LIBS" |
| Siva Velusamy | 8e6fabf | 2012-03-29 14:43:49 -0700 | [diff] [blame] | 205 | CP_FILES="$CP_FILES @:$GLD_DEST $GLD_LIBS" |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 206 | fi |
| 207 | |
| Raphael Moll | d9b2cbd | 2012-01-25 13:33:57 -0800 | [diff] [blame] | 208 | # In the mode to only echo dependencies, output them and we're done |
| 209 | if [[ -n $ONLY_SHOW_DEPS ]]; then |
| 210 | echo $LIBS |
| 211 | exit 0 |
| Raphael | f1c0263 | 2011-11-23 09:09:03 -0800 | [diff] [blame] | 212 | fi |
| 213 | |
| Raphael Moll | d9b2cbd | 2012-01-25 13:33:57 -0800 | [diff] [blame] | 214 | if [[ -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 |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 222 | |
| Raphael Moll | d9b2cbd | 2012-01-25 13:33:57 -0800 | [diff] [blame] | 223 | # Run make on all libs |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 224 | |
| Raphael Moll | d9b2cbd | 2012-01-25 13:33:57 -0800 | [diff] [blame] | 225 | 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 |
| 231 | fi |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 232 | |
| 233 | # Copy resulting files |
| Raphael | e7e9d05 | 2011-11-07 13:39:29 -0800 | [diff] [blame] | 234 | DEST="" |
| 235 | for 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 |
| 242 | SRC="out/host/$PLATFORM/framework/$SRC.jar" |
| 243 | fi |
| 244 | if [[ -f "$SRC" ]]; then |
| 245 | if [[ ! -d "$DEST" ]]; then |
| 246 | die "Invalid cp_file dest directory: $DEST" |
| 247 | fi |
| 248 | |
| 249 | cpfile "$SRC" "$DEST" |
| 250 | else |
| 251 | die "## Unknown file '$SRC' to copy in '$DEST'" |
| 252 | fi |
| 253 | done |
| 254 | |
| 255 | # OS-specific post operations |
| 256 | |
| 257 | if [ "${HOST:0:6}" == "CYGWIN" ]; then |
| 258 | chmod -v a+rx "$ADT_DEST"/*.jar |
| 259 | fi |
| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 260 | |
| 261 | echo "### $0 done" |