OSDN Git Service

Support multidex run-test with Jack
authorSebastien Hertz <shertz@google.com>
Thu, 3 Mar 2016 17:08:17 +0000 (18:08 +0100)
committerSebastien Hertz <shertz@google.com>
Mon, 7 Mar 2016 10:45:41 +0000 (11:45 +0100)
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

test/462-checker-inlining-across-dex-files/multidex.jpp [new file with mode: 0644]
test/556-invoke-super/multidex.jpp [new file with mode: 0644]
test/569-checker-pattern-replacement/multidex.jpp [new file with mode: 0644]
test/etc/default-build

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 (file)
index 0000000..ae55456
--- /dev/null
@@ -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 (file)
index 0000000..fe01801
--- /dev/null
@@ -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 (file)
index 0000000..cfc8ad1
--- /dev/null
@@ -0,0 +1,8 @@
+Main:
+  @@com.android.jack.annotations.ForceInMainDex
+  class Main
+
+BaseInMainDex:
+  @@com.android.jack.annotations.ForceInMainDex
+  class BaseInMainDex
+
index 6e855ec..5f78496 100755 (executable)
@@ -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