Conditionally compile/link ARM & ARM64 disassemblers based on targeted archs.

Note: We still unconditionally compile and link the MIPS32/MIPS64
and x86/x86-64 disassemblers, as they cannot be easily made
orthogonal in the Blueprint file.

Test: Build ART on host
Test: Build ART for ARM-only device
Test: Build ART for ARM64-only device
Test: Build ART for ARM64/ARM device
Bug: 119090273
Change-Id: Iec7bfed660ad0008bb870bfa614a90113bf4c501
diff --git a/disassembler/Android.bp b/disassembler/Android.bp
index 241b191..a7c1802 100644
--- a/disassembler/Android.bp
+++ b/disassembler/Android.bp
@@ -20,11 +20,39 @@
     host_supported: true,
     srcs: [
         "disassembler.cc",
-        "disassembler_arm.cc",
-        "disassembler_arm64.cc",
         "disassembler_mips.cc",
         "disassembler_x86.cc",
     ],
+    codegen: {
+        arm: {
+            srcs: ["disassembler_arm.cc"]
+        },
+        arm64: {
+            srcs: ["disassembler_arm64.cc"]
+        },
+        // TODO: We should also conditionally include the MIPS32/MIPS64 and the
+        // x86/x86-64 disassembler definitions (b/119090273). However, using the
+        // following syntax here:
+        //
+        //   mips: {
+        //       srcs: ["disassembler_mips.cc"]
+        //   },
+        //   mips64: {
+        //       srcs: ["disassembler_mips.cc"]
+        //   },
+        //   x86: {
+        //       srcs: ["disassembler_x86.cc"]
+        //   },
+        //   x86_64: {
+        //       srcs: ["disassembler_x86.cc"]
+        //   },
+        //
+        // does not work, as it generates a file rejected by ninja with this
+        // error message (e.g. on host, where we include all the back ends by
+        // default):
+        //
+        //   FAILED: ninja: out/soong/build.ninja:320768: multiple rules generate out/soong/.intermediates/art/disassembler/libart-disassembler/linux_glibc_x86_64_static/obj/art/disassembler/disassembler_mips.o [-w dupbuild=err]
+    },
     include_dirs: ["art/runtime"],
 
     shared_libs: [