blob: 4154bf8ab522be7f9a831f69b16e4bd75e36d6bf [file] [log] [blame]
The Android Open Source Project55a2c712009-03-03 19:29:09 -08001#!/bin/bash
2
3# Quick script used to setup Eclipse for the ADT plugin build.
4#
5# usage:
Raphael Moll15a72762010-12-09 19:17:15 -08006# 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 Project55a2c712009-03-03 19:29:09 -08008#
9# Workflow:
10# - downloads & unpack Eclipse if necessary
11# - *runs* it once
12
13
14#-----------------
15#
Raphael Mollb3719202010-11-23 01:18:20 -080016# Note: right now this is invoked by sdk/eclipse/doBuild.sh
The Android Open Source Project55a2c712009-03-03 19:29:09 -080017# 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
24set -e # abort this script early if any command fails
25
26function die() {
27 echo $@
28 exit 1
29}
30
Raphael Mollb3719202010-11-23 01:18:20 -080031V="--no-verbose"
32if [[ "$1" == "-v" ]]; then
33 V=""
34 shift
35fi
36
37if [[ "-p" == "$1" ]]; then
The Android Open Source Project55a2c712009-03-03 19:29:09 -080038 GET_PID="-p"
39 shift
40fi
41
Raphael Mollb3719202010-11-23 01:18:20 -080042
The Android Open Source Project55a2c712009-03-03 19:29:09 -080043BASE_DIR="$1"
44
Raphael Mollb3719202010-11-23 01:18:20 -080045[[ -n "$1" ]] || die "Usage: $0 <dest-dir>"
The Android Open Source Project55a2c712009-03-03 19:29:09 -080046
Siva Velusamybfe3bd72012-03-21 15:38:31 -070047# URL for Eclipse Linux RCP.
Raphael9c014a82011-11-02 15:49:49 -070048DOWNLOAD_URL="http://download.eclipse.org/technology/epp/downloads/release/helios/SR2/eclipse-rcp-helios-SR2-linux-gtk-x86_64.tar.gz"
The Android Open Source Project55a2c712009-03-03 19:29:09 -080049
Siva Velusamybfe3bd72012-03-21 15:38:31 -070050# URL for CDT
51CDT_DOWNLOAD_URL="http://download.eclipse.org/tools/cdt/releases/helios/dist/cdt-master-7.0.2.zip"
52
The Android Open Source Project55a2c712009-03-03 19:29:09 -080053BIN="$BASE_DIR/eclipse/eclipse" # path to installed binary
Raphael Moll15a72762010-12-09 19:17:15 -080054TARGZ="$BASE_DIR/${DOWNLOAD_URL##*/}" # base dir + filename of the download URL
Siva Velusamybfe3bd72012-03-21 15:38:31 -070055CDTZIP="$BASE_DIR/${CDT_DOWNLOAD_URL##*/}"
The Android Open Source Project55a2c712009-03-03 19:29:09 -080056
Raphael Mollb3719202010-11-23 01:18:20 -080057if [[ ! -f "$BIN" ]]; then
The Android Open Source Project55a2c712009-03-03 19:29:09 -080058 echo "Downloading and installing Eclipse in $BASE_DIR."
59 mkdir -p "$BASE_DIR"
Siva Velusamybfe3bd72012-03-21 15:38:31 -070060
Raphael Mollb3719202010-11-23 01:18:20 -080061 wget --continue $V --output-document="$TARGZ" "$DOWNLOAD_URL"
The Android Open Source Project55a2c712009-03-03 19:29:09 -080062 echo "Unpacking $TARGZ"
63 (cd "$BASE_DIR" && tar xzf "$TARGZ")
Raphael Mollb3719202010-11-23 01:18:20 -080064
Siva Velusamybfe3bd72012-03-21 15:38:31 -070065 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 Project55a2c712009-03-03 19:29:09 -080069 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 Mollb3719202010-11-23 01:18:20 -080073 if [[ -n "$GET_PID" ]]; then
The Android Open Source Project55a2c712009-03-03 19:29:09 -080074 # 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
84fi
Raphael Mollb3719202010-11-23 01:18:20 -080085