From ed93980a2f09f027b32f7141594fb5dfc5fc8efb Mon Sep 17 00:00:00 2001 From: yroussel Date: Fri, 26 Oct 2012 16:33:53 +0200 Subject: Define scripts for calling DexMerger. (cherry picked from commit 4f00f32e39f04b5b7ba6684ee3914d9904a139d5) Change-Id: I86cedb9f48bbb8f7f1945f86b9e10bc2f37a24b9 --- dx/Android.mk | 18 ++++++++++++ dx/etc/dexmerger | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 dx/etc/dexmerger (limited to 'dx') diff --git a/dx/Android.mk b/dx/Android.mk index b31b23b3b..edf8ca3b4 100644 --- a/dx/Android.mk +++ b/dx/Android.mk @@ -29,6 +29,24 @@ INTERNAL_DALVIK_MODULES += $(LOCAL_INSTALLED_MODULE) endif # TARGET_BUILD_APPS +# the dexmerger script +# ============================================================ +include $(CLEAR_VARS) +LOCAL_IS_HOST_MODULE := true +LOCAL_MODULE_CLASS := EXECUTABLES +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE := dexmerger + +include $(BUILD_SYSTEM)/base_rules.mk + +$(LOCAL_BUILT_MODULE): $(HOST_OUT_JAVA_LIBRARIES)/dx$(COMMON_JAVA_PACKAGE_SUFFIX) +$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/etc/dexmerger | $(ACP) + @echo "Copy: $(PRIVATE_MODULE) ($@)" + $(copy-file-to-new-target) + $(hide) chmod 755 $@ + +INTERNAL_DALVIK_MODULES += $(LOCAL_INSTALLED_MODULE) + # the jasmin script # ============================================================ include $(CLEAR_VARS) diff --git a/dx/etc/dexmerger b/dx/etc/dexmerger new file mode 100644 index 000000000..58fd9ab9d --- /dev/null +++ b/dx/etc/dexmerger @@ -0,0 +1,89 @@ +#!/bin/bash +# +# Copyright (C) 2012 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. + +# Set up prog to be the path of this script, including following symlinks, +# and set up progdir to be the fully-qualified pathname of its directory. +prog="$0" +while [ -h "${prog}" ]; do + newProg=`/bin/ls -ld "${prog}"` + newProg=`expr "${newProg}" : ".* -> \(.*\)$"` + if expr "x${newProg}" : 'x/' >/dev/null; then + prog="${newProg}" + else + progdir=`dirname "${prog}"` + prog="${progdir}/${newProg}" + fi +done +oldwd=`pwd` +progdir=`dirname "${prog}"` +cd "${progdir}" +progdir=`pwd` +prog="${progdir}"/`basename "${prog}"` +cd "${oldwd}" + +jarfile=dx.jar +libdir="$progdir" + +if [ ! -r "$libdir/$jarfile" ]; then + # set dx.jar location for the SDK case + libdir=`dirname "$progdir"`/platform-tools/lib +fi + + +if [ ! -r "$libdir/$jarfile" ]; then + # set dx.jar location for the Android tree case + libdir=`dirname "$progdir"`/framework +fi + +if [ ! -r "$libdir/$jarfile" ]; then + echo `basename "$prog"`": can't find $jarfile" + exit 1 +fi + +# By default, give dexmerger a max heap size of 1 gig. This can be overridden +# by using a "-J" option (see below). +defaultMx="-Xmx1024M" + +# The following will extract any initial parameters of the form +# "-J" from the command line and pass them to the Java +# invocation (instead of to dexmerger). This makes it possible for you to add +# a command-line parameter such as "-JXmx256M" in your scripts, for +# example. "java" (with no args) and "java -X" give a summary of +# available options. + +javaOpts="" + +while expr "x$1" : 'x-J' >/dev/null; do + opt=`expr "x$1" : 'x-J\(.*\)'` + javaOpts="${javaOpts} -${opt}" + if expr "x${opt}" : "xXmx[0-9]" >/dev/null; then + defaultMx="no" + fi + shift +done + +if [ "${defaultMx}" != "no" ]; then + javaOpts="${javaOpts} ${defaultMx}" +fi + +if [ "$OSTYPE" = "cygwin" ]; then + # For Cygwin, convert the jarfile path into native Windows style. + jarpath=`cygpath -w "$libdir/$jarfile"` +else + jarpath="$libdir/$jarfile" +fi + +exec java $javaOpts -cp "$jarpath" com.android.dx.merge.DexMerger "$@" -- cgit v1.2.3