1 #!/bin/bash 2 3 set -e 4 5 # CD to the top android directory 6 D=`dirname "$0"` 7 cd "$D/../../../" 8 9 # computes relative ".." paths from $1 to here (in /android) 10 function back() { 11 echo $1 | sed 's@[^/]*@..@g' 12 } 13 14 HOST=`uname` 15 if [ "${HOST:0:6}" == "CYGWIN" ]; then 16 # We can't use symlinks under Cygwin 17 function cpdir() { # $1=dest $2=source 18 echo "rsync $2 => $1" 19 rsync -avW --delete-after $2 $1 20 } 21 22 else 23 # For all other systems which support symlinks 24 function cpdir() { # $1=dest $2=source 25 ln -svf `back $1`/$2 $1 26 } 27 fi 28 29 BASE="sdk/eclipse/plugins/com.android.ide.eclipse.tests" 30 DEST=$BASE 31 BACK=`back $DEST` 32 33 HOST=`uname` 34 if [ "$HOST" == "Linux" ]; then 35 ln -svf $BACK/out/host/linux-x86/framework/kxml2-2.3.0.jar "$DEST/" 36 ln -svf $BACK/out/host/linux-x86/framework/layoutlib.jar "$DEST/" 37 ln -svf $BACK/out/host/linux-x86/framework/groovy-all-1.7.0.jar "$DEST/" 38 39 elif [ "$HOST" == "Darwin" ]; then 40 ln -svf $BACK/out/host/darwin-x86/framework/kxml2-2.3.0.jar "$DEST/" 41 ln -svf $BACK/out/host/darwin-x86/framework/layoutlib.jar "$DEST/" 42 ln -svf $BACK/out/host/darwin-x86/framework/groovy-all-1.7.0.jar "$DEST/" 43 44 elif [ "${HOST:0:6}" == "CYGWIN" ]; then 45 if [ ! -f "$DEST/kxml2-2.3.0.jar" ]; then 46 cp -v "prebuilt/common/kxml2/kxml2-2.3.0.jar" "$DEST/" 47 fi 48 49 if [ ! -f "$DEST/groovy-all-1.7.0.jar" ]; then 50 cp -v "prebuilt/common/groovy/groovy-all-1.7.0.jar" "$DEST/" 51 fi 52 53 LIBS="layoutlib.jar" 54 NEED_MAKE="yes" 55 for LIB in $LIBS ; do 56 SRCJAR="out/host/windows-x86/framework/$LIB" 57 DSTJAR="$DEST/$LIB" 58 if [[ $NEED_MAKE ]] && ! diff -q "$SRCJAR" "$DSTJAR" >/dev/null ; then 59 MAKE_LIBS="${LIBS//.jar/}" 60 echo "Make java libs: $MAKE_LIBS" 61 make -j3 showcommands $MAKE_LIBS || die "adt-tests: Failed to build one of $LIBS." 62 NEED_MAKE="" 63 fi 64 65 cp -v "$SRCJAR" "$DSTJAR" 66 done 67 68 chmod -v a+rx "$DEST"/*.jar 69 else 70 echo "Unsupported platform ($HOST). Nothing done." 71 fi 72 73 # create link to ddmlib tests 74 DEST=$BASE/unittests/com/android 75 cpdir $DEST sdk/ddms/libs/ddmlib/tests/src/com/android/ddmlib 76 cpdir $DEST sdk/sdkmanager/libs/sdklib/tests/com/android/sdklib 77 78 # Cleanup old obsolete symlink 79 [[ -e $DEST/sdkuilib || -L $DEST/sdkuilib ]] && rm -rfv $DEST/sdkuilib 80 81 DEST=$BASE/unittests/com/android/layoutlib 82 mkdir -p $DEST 83 cpdir $DEST frameworks/base/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge 84 cpdir $DEST frameworks/base/tools/layoutlib/bridge/tests/com/android/layoutlib/testdata 85