#
# Usage: dex-preopt [options] path/to/input.jar path/to/output.odex
#
# This tool runs a host build of dalvikvm in order to preoptimize dex
# files that will be run on a device
.
# The input may be any sort of jar file (including .apk files), as long
# as it contains a classes.dex file. Note that optimized versions of
# bootstrap classes must be created before this can be run on other files;
# use the "--bootstrap" option to do this.
#
# The "output.odex" file must not already exist.
#
#
# This is expected to be running in a user build environment, where
# "dexopt" is available on the host.
#
# Options:
# --build-dir=path/to/out -- Specify where the base of the build tree is.
# This is typically a directory named "out". If not specified, it is
# assumed to be the current directory. The specified input and output
# paths are taken to be relative to this directory.
# --dexopt=path/to/dexopt -- Specify the path to the dexopt executable.
# If unspecified, there must be a unique subdirectory of the build-dir
# that looks like host/ARCH/bin which must contain dexopt.
# --product-dir=path/to/product -- Specify the path, relative to the build
# directory, where the product tree to be used is. This directory should
# contain the boot classpath jar files. If not specified, then there
# must be a unique directory in the build named "target/product/NAME",
# and this is the directory that will be used.
# --boot-dir=path/to/bootclasspath -- Specify the path, relative to the
# product directory, of the directory where the boot classpath files
# reside. If not specified, this defaults to "system/framework"
# --boot-jars=list:of:jar:base:names -- Specify the list of base names
# of bootstrap classpath elements, colon-separated. Order is significant
# and must match the BOOTCLASSPATH that is eventually specified at
# runtime on the device. This defaults to "core". However, this really
# needs to match the target product's BOOTCLASSPATH, which, as of this
# writing, doesn't have a super-strict way of being defined within the
# build. You can find variations of it in different init.rc files under
# system/core/rootdir or under product-specific directories.
# --bootstrap -- Process the bootstrap classes. If this is specified,
# then, instead of processing a specified input file, no other arguments
# are taken, and what is processed is the entirety of the boot jar
# list, in order.
# --verify={none,remote,all} -- Specify what level of verification to
# do. Defaults to "all".
# --optimize={none,verified,all} -- Specify which classes to optimize.
# Defaults to "verified".
# --no-register-maps -- Indicate that the output should not contain
# register maps. By default, register maps are created and included.
# --uniprocessor -- Indicate that the output should target a uniprocessor.
# By default, optimizations will be made that specifically target
# SMP processors (which will merely be superfluous on uniprocessors).
#
43 # $(1): the input .jar or .apk file
44 # $(2): the output .odex file
45 define dexpreopt-one-file
46 $(hide) $(DEXPREOPT) --dexopt=$(DEXPREOPT_DEXOPT) --build-dir=$(DEXPREOPT_BUILD_DIR) \
47 --product-dir=$(DEXPREOPT_PRODUCT_DIR) --boot-dir=$(DEXPREOPT_BOOT_JAR_DIR) \
48 --boot-jars=$(DEXPREOPT_BOOT_JARS) $(DEXPREOPT_UNIPROCESSOR) \
49 $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(1)) \
50 $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(2))
51 endef