| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Quick script used to setup Eclipse for the ADT plugin build. |
| 4 | # |
| 5 | # usage: |
| Raphael Moll | 15a7276 | 2010-12-09 19:17:15 -0800 | [diff] [blame] | 6 | # setup_eclipse.sh [-p] <dest_dir> |
| 7 | # -p: run Eclipse in the background and print its PID in dest_dir/eclipse.pid |
| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 8 | # |
| 9 | # Workflow: |
| 10 | # - downloads & unpack Eclipse if necessary |
| 11 | # - *runs* it once |
| 12 | |
| 13 | |
| 14 | #----------------- |
| 15 | # |
| Raphael Moll | b371920 | 2010-11-23 01:18:20 -0800 | [diff] [blame] | 16 | # Note: right now this is invoked by sdk/eclipse/doBuild.sh |
| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 17 | # and it *MUST* be invoked with the following destination directory: |
| 18 | # |
| 19 | # $ setup_eclipse.sh /buildbot/eclipse-android/3.4.0/ |
| 20 | # |
| 21 | #----------------- |
| 22 | |
| 23 | |
| 24 | set -e # abort this script early if any command fails |
| 25 | |
| 26 | function die() { |
| 27 | echo $@ |
| 28 | exit 1 |
| 29 | } |
| 30 | |
| Raphael Moll | b371920 | 2010-11-23 01:18:20 -0800 | [diff] [blame] | 31 | V="--no-verbose" |
| 32 | if [[ "$1" == "-v" ]]; then |
| 33 | V="" |
| 34 | shift |
| 35 | fi |
| 36 | |
| 37 | if [[ "-p" == "$1" ]]; then |
| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 38 | GET_PID="-p" |
| 39 | shift |
| 40 | fi |
| 41 | |
| Raphael Moll | b371920 | 2010-11-23 01:18:20 -0800 | [diff] [blame] | 42 | |
| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 43 | BASE_DIR="$1" |
| 44 | |
| Raphael Moll | b371920 | 2010-11-23 01:18:20 -0800 | [diff] [blame] | 45 | [[ -n "$1" ]] || die "Usage: $0 <dest-dir>" |
| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 46 | |
| Siva Velusamy | bfe3bd7 | 2012-03-21 15:38:31 -0700 | [diff] [blame] | 47 | # URL for Eclipse Linux RCP. |
| Scott Fan | a0c9a45 | 2013-06-11 14:53:40 +0800 | [diff] [blame] | 48 | DOWNLOAD_URL="http://archive.eclipse.org/technology/epp/downloads/release/helios/SR2/eclipse-rcp-helios-SR2-linux-gtk-x86_64.tar.gz" |
| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 49 | |
| Siva Velusamy | bfe3bd7 | 2012-03-21 15:38:31 -0700 | [diff] [blame] | 50 | # URL for CDT |
| 51 | CDT_DOWNLOAD_URL="http://download.eclipse.org/tools/cdt/releases/helios/dist/cdt-master-7.0.2.zip" |
| 52 | |
| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 53 | BIN="$BASE_DIR/eclipse/eclipse" # path to installed binary |
| Raphael Moll | 15a7276 | 2010-12-09 19:17:15 -0800 | [diff] [blame] | 54 | TARGZ="$BASE_DIR/${DOWNLOAD_URL##*/}" # base dir + filename of the download URL |
| Siva Velusamy | bfe3bd7 | 2012-03-21 15:38:31 -0700 | [diff] [blame] | 55 | CDTZIP="$BASE_DIR/${CDT_DOWNLOAD_URL##*/}" |
| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 56 | |
| Raphael Moll | b371920 | 2010-11-23 01:18:20 -0800 | [diff] [blame] | 57 | if [[ ! -f "$BIN" ]]; then |
| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 58 | echo "Downloading and installing Eclipse in $BASE_DIR." |
| 59 | mkdir -p "$BASE_DIR" |
| Siva Velusamy | bfe3bd7 | 2012-03-21 15:38:31 -0700 | [diff] [blame] | 60 | |
| Raphael Moll | b371920 | 2010-11-23 01:18:20 -0800 | [diff] [blame] | 61 | wget --continue $V --output-document="$TARGZ" "$DOWNLOAD_URL" |
| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 62 | echo "Unpacking $TARGZ" |
| 63 | (cd "$BASE_DIR" && tar xzf "$TARGZ") |
| Raphael Moll | b371920 | 2010-11-23 01:18:20 -0800 | [diff] [blame] | 64 | |
| Siva Velusamy | bfe3bd7 | 2012-03-21 15:38:31 -0700 | [diff] [blame] | 65 | wget --continue $V --output-document="$CDTZIP" "$CDT_DOWNLOAD_URL" |
| 66 | echo "Unpacking $CDTZIP" |
| 67 | (cd "$BASE_DIR/eclipse" && unzip -o "$CDTZIP") |
| 68 | |
| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 69 | echo |
| 70 | echo "*** WARNING: To setup Eclipse correctly, it must be ran at least once manually" |
| 71 | echo "*** Eclipse will now start." |
| 72 | echo |
| Raphael Moll | b371920 | 2010-11-23 01:18:20 -0800 | [diff] [blame] | 73 | if [[ -n "$GET_PID" ]]; then |
| The Android Open Source Project | 55a2c71 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 74 | # if started from the automatic eclipse build, run Eclipse in the background |
| 75 | "$BIN" & |
| 76 | ECLIPSE_PID=$! |
| 77 | echo "*** Eclipse started in background with PID $ECLIPSE_PID" |
| 78 | echo "$ECLIPSE_PID" > "$BASE_DIR"/eclipse.pid |
| 79 | sleep 5 # give some time for Eclipse to start and setup its environment |
| 80 | else |
| 81 | # if started manually, run Eclipse in the foreground |
| 82 | "$BIN" |
| 83 | fi |
| 84 | fi |
| Raphael Moll | b371920 | 2010-11-23 01:18:20 -0800 | [diff] [blame] | 85 | |