Revert^4 Build only the needed run-test shards with "test.py -b -t XXX"

This reverts commit 592c561dac5b6024cc18ddd9a946000597559c51.

Reason for revert: Reland

Change-Id: I10f5755be2d8590174b66075e8c39b56ae3b14f3
diff --git a/test/Android.run-test.bp.py b/test/Android.run-test.bp.py
index a051a1d..bca48fe 100755
--- a/test/Android.run-test.bp.py
+++ b/test/Android.run-test.bp.py
@@ -35,27 +35,51 @@
         names.append(name)
         f.write(textwrap.dedent("""
           java_genrule {{
-              name: "{name}",
+              name: "{name}-tmp",
               out: ["{name}.zip"],
               srcs: ["*{shard}-*/**/*"],
               defaults: ["art-run-test-data-defaults"],
               cmd: "$(location run-test-build.py) --out $(out) --mode {mode} --shard {shard} " +
                   "--bootclasspath $(location :art-run-test-bootclasspath)",
           }}
+
+          // Install in the output directory to make it accessible for tests.
+          prebuilt_etc_host {{
+              name: "{name}",
+              defaults: ["art_module_source_build_prebuilt_defaults"],
+              src: ":{name}-tmp",
+              sub_dir: "art",
+              filename: "{name}.zip",
+          }}
           """.format(name=name, mode=mode, shard=shard)))
-      srcs = ("\n"+" "*8).join('":{}",'.format(n) for n in names)
+
+      name = "art-run-test-{mode}-data".format(mode=mode)
+      srcs = ("\n"+" "*8).join('":{}-tmp",'.format(n) for n in names)
+      deps = ("\n"+" "*8).join('"{}",'.format(n) for n in names)
       f.write(textwrap.dedent("""
         java_genrule {{
-            name: "art-run-test-{mode}-data-merged",
+            name: "{name}-tmp",
             defaults: ["art-run-test-data-defaults"],
-            out: ["art-run-test-{mode}-data-merged.zip"],
+            out: ["{name}.zip"],
             srcs: [
                 {srcs}
             ],
             tools: ["merge_zips"],
             cmd: "$(location merge_zips) $(out) $(in)",
         }}
-        """).format(mode=mode, srcs=srcs))
+
+        // Install in the output directory to make it accessible for tests.
+        prebuilt_etc_host {{
+            name: "{name}",
+            defaults: ["art_module_source_build_prebuilt_defaults"],
+            src: ":{name}-tmp",
+            required: [
+                {deps}
+            ],
+            sub_dir: "art",
+            filename: "{name}.zip",
+        }}
+        """).format(name=name, srcs=srcs, deps=deps))
 
 if __name__ == "__main__":
   main()