aboutsummaryrefslogtreecommitdiff
path: root/eclipse/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'eclipse/scripts')
-rwxr-xr-xeclipse/scripts/_mk_icons.sh55
-rwxr-xr-xeclipse/scripts/build_adt.sh49
-rwxr-xr-xeclipse/scripts/build_update_site.sh34
-rwxr-xr-xeclipse/scripts/collect_sources_for_sdk.py180
-rwxr-xr-xeclipse/scripts/gen_icon.py71
-rwxr-xr-xeclipse/scripts/update_version.sh80
6 files changed, 469 insertions, 0 deletions
diff --git a/eclipse/scripts/_mk_icons.sh b/eclipse/scripts/_mk_icons.sh
new file mode 100755
index 000000000..b3ea35b39
--- /dev/null
+++ b/eclipse/scripts/_mk_icons.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+
+function icon() {
+ # $1=letter, $2=letter's color (e.g. A red), $3=filename
+ ./gen_icon.py ${3}.png 16 white black $2 $1
+}
+
+icon M green manifest
+ icon S blue sharedUserId
+ icon S red signature
+ icon P green package
+
+icon I green instrumentation
+ icon F green functionalTest
+ icon H green handleProfiling
+ icon I green icon
+ icon T green targetPackage
+
+icon U blue uses-permission
+icon P red permission
+ icon N green name
+ icon L blue label
+
+icon A blue application
+ icon P red permission
+ icon P blue persistent
+ icon P green process
+ icon T green taskAffinity
+ icon T blue theme
+ icon P red provider
+ icon A green authorities
+ icon I green initOrder
+ icon M green multiprocess
+ icon R green readPermission
+ icon W green writePermission
+ icon S green syncable
+ icon R green receiver
+ icon S blue service
+ icon A green activity
+ icon C blue clearOnBackground
+ icon C green configChanges
+ icon E green excludeFromRecents
+ icon L green launchMode
+ icon S green stateNotNeeded
+ icon F blue intent-filter
+ icon P green priority
+ icon A red action
+ icon C green category
+ icon D green data
+ icon M green mimeType
+ icon S green scheme
+ icon H green host
+ icon P green port
+ icon P blue path
+
diff --git a/eclipse/scripts/build_adt.sh b/eclipse/scripts/build_adt.sh
new file mode 100755
index 000000000..7006aabc5
--- /dev/null
+++ b/eclipse/scripts/build_adt.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+# Expected arguments:
+# $1 = out_dir
+# $2 = dist_dir
+# $3 = build_number
+
+# exit on error
+set -e
+
+if [ $# -ne 3 ]
+then
+ echo "Usage: $0 <out_dir> <dest_dir> <build_number>" > /dev/stderr
+ echo "Given arguments: $*" > /dev/stderr
+ exit 1
+fi
+
+PROG_DIR=$(dirname "$0")
+
+cd "$PROG_DIR"/../../..
+ANDROID_SRC="$PWD"
+
+OUT="$1"
+DIST="$2"
+BNUM="$3"
+
+echo "ANDROID_SRC=$ANDROID_SRC"
+echo "OUT=$OUT"
+echo "DIST=$DIST"
+echo "BNUM=$BNUM"
+
+# Steps to build Eclipse
+# 1. Generate Maven repository containing all tools
+echo Running gradle to build tools libraries...
+cd "$ANDROID_SRC"/tools
+./gradlew --no-daemon publishLocal
+
+# 2. Copy dependent jars into the libs folder of each plugin
+echo Copying jars to be embedded inside the ADT plugins
+cd "$ANDROID_SRC"
+./tools/gradlew -i -b sdk/eclipse/build.gradle --no-daemon copydeps
+
+# 3. Launch Tycho build
+echo Launching Tycho to build ADT plugins and bundle
+( set -x ; BUILD_NUMBER="$BNUM" ./tools/gradlew -i -b sdk/eclipse/build.gradle --no-daemon buildEclipse)
+
+echo Copying ADT plugins and bundle into destination folder
+cd "$ANDROID_SRC"
+cp -rv out/host/maven/bundles-*/products/*.zip "$DIST"/
+cp -rv out/host/maven/p2repo-*/p2repo-*.zip "$DIST"/p2repo-$BNUM.zip
diff --git a/eclipse/scripts/build_update_site.sh b/eclipse/scripts/build_update_site.sh
new file mode 100755
index 000000000..599875682
--- /dev/null
+++ b/eclipse/scripts/build_update_site.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+# Entry point to build the Eclipse plugins for local deployment.
+#
+# Input parameters:
+# $1: Optional build number. If present, will be appended to the date qualifier.
+# The build number cannot contain spaces *nor* periods (dashes are ok.)
+# -i: Optional, if present, the Google internal update site will be built. Otherwise,
+# the external site will be built
+#
+# Workflow:
+# - calls buildserver with /home/$USER/www/no_crawl and -z
+# to build and create the update size but do not zip it in the destination directory.
+
+set -e # Fail this script as soon as a command fails -- fail early, fail fast
+
+D=`dirname $0`
+BUILD_NUMBER=""
+INTERNAL_BUILD=""
+# parse input parameters
+while [ $# -gt 0 ]; do
+ if [ "$1" == "-i" ]; then
+ INTERNAL_BUILD="-i"
+ elif [ "$1" != "" ]; then
+ BUILD_NUMBER="$1"
+ fi
+ shift
+done
+
+DEST_DIR="$HOME"
+[ -z "$DEST_DIR" ] && [ -n "$USER" ] && DEST_DIR="/home/$USER"
+[ -z "$DEST_DIR" ] && DEST_DIR="~"
+DEST_DIR="$DEST_DIR/www/no_crawl"
+
+"$D/build_server.sh" "$DEST_DIR" "$BUILD_NUMBER" -z "$INTERNAL_BUILD"
diff --git a/eclipse/scripts/collect_sources_for_sdk.py b/eclipse/scripts/collect_sources_for_sdk.py
new file mode 100755
index 000000000..b95ae62b8
--- /dev/null
+++ b/eclipse/scripts/collect_sources_for_sdk.py
@@ -0,0 +1,180 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2009 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+"""
+Description:
+ This script collects all framework Java sources from the current android
+ source code and places them in a source folder suitable for the eclipse ADT
+ plugin.
+
+See usage() below.
+
+Copyright (C) 2009 The Android Open Source Project
+Licensed under the Apache License, Version 2.0 (the "License").
+"""
+
+import re
+import os
+import sys
+import getopt
+import shutil
+
+_RE_PKG = re.compile("^\s*package\s+([^\s;]+)\s*;.*")
+
+# Holds cmd-line arguments
+class Params(object):
+ def __init__(self):
+ self.DRY = False
+ self.DIR = "frameworks libcore"
+ self.SRC = None
+ self.DST = None
+ self.CNT_USED = 0
+ self.CNT_NOPKG = 0
+
+
+# Prints a usage summary
+def usage(error=None):
+ print """
+ Description:
+ This script collects all framework Java sources from the current android
+ source code and places them in a source folder suitable for the eclipse ADT
+ plugin.
+
+ Usage:
+ %s [-n] <android-git-repo root> <sdk/platforms/xyz/sources>
+
+ The source and destination directories must already exist.
+ Use -n for a dry-run.
+
+""" % sys.argv[0]
+
+ if error:
+ print >>sys.stderr, "Error:", error
+
+
+# Parse command line args, returns a Params instance or sys.exit(2) on error
+# after printing the error and the usage.
+def parseArgs(argv):
+ p = Params()
+ error = None
+
+ try:
+ opts, args = getopt.getopt(argv[1:],
+ "ns:",
+ [ "--dry", "--sourcedir=" ])
+ except getopt.GetoptError, e:
+ error = str(e)
+
+ if error is None:
+ for o, a in opts:
+ if o in [ "-n", "--dry" ]:
+ p.DRY = True
+ elif o in [ "-s", "--sourcedir" ]:
+ p.DIR = a
+
+ if len(args) != 2:
+ error = "Missing arguments: <source> <dest>"
+ else:
+ p.SRC = args[0]
+ p.DST = args[1]
+
+ if not os.path.isdir(p.SRC):
+ error = "%s is not a directory" % p.SRC
+ elif not os.path.isdir(p.DST):
+ error = "%s is not a directory" % p.DST
+
+ if error:
+ usage(error)
+ sys.exit(2)
+
+ return p
+
+
+# Recursively parses the given directory and process java files found
+def parseSrcDir(p, srcdir):
+ if not os.path.exists(srcdir):
+ print >>sys.stderr, "Error: Skipping unknown directory", srcdir
+ return
+
+ for f in os.listdir(srcdir):
+ fp = os.path.join(srcdir, f)
+ if f.endswith(".java") and os.path.isfile(fp):
+ pkg = checkJavaFile(fp)
+ if pkg:
+ pkg = pkg.replace(".", os.path.sep) # e.g. android.view => android/view
+ copy(p, fp, f, pkg)
+ p.CNT_USED += 1 # one more copied
+ else:
+ p.CNT_NOPKG += 1 # this java file lacked a package declaration
+ elif os.path.isdir(fp):
+ parseSrcDir(p, fp)
+
+
+# Check a java file to find its package declaration, if any
+def checkJavaFile(path):
+ print "Process", path
+
+ try:
+ f = None
+ try:
+ f = file(path)
+ for l in f.readlines():
+ m = _RE_PKG.match(l)
+ if m:
+ return m.group(1)
+ finally:
+ if f: f.close()
+ except Exception:
+ pass
+
+ return None
+
+
+# Create destination directory based on package name then copy the
+# source file in there
+def copy(p, fp, f, pkg):
+ dstdir = os.path.join(p.DST, pkg)
+ _mkdir(p, dstdir)
+ _cp(p, fp, os.path.join(dstdir, f))
+
+
+def _mkdir(p, dir):
+ if not os.path.isdir(dir):
+ if p.DRY:
+ print "mkdir", dir
+ else:
+ os.makedirs(dir)
+
+
+def _cp(p, src, dst):
+ if p.DRY:
+ print "cp", src, dst
+ else:
+ shutil.copyfile(src, dst)
+
+
+def main():
+ p = parseArgs(sys.argv)
+ for d in p.DIR.split():
+ if d:
+ parseSrcDir(p, os.path.join(p.SRC, d))
+ print "%d java files copied" % p.CNT_USED
+ if p.CNT_NOPKG: print "%d java files ignored (no package)" % p.CNT_NOPKG
+ if p.DRY: print "This was in *DRY* mode. No copies done."
+
+
+if __name__ == "__main__":
+ main()
diff --git a/eclipse/scripts/gen_icon.py b/eclipse/scripts/gen_icon.py
new file mode 100755
index 000000000..f6274e16e
--- /dev/null
+++ b/eclipse/scripts/gen_icon.py
@@ -0,0 +1,71 @@
+#!/usr/bin/python
+
+import sys
+import StringIO
+try:
+ import Image, ImageDraw, ImageFont
+except ImportError, e:
+ print str(e)
+ print "Are you missing the Python Imaging Library? (apt-get install python-imaging)"
+ sys.exit(1)
+
+FONT_PATH = "/usr/share/fonts/truetype/msttcorefonts/arial.ttf"
+
+class Args(object):
+ def __init__(self, dest_name, size, circle_color, border_color,
+ letter_color, letter):
+ self.dest_name = dest_name
+ self.size = size
+ self.circle_color = circle_color
+ self.border_color = border_color
+ self.letter_color = letter_color
+ self.letter = letter
+
+def main(args):
+ data = process_args(args)
+ if data:
+ createImage(data)
+
+def process_args(args):
+ if not args or len(args) != 6:
+ usage()
+ return Args(*args)
+
+def usage():
+ print """Usage: %s <file_name> <size> <circle-color> <border-color> <letter-color> <letter>""" % sys.argv[0]
+ sys.exit(1)
+
+def createImage(data):
+ zoom = 4
+ rmin = -zoom/2
+ rmax = zoom/2
+ if zoom > 1:
+ r = range(-zoom/2, zoom/2+1)
+ else:
+ r = [ 0 ]
+ sz = int(data.size)
+ sz4 = sz * zoom
+
+ img = Image.new("RGBA", (sz4, sz4), (255,255,255,0))
+ draw = ImageDraw.Draw(img)
+
+ draw.ellipse((0, 0, sz4-zoom, sz4-zoom),
+ fill=data.circle_color, outline=None)
+ for i in r:
+ draw.ellipse((i, i, sz4-i-zoom, sz4-i-zoom),
+ fill=None, outline=data.border_color)
+
+ font = ImageFont.truetype(FONT_PATH, int(sz4 * .75))
+ tsx, tsy = draw.textsize(data.letter, font=font)
+
+ ptx = (sz4 - tsx) / 2
+ pty = (sz4 - tsy) / 2
+ for i in r:
+ draw.text((ptx + i, pty), data.letter, font=font, fill=data.letter_color)
+
+ img = img.resize((sz, sz), Image.BICUBIC)
+ img.save(data.dest_name, "PNG")
+ print "Saved", data.dest_name
+
+if __name__ == "__main__":
+ main(sys.argv[1:])
diff --git a/eclipse/scripts/update_version.sh b/eclipse/scripts/update_version.sh
new file mode 100755
index 000000000..228be97a9
--- /dev/null
+++ b/eclipse/scripts/update_version.sh
@@ -0,0 +1,80 @@
+#!/bin/bash
+
+OLD="$1"
+NEW="$2"
+
+# sanity check in input args
+if [ -z "$OLD" ] || [ -z "$NEW" ]; then
+ cat <<EOF
+Usage: $0 <old> <new>
+Changes the ADT plugin revision number.
+Example:
+ cd sdk/eclipse
+ scripts/update_version.sh 0.1.2 0.2.3
+EOF
+ exit 1
+fi
+
+# sanity check on current dir
+if [ `basename "$PWD"` != "eclipse" ]; then
+ echo "Please run this from sdk/eclipse."
+ exit 1
+fi
+
+# sanity check the new version number
+if [[ "$NEW" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+ echo "## Version $NEW: seems valid."
+else
+ echo "## Version $NEW: does not conform to major.mino.micro format."
+ exit 1
+fi
+
+function replace() {
+ if [[ -f "$1" ]]; then
+ echo "### Change $SED_OLD => $SED_NEW in $1"
+ if [[ $(uname) == "Linux" ]]; then
+ sed -i "s/$SED_OLD/$SED_NEW/g" "$1"
+ else
+ # sed on Mac doesn't handle -i the same way as on Linux
+ sed -i "" "s/$SED_OLD/$SED_NEW/g" "$1"
+ fi
+ fi
+}
+
+# ---1--- Change Eclipse's qualified version numbers
+# quote dots for regexps
+SED_OLD="${OLD//./\.}\.qualifier"
+SED_NEW="${NEW//./\.}\.qualifier"
+
+for i in $(grep -rl "$OLD" * | grep -E "\.xml$|\.MF$|\.product$"); do
+ if [[ -f "$i" && $(basename "$i") != "build.xml" ]]; then
+ replace "$i"
+ fi
+done
+
+# ---2--- Change unqualified version numbers in specific files
+SED_OLD="${OLD//./\.}"
+SED_NEW="${NEW//./\.}"
+for i in artifacts/*/pom.xml \
+ monitor/build.gradle \
+ plugins/com.android.ide.eclipse.adt.package/ide.product \
+ plugins/com.android.ide.eclipse.monitor/monitor.product \
+ plugins/com.android.ide.eclipse.monitor/plugin.properties \
+ plugins/com.android.ide.eclipse.*/pom.xml \
+ features/com.android.ide.eclipse.*/pom.xml \
+ features/com.android.ide.eclipse.adt.package/feature.xml ; do
+ if grep -qs "$OLD" "$i"; then
+ replace "$i"
+ fi
+done
+
+# do another grep for older version without the qualifier. We don't
+# want to replace those automatically as it could be something else.
+# Printing out occurence helps find ones to update manually, but exclude
+# some known useless files.
+echo
+echo "#### ----------------"
+echo "#### Remaining instances of $OLD"
+echo
+grep -r "$OLD" * | grep -v -E "/build.xml:|/javaCompiler\.\.\.args:"
+