From 4856ca7f652b889c176a2af747d5cc4b334fc1c6 Mon Sep 17 00:00:00 2001 From: Sebastien Hertz Date: Thu, 3 Mar 2016 18:08:17 +0100 Subject: [PATCH] Support multidex run-test with Jack Updates default-build script to compile multidex run-tests with Jack. Such test needs a 'multidex.jpp' file specifying how to partition classes in the output dex files (mainly how to stick some classes in the classes.dex file and others in a classes2.dex file). Bug: 19467889 Change-Id: I2500967ba951218c5b03166b3586a576d6dc8749 --- .../multidex.jpp | 8 ++++++ test/556-invoke-super/multidex.jpp | 4 +++ test/569-checker-pattern-replacement/multidex.jpp | 8 ++++++ test/etc/default-build | 29 +++++++++++++--------- 4 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 test/462-checker-inlining-across-dex-files/multidex.jpp create mode 100644 test/556-invoke-super/multidex.jpp create mode 100644 test/569-checker-pattern-replacement/multidex.jpp diff --git a/test/462-checker-inlining-across-dex-files/multidex.jpp b/test/462-checker-inlining-across-dex-files/multidex.jpp new file mode 100644 index 000000000..ae554566c --- /dev/null +++ b/test/462-checker-inlining-across-dex-files/multidex.jpp @@ -0,0 +1,8 @@ +Main: + @@com.android.jack.annotations.ForceInMainDex + class Main + +AAA: + @@com.android.jack.annotations.ForceInMainDex + class AAA + diff --git a/test/556-invoke-super/multidex.jpp b/test/556-invoke-super/multidex.jpp new file mode 100644 index 000000000..fe018019e --- /dev/null +++ b/test/556-invoke-super/multidex.jpp @@ -0,0 +1,4 @@ +Main: + @@com.android.jack.annotations.ForceInMainDex + class Main* + diff --git a/test/569-checker-pattern-replacement/multidex.jpp b/test/569-checker-pattern-replacement/multidex.jpp new file mode 100644 index 000000000..cfc8ad1fc --- /dev/null +++ b/test/569-checker-pattern-replacement/multidex.jpp @@ -0,0 +1,8 @@ +Main: + @@com.android.jack.annotations.ForceInMainDex + class Main + +BaseInMainDex: + @@com.android.jack.annotations.ForceInMainDex + class BaseInMainDex + diff --git a/test/etc/default-build b/test/etc/default-build index 6e855ec30..5f78496c3 100755 --- a/test/etc/default-build +++ b/test/etc/default-build @@ -116,28 +116,33 @@ if ! [ "${HAS_SRC}" = "true" ] && ! [ "${HAS_SRC2}" = "true" ]; then SKIP_DX_MERGER="true" fi -if [ "${HAS_SRC_MULTIDEX}" = "true" ]; then - # Jack does not support this configuration unless we specify how to partition the DEX file - # with a .jpp file. - USE_JACK="false" -fi - if [ ${USE_JACK} = "true" ]; then # Jack toolchain if [ "${HAS_SRC}" = "true" ]; then - ${JACK} ${JACK_ARGS} --output-jack src.jack src - imported_jack_files="--import src.jack" + if [ "${HAS_SRC_MULTIDEX}" = "true" ]; then + # Compile src and src-multidex in the same .jack file. We will apply multidex partitioning + # when creating the output .dex file. + ${JACK} ${JACK_ARGS} --output-jack src.jack src src src-multidex + jack_extra_args="${jack_extra_args} -D jack.dex.output.policy=minimal-multidex" + jack_extra_args="${jack_extra_args} -D jack.preprocessor=true" + jack_extra_args="${jack_extra_args} -D jack.preprocessor.file=multidex.jpp" + else + ${JACK} ${JACK_ARGS} --output-jack src.jack src + fi + jack_extra_args="${jack_extra_args} --import src.jack" fi if [ "${HAS_SRC2}" = "true" ]; then ${JACK} ${JACK_ARGS} --output-jack src2.jack src2 - imported_jack_files="--import src2.jack ${imported_jack_files}" + # In case of duplicate classes, we want to take into account the classes from src2. Therefore + # we apply the 'keep-first' policy and import src2.jack file *before* the src.jack file. + jack_extra_args="${jack_extra_args} -D jack.import.type.policy=keep-first" + jack_extra_args="--import src2.jack ${jack_extra_args}" fi - # Compile jack files into a DEX file. We set jack.import.type.policy=keep-first to consider - # class definitions from src2 first. + # Compile jack files into a DEX file. if [ "${HAS_SRC}" = "true" ] || [ "${HAS_SRC2}" = "true" ]; then - ${JACK} ${JACK_ARGS} ${imported_jack_files} -D jack.import.type.policy=keep-first --output-dex . + ${JACK} ${JACK_ARGS} ${jack_extra_args} --output-dex . fi else # Legacy toolchain with javac+dx -- 2.11.0