Switch to new fuchsia_package templates

Change-Id: I07564d4b688defa376fd97a93568ba410e0bd384
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/Vulkan-Tools/+/524123
Reviewed-by: John Rosasco <rosasco@google.com>
diff --git a/cube/BUILD.gn b/cube/BUILD.gn
index 5ead1c6..0662018 100644
--- a/cube/BUILD.gn
+++ b/cube/BUILD.gn
@@ -13,10 +13,11 @@
 # limitations under the License.
 
 import("//build/compiled_action.gni")
-import("//build/package.gni")
+import("//build/components/fuchsia_package_with_single_component.gni")
 import("//build_overrides/vulkan_tools.gni")
 import("//src/lib/vulkan/image_pipe_swapchain.gni")
 import("//src/lib/vulkan/layers.gni")
+import("//src/sys/component_index/component_index.gni")
 
 group("cube") {
   testonly = true
@@ -27,90 +28,61 @@
   ]
 }
 
-package("vkcube-on-fb") {
-  testonly = true
-
-  deps = [ ":cube-fb" ]
-
-  binaries = [
-    {
-      name = "cube-fb"
-      dest = "vkcube-on-fb"
-    },
-  ]
-
-  meta = [
-    {
-      path = rebase_path("fuchsia/meta/vkcube-on-fb.cmx")
-      dest = "vkcube-on-fb.cmx"
-    },
-  ]
-
-  public_deps =
-      vulkan_validation_layers.public_deps + image_pipe_swapchain_fb.public_deps
-
-  loadable_modules = vulkan_validation_layers.loadable_modules +
-                     image_pipe_swapchain_fb.loadable_modules
-
-  resources =
-      vulkan_validation_layers.resources + image_pipe_swapchain_fb.resources
+add_to_component_index("fb-component-index") {
+  package_name = "vkcube-on-fb"
+  manifest = "meta/vkcube-on-fb.cmx"
 }
 
-package("vkcube-on-scenic") {
+fuchsia_package_with_single_component("vkcube-on-fb") {
   testonly = true
 
-  deps = [ ":cube-scenic" ]
-
-  binaries = [
-    {
-      name = "cube-scenic"
-      dest = "vkcube-on-scenic"
-    },
+  deps = [
+    ":cube-fb",
+    ":fb-component-index",
+    "//src/lib/vulkan/swapchain:image_pipe_swapchain_fb_layer",
+    "//src/lib/vulkan/validation_layers",
   ]
 
-  meta = [
-    {
-      path = rebase_path("fuchsia/meta/vkcube-on-scenic.cmx")
-      dest = "vkcube-on-scenic.cmx"
-    },
-  ]
-
-  public_deps =
-      vulkan_validation_layers.public_deps + image_pipe_swapchain.public_deps
-
-  loadable_modules = vulkan_validation_layers.loadable_modules +
-                     image_pipe_swapchain.loadable_modules
-
-  resources =
-      vulkan_validation_layers.resources + image_pipe_swapchain.resources
+  component_name = "vkcube-on-fb"
+  manifest = "fuchsia/meta/vkcube-on-fb.cmx"
 }
 
-package("vkcube-skip-present") {
+add_to_component_index("scenic-component-index") {
+  package_name = "vkcube-on-scenic"
+  manifest = "meta/vkcube-on-scenic.cmx"
+}
+
+fuchsia_package_with_single_component("vkcube-on-scenic") {
   testonly = true
 
-  deps = [ ":cube-skip-present" ]
-
-  binaries = [
-    {
-      name = "cube-skip-present"
-      dest = "vkcube-skip-present"
-    },
+  deps = [
+    ":cube-scenic",
+    ":scenic-component-index",
+    "//src/lib/vulkan/swapchain:image_pipe_swapchain_layer",
+    "//src/lib/vulkan/validation_layers",
   ]
 
-  meta = [
-    {
-      path = rebase_path("fuchsia/meta/vkcube-skip-present.cmx")
-      dest = "vkcube-skip-present.cmx"
-    },
+  component_name = "vkcube-on-scenic"
+  manifest = "fuchsia/meta/vkcube-on-scenic.cmx"
+}
+
+add_to_component_index("skip-present-component-index") {
+  package_name = "vkcube-skip-present"
+  manifest = "meta/vkcube-skip-present.cmx"
+}
+
+fuchsia_package_with_single_component("vkcube-skip-present") {
+  testonly = true
+
+  deps = [
+    ":cube-skip-present",
+    ":skip-present-component-index",
+    "//src/lib/vulkan/swapchain:image_pipe_swapchain_fb_skip_present_layer",
+    "//src/lib/vulkan/validation_layers",
   ]
 
-  public_deps = vulkan_validation_layers.public_deps +
-                image_pipe_swapchain_fb_skip_present.public_deps
-
-  loadable_modules = vulkan_validation_layers.loadable_modules +
-                     image_pipe_swapchain_fb_skip_present.loadable_modules
-  resources = vulkan_validation_layers.resources +
-              image_pipe_swapchain_fb_skip_present.resources
+  component_name = "vkcube-skip-present"
+  manifest = "fuchsia/meta/vkcube-skip-present.cmx"
 }
 
 config("cube_config") {
@@ -136,6 +108,7 @@
 }
 
 executable("cube-scenic") {
+  output_name = "vkcube-on-scenic"
   defines = [
     "FUCHSIA_USE_SCENIC=1",
     "FUCHSIA_IMAGEPIPE_LAYER=\"VK_LAYER_FUCHSIA_imagepipe_swapchain\"",
@@ -170,6 +143,7 @@
 }
 
 executable("cube-fb") {
+  output_name = "vkcube-on-fb"
   defines = [
     "FUCHSIA_USE_SCENIC=0",
     "FUCHSIA_IMAGEPIPE_LAYER=\"VK_LAYER_FUCHSIA_imagepipe_swapchain_fb\"",
@@ -192,6 +166,7 @@
 }
 
 executable("cube-skip-present") {
+  output_name = "vkcube-skip-present"
   defines = [
     "FUCHSIA_USE_SCENIC=0",
     "FUCHSIA_IMAGEPIPE_LAYER=\"VK_LAYER_FUCHSIA_imagepipe_swapchain_fb_skip_present\"",