[fuchsia][v8] Migrate d8 to a component framework v2 Fuchsia component

In the process, switch to using the Fuchsia GN SDK templates for
building the component and package.

Bug: 1092804,v8:12589
Change-Id: Id56ac84024e02c530c271b6acb164c84e35262e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3883943
Reviewed-by: Sylvain Defresne <[email protected]>
Commit-Queue: Greg Thompson <[email protected]>
Auto-Submit: Greg Thompson <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1045794}
diff --git a/BUILD.gn b/BUILD.gn
index b61022b..cab98a8 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -38,6 +38,12 @@
   import("//build/config/android/config.gni")
 }
 
+if (is_fuchsia) {
+  import("//build/config/fuchsia/generate_runner_scripts.gni")
+  import("//third_party/fuchsia-sdk/sdk/build/component.gni")
+  import("//third_party/fuchsia-sdk/sdk/build/package.gni")
+}
+
 if (is_linux) {
   import("build/config/linux/gtk/gtk.gni")
 }
@@ -930,16 +936,19 @@
 if (is_fuchsia) {
   # TODO(https://crbug.com/731217): This can't practically be in //v8 without
   # duplicating all the Fuchsia running infrastructure there.
-  cr_fuchsia_package("d8_fuchsia_pkg") {
+  fuchsia_component("d8_component") {
     testonly = true
-    binary = "//v8:d8"
-    manifest = "//v8/gni/v8.cmx"
-    package_name = "d8"
+    manifest = "//v8/gni/v8.cml"
+    data_deps = [ "//v8:d8" ]
   }
-
+  fuchsia_package("d8_pkg") {
+    testonly = true
+    package_name = "d8"
+    deps = [ ":d8_component" ]
+  }
   fuchsia_package_installer("d8_fuchsia") {
     testonly = true
-    package = ":d8_fuchsia_pkg"
+    package = ":d8_pkg"
     package_name = "d8"
   }
 }