aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/scripts/create_all_symlinks.sh
diff options
context:
space:
mode:
authorRaphael Moll <ralf@android.com>2013-07-10 16:51:43 -0700
committerRaphael Moll <ralf@android.com>2013-07-16 13:15:54 -0700
commitd54f314f5779de983712d10d51ae44190a14b3e8 (patch)
tree81b19945e0fc7a647905de94023d285ae52e9d27 /eclipse/scripts/create_all_symlinks.sh
parent7d2bd257d91c8f8acf1d95485fbf058f1bc15755 (diff)
downloadsdk-d54f314f5779de983712d10d51ae44190a14b3e8.zip
sdk-d54f314f5779de983712d10d51ae44190a14b3e8.tar.gz
sdk-d54f314f5779de983712d10d51ae44190a14b3e8.tar.bz2
Change create_symlinks to use gradle-based libraries.
As part of this change, each section clearly identifies where libraries should be built from. Example from the source: LIBS="base:common make:ant-glob ... swt:ddmuilib" means that: - "common" is taken from tools/base (gradle) - "ddmuilib" is taken from tools/swt (gradle) - "sdkstats" is built using 'make', in which case a prebuilt/devtools JAR will be used if it can be found. Change-Id: Ie793b684f303566a307ee3ff6d6d72db8d26996e
Diffstat (limited to 'eclipse/scripts/create_all_symlinks.sh')
-rwxr-xr-xeclipse/scripts/create_all_symlinks.sh190
1 files changed, 140 insertions, 50 deletions
diff --git a/eclipse/scripts/create_all_symlinks.sh b/eclipse/scripts/create_all_symlinks.sh
index 925bc70..8b224f6 100755
--- a/eclipse/scripts/create_all_symlinks.sh
+++ b/eclipse/scripts/create_all_symlinks.sh
@@ -39,6 +39,20 @@ function warn() {
fi
}
+function printGradleJarPath() {
+ # Prints to stdout the absolute path of the JAR assembled for a given gradle project.
+ # $1 = source dir, e.g. tools/base or tools/swt
+ # $2 = the gradle project name e.g. common or lint-api
+ echo "## Quering Gradle properties for '$2' in '$1'." > /dev/stderr
+ ( cd $1 && \
+ ./gradlew :$2:properties | awk '
+ BEGIN { B=""; N=""; V="" }
+ /^archivesBaseName:/ { N=$2 }
+ /^buildDir:/ { D=$2 }
+ /^version:/ { V=$2 }
+ END { print D "/libs/" N "-" V ".jar" }' )
+}
+
## parse arguments
while [ $# -gt 0 ]; do
case "$1" in
@@ -76,12 +90,8 @@ else
fi
if [[ "$USE_COPY" == "1" ]]; then
- function cpfile { # $1=source $2=dest
- cp -fv $1 $2/
- }
-
- function cpdir() { # $1=source $2=dest
- rsync -avW --delete-after $1 $2
+ function cpfile { # $1=source $2=dest $3=optional dest filename
+ cp -fv $1 $2/$3
}
else
# computes the "reverse" path, e.g. "a/b/c" => "../../.."
@@ -89,12 +99,15 @@ else
echo $1 | sed 's@[^/]*@..@g'
}
- function cpfile { # $1=source $2=dest
- ln -svf `back $2`/$1 $2/
- }
-
- function cpdir() { # $1=source $2=dest
- ln -svf `back $2`/$1 $2
+ function cpfile { # $1=source $2=dest $3=optional dest filename
+ local src=$1
+ if [[ "${src:0:1}" != "/" ]]; then
+ # Not an absolute path. We assume a relative path to be
+ # relative to the android root and we want to make it
+ # relative to the destination dir.
+ src=$(back $2)/$1
+ fi
+ ln -svf $src $2/$3
}
fi
@@ -105,10 +118,19 @@ LIBS=""
CP_FILES=""
+### Configure which libs to build.
+#
+# Each entry for LIBS needs to be prefixed with the way we want to build it:
+# make: - a library built using its traditional Android.mk
+# base: - a gradle library located in tools/base
+# swt: - a gradle library located in toosl/swt
+#
+# LIBS entries without or with an unknown ":" prefix will generate an error.
+
### BASE ###
BASE_PLUGIN_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.base/libs"
-BASE_PLUGIN_LIBS="common sdkstats sdklib dvlib layoutlib-api sdk-common"
+BASE_PLUGIN_LIBS="base:common swt:sdkstats base:sdklib base:dvlib base:layoutlib-api base:sdk-common"
BASE_PLUGIN_PREBUILTS="\
prebuilts/tools/common/m2/repository/net/sf/kxml/kxml2/2.3.0/kxml2-2.3.0.jar \
prebuilts/tools/common/m2/repository/org/apache/commons/commons-compress/1.0/commons-compress-1.0.jar \
@@ -128,7 +150,8 @@ CP_FILES="$CP_FILES @:$BASE_PLUGIN_DEST $BASE_PLUGIN_LIBS $BASE_PLUGIN_PREBUILTS
### ADT ###
ADT_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.adt/libs"
-ADT_LIBS="ant-glob asset-studio lint-api lint-checks ninepatch propertysheet rule-api sdkuilib swtmenubar manifest-merger"
+ADT_LIBS="make:ant-glob base:asset-studio base:lint-api base:lint-checks base:ninepatch make:propertysheet \
+ base:rule-api swt:sdkuilib swt:swtmenubar base:manifest-merger"
ADT_PREBUILTS="\
prebuilts/tools/common/freemarker/freemarker-2.3.19.jar \
prebuilts/tools/common/m2/repository/org/ow2/asm/asm/4.0/asm-4.0.jar \
@@ -143,7 +166,7 @@ CP_FILES="$CP_FILES @:$ADT_DEST $ADT_LIBS $ADT_PREBUILTS"
### DDMS ###
DDMS_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.ddms/libs"
-DDMS_LIBS="ddmlib ddmuilib swtmenubar uiautomatorviewer"
+DDMS_LIBS="base:ddmlib swt:ddmuilib swt:swtmenubar swt:uiautomatorviewer"
DDMS_PREBUILTS="\
prebuilts/tools/common/m2/repository/jfree/jcommon/1.0.12/jcommon-1.0.12.jar \
@@ -157,7 +180,7 @@ CP_FILES="$CP_FILES @:$DDMS_DEST $DDMS_LIBS $DDMS_PREBUILTS"
### TEST ###
TEST_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.tests"
-TEST_LIBS="easymock sdktestutils"
+TEST_LIBS="make:easymock base:sdktestutils"
TEST_PREBUILTS="prebuilts/tools/common/m2/repository/net/sf/kxml/kxml2/2.3.0/kxml2-2.3.0.jar"
LIBS="$LIBS $TEST_LIBS"
@@ -168,7 +191,7 @@ CP_FILES="$CP_FILES @:$TEST_DEST $TEST_LIBS $TEST_PREBUILTS"
if [[ $PLATFORM != "windows-x86" ]]; then
# We can't build enough of the platform on Cygwin to create layoutlib
- BRIDGE_LIBS="layoutlib ninepatch"
+ BRIDGE_LIBS="make:layoutlib base:ninepatch"
LIBS="$LIBS $BRIDGE_LIBS"
fi
@@ -177,7 +200,7 @@ fi
### HIERARCHYVIEWER ###
HV_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/libs"
-HV_LIBS="hierarchyviewer2lib swtmenubar"
+HV_LIBS="swt:hierarchyviewer2lib swt:swtmenubar"
LIBS="$LIBS $HV_LIBS"
CP_FILES="$CP_FILES @:$HV_DEST $HV_LIBS"
@@ -186,7 +209,7 @@ CP_FILES="$CP_FILES @:$HV_DEST $HV_LIBS"
### TRACEVIEW ###
TV_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.traceview/libs"
-TV_LIBS="traceview"
+TV_LIBS="swt:traceview"
LIBS="$LIBS $TV_LIBS"
CP_FILES="$CP_FILES @:$TV_DEST $TV_LIBS"
@@ -195,7 +218,7 @@ CP_FILES="$CP_FILES @:$TV_DEST $TV_LIBS"
### MONITOR ###
MONITOR_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.monitor/libs"
-MONITOR_LIBS="sdkuilib"
+MONITOR_LIBS="swt:sdkuilib"
LIBS="$LIBS $MONITOR_LIBS"
CP_FILES="$CP_FILES @:$MONITOR_DEST $MONITOR_LIBS"
@@ -203,7 +226,7 @@ CP_FILES="$CP_FILES @:$MONITOR_DEST $MONITOR_LIBS"
### SDKMANAGER ###
-SDKMAN_LIBS="swtmenubar"
+SDKMAN_LIBS="swt:swtmenubar"
LIBS="$LIBS $SDKMAN_LIBS"
@@ -214,18 +237,72 @@ if [[ $PLATFORM != "windows-x86" ]]; then
# liblzf doesn't build under cygwin. If necessary, this should be fixed first.
GLD_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.gldebugger/libs"
- GLD_LIBS="host-libprotobuf-java-2.3.0-lite liblzf"
+ GLD_LIBS="make:host-libprotobuf-java-2.3.0-lite make:liblzf"
LIBS="$LIBS $GLD_LIBS"
CP_FILES="$CP_FILES @:$GLD_DEST $GLD_LIBS"
fi
+
+#--- Determine what to build
+
+UNPROCESSED=""
+GRADLE_SWT=""
+GRADLE_BASE=""
+MAKE_TARGETS=""
+for LIB in $LIBS; do
+ if [[ "${LIB:0:5}" == "base:" ]]; then
+ GRADLE_BASE="$GRADLE_BASE :${LIB:5}:assemble"
+ elif [[ "${LIB:0:4}" == "swt:" ]]; then
+ GRADLE_SWT="$GRADLE_SWT :${LIB:4}:assemble"
+ elif [[ "${LIB:0:5}" == "make:" ]]; then
+ MAKE_TARGETS="$MAKE_TARGETS ${LIB:5}"
+ else
+ UNPROCESSED="$UNPROCESSED $LIB"
+ fi
+done
+
+unset LIBS # we shouldn't use this anymore, it has been split up just above.
+
+
+if [[ -n $UNPROCESSED ]]; then
+ die "## The following libs lack a prefix (make:, base: or swt:): $UNPROCESSED"
+fi
+
+# In the mode to only echo dependencies, output them and we're done
+if [[ -n $ONLY_SHOW_DEPS ]]; then
+ echo $MAKE_TARGETS
+ exit 0
+fi
+
+# --- Gradle Build ---
+
+# tools/base: if we need it for SWT, we build them all and public local.
+# Otherwise we do a specific tools/base build on just the requested targets.
+
+if [[ -n "$GRADLE_SWT" ]]; then
+ echo "### Starting tools/base: gradlew publishLocal"
+ (cd tools/base && ./gradlew publishLocal)
+elif [[ -n "$GRADLE_BASE" ]]; then
+ echo "### Starting tools/base: gradlew $GRADLE_BASE"
+ (cd tools/base && ./gradlew $GRADLE_BASE)
+fi
+
+# tools/swt: build requested targets
+
+if [[ -n "$GRADLE_SWT" ]]; then
+ echo "### Starting tools/swt: gradlew $GRADLE_SWT"
+ (cd tools/swt && ./gradlew $GRADLE_SWT)
+fi
+
+# --- Android.mk Build ---
+
# If some of the libs are available in prebuilts/devtools, use link to them directly
# instead of trying to rebuild them so remove them from the libs to build. Note that
# they are already listed in CP_FILES so we'll adjust the source to copy later.
-LIBS2=""
-for LIB in $LIBS; do
+NEW_TARGETS=""
+for LIB in $MAKE_TARGETS; do
J="prebuilts/devtools/tools/lib/$LIB.jar"
if [[ ! -f $J ]]; then
J="prebuilts/devtools/adt/lib/$LIB.jar"
@@ -233,38 +310,33 @@ for LIB in $LIBS; do
if [[ -f $J ]]; then
warn "## Using existing $J"
else
- LIBS2="$LIBS2 $LIB"
+ NEW_TARGETS="$NEW_TARGETS $LIB"
fi
done
-LIBS="$LIBS2"
-unset LIBS2
+MAKE_TARGETS="$NEW_TARGETS"
+unset NEW_TARGETS
-# In the mode to only echo dependencies, output them and we're done
-if [[ -n $ONLY_SHOW_DEPS ]]; then
- echo $LIBS
- exit 0
-fi
-if [[ -z $ONLY_COPY_DEPS ]]; then
- # Make sure we have lunch sdk-<something>
- if [[ ! "$TARGET_PRODUCT" ]]; then
- warn "## TARGET_PRODUCT is not set, running build/envsetup.sh"
- . build/envsetup.sh
- warn "## lunch sdk-eng"
- lunch sdk-eng
- fi
-
- # Run make on all libs
+if [[ -n $MAKE_TARGETS ]]; then
+ ( # Make sure we have lunch sdk-<something>
+ if [[ ! "$TARGET_PRODUCT" ]]; then
+ warn "## TARGET_PRODUCT is not set, running build/envsetup.sh"
+ . build/envsetup.sh
+ warn "## lunch sdk-eng"
+ lunch sdk-eng
+ fi
- J="4"
- [[ $(uname) == "Darwin" ]] && J=$(sysctl hw.ncpu | cut -d : -f 2 | tr -d ' ')
- [[ $(uname) == "Linux" ]] && J=$(cat /proc/cpuinfo | grep processor | wc -l)
+ J="4"
+ [[ $(uname) == "Darwin" ]] && J=$(sysctl hw.ncpu | cut -d : -f 2 | tr -d ' ')
+ [[ $(uname) == "Linux" ]] && J=$(cat /proc/cpuinfo | grep processor | wc -l)
- warn "## Building libs: make -j$J $LIBS"
- make -j${J} $LIBS
+ warn "## Building libs: make -j$J $MAKE_TARGETS"
+ make -j${J} $MAKE_TARGETS
+ )
fi
-# Copy resulting files
+# --- Copy resulting files ---
+
DEST=""
for SRC in $CP_FILES; do
if [[ "${SRC:0:2}" == "@:" ]]; then
@@ -272,8 +344,26 @@ for SRC in $CP_FILES; do
mkdir -vp "$DEST"
continue
fi
- if [[ ! -f "$SRC" ]]; then
+
+ ORIG_SRC="$SRC"
+ DEST_FILE=""
+
+ if [[ "${SRC:0:5}" == "base:" ]]; then
+ SRC="${SRC:5}"
+ ORIG_SRC="$SRC"
+ DEST_FILE="$SRC.jar"
+ SRC=$(printGradleJarPath tools/base $SRC)
+ elif [[ "${SRC:0:4}" == "swt:" ]]; then
+ SRC="${SRC:4}"
+ ORIG_SRC="$SRC"
+ DEST_FILE="$SRC.jar"
+ SRC=$(printGradleJarPath tools/swt $SRC)
+ elif [[ "${SRC:0:5}" == "make:" ]]; then
+ SRC="${SRC:5}"
ORIG_SRC="$SRC"
+ fi
+
+ if [[ ! -f "$SRC" ]]; then
# Take a prebuilts/devtools instead of a framework one if possible.
SRC="prebuilts/devtools/tools/lib/$SRC.jar"
if [[ ! -f "$SRC" ]]; then
@@ -288,7 +378,7 @@ for SRC in $CP_FILES; do
die "Invalid cp_file dest directory: $DEST"
fi
- cpfile "$SRC" "$DEST"
+ cpfile "$SRC" "$DEST" "$DEST_FILE"
else
die "## Unknown source '$ORIG_SRC' to copy in '$DEST'"
fi