[zircon] [gn] Add legacy-host_tests target

This copies all the host tests to $root_build_dir/host_tests as
the legacy build infra expects.

Bug: BLD-325
Bug: BLD-353
Test: gn gen && ninja legacy-host_tests
Change-Id: I29cc628e7ba9313508e1a4a421e73ff5d14cc6b9
diff --git a/zircon/BUILD.gn b/zircon/BUILD.gn
index 5438d9c..04dea14 100644
--- a/zircon/BUILD.gn
+++ b/zircon/BUILD.gn
@@ -70,6 +70,43 @@
       ]
     }
   }
+
+  # TODO(BLD-353): Temporary hacks for integrating with the legacy Fuchsia
+  # GN build.
+  host_tests_rspfile = "$target_gen_dir/host_tests.rsp"
+  generated_file("host_tests.rsp") {
+    testonly = true
+    visibility = [ ":legacy-host_tests" ]
+    outputs = [
+      host_tests_rspfile,
+    ]
+    deps = [
+      "system/utest:host",
+    ]
+    output_conversion = "list lines"
+    data_keys = [ "link_output" ]
+    walk_keys = [ "link_barrier" ]
+  }
+
+  action("legacy-host_tests") {
+    testonly = true
+    deps = [
+      ":host_tests.rsp",
+    ]
+    script = "$zx/scripts/copy-files"
+    depfile = "$target_out_dir/$target_name.d"
+    outputs = [
+      depfile,
+    ]
+    sources = [
+      host_tests_rspfile,
+    ]
+    args = [
+      "host_tests",
+      rebase_path(depfile, root_build_dir),
+      rebase_path(host_tests_rspfile, root_build_dir),
+    ]
+  }
 }
 
 group("default") {