Remove --shard argument from run_test_build.py

Use the passed sources to identify the tests to build.

Test: generated build artifacts are the same
Change-Id: I01b19cb65727905113d5402d00ed879628c51582
diff --git a/test/Android.run-test.bp.py b/test/Android.run-test.bp.py
index cb65caa..51c7d8d 100755
--- a/test/Android.run-test.bp.py
+++ b/test/Android.run-test.bp.py
@@ -37,10 +37,8 @@
           java_genrule {{
               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)",
+              srcs: ["?{shard}-*/**/*", "??{shard}-*/**/*"],
+              defaults: ["art-run-test-{mode}-data-defaults"],
           }}
 
           // Install in the output directory to make it accessible for tests.
@@ -53,13 +51,36 @@
           }}
           """.format(name=name, mode=mode, shard=shard)))
 
+      f.write(textwrap.dedent("""
+        genrule_defaults {{
+            name: "art-run-test-{mode}-data-defaults",
+            defaults: [
+                // Enable only in source builds, where com.android.art.testing is
+                // available.
+                "art_module_source_build_genrule_defaults",
+            ],
+            tool_files: [
+                "run_test_build.py",
+                ":art-run-test-bootclasspath",
+            ],
+            tools: [
+                "d8",
+                "hiddenapi",
+                "jasmin",
+                "smali",
+            ],
+            cmd: "$(location run_test_build.py) --out $(out) --mode {mode} " +
+                "--bootclasspath $(location :art-run-test-bootclasspath) $(in)",
+        }}
+        """).format(mode=mode))
+
       name = "art-run-test-{mode}-data-merged".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: "{name}-tmp",
-            defaults: ["art-run-test-data-defaults"],
+            defaults: ["art_module_source_build_genrule_defaults"],
             out: ["{name}.zip"],
             srcs: [
                 {srcs}