[component_manager] include in fuchsia.zbi

Bug: CF-651 #done
Change-Id: I4165c217ee4f05566bcfddbdc167d1591a41bec6
diff --git a/build/images/BUILD.gn b/build/images/BUILD.gn
index de8feed..e8f505e 100644
--- a/build/images/BUILD.gn
+++ b/build/images/BUILD.gn
@@ -71,9 +71,7 @@
 
 assert(
     meta_package_labels != [],
-    "Missing meta_package_labels. Are you using a supported product configuration? " +
-    "Check your args.gn file for an import of a product configuration, and consider " +
-    "using one of the products in the `//products` or `//vendor/*/products` directories.")
+    "Missing meta_package_labels. Are you using a supported product configuration? " + "Check your args.gn file for an import of a product configuration, and consider " + "using one of the products in the `//products` or `//vendor/*/products` directories.")
 
 # This will collect a list of scopes describing each image exported.
 # See json.gni.
@@ -602,17 +600,28 @@
   ]
 }
 
+component_manager_label =
+    "//garnet/bin/sys/component_manager:component_manager.bootfs"
+component_manager_target_dir =
+    get_label_info(component_manager_label, "target_out_dir")
+component_manager_target_name = get_label_info(component_manager_label, "name")
+component_manager_manifest =
+    component_manager_target_dir + "/" + component_manager_target_name
+
 # The main bootable image, which requires `blob.blk` to appear on some
 # attached storage device at runtime.
 zbi("fuchsia") {
   testonly = true
+
   deps = [
     ":devmgr_config.txt",
     ":system_image.manifest",
+    component_manager_label,
   ]
   inputs = [
-    zircon_kernel_zbi,
+    component_manager_manifest,
     boot_manifest,
+    zircon_kernel_zbi,
   ]
   manifest = [
     {
diff --git a/build/images/zedboot/BUILD.gn b/build/images/zedboot/BUILD.gn
index 057fd0d..a231980 100644
--- a/build/images/zedboot/BUILD.gn
+++ b/build/images/zedboot/BUILD.gn
@@ -93,13 +93,20 @@
   }
 }
 
+component_manager_label = "//garnet/bin/sys/component_manager:component_manager.bootfs"
+component_manager_target_dir = get_label_info(component_manager_label, "target_out_dir")
+component_manager_target_name = get_label_info(component_manager_label, "name")
+component_manager_manifest = component_manager_target_dir + "/" + component_manager_target_name
+
 zbi("zbi") {
   output_name = "zedboot"
   deps = [
     ":devmgr_config.txt",
     ":zedboot.manifest",
+    component_manager_label,
   ]
   inputs = [
+    component_manager_manifest,
     zircon_kernel_zbi,
     manifest_file,
   ]
diff --git a/garnet/bin/sys/component_manager/BUILD.gn b/garnet/bin/sys/component_manager/BUILD.gn
index 1f7cf09..0f208c9 100644
--- a/garnet/bin/sys/component_manager/BUILD.gn
+++ b/garnet/bin/sys/component_manager/BUILD.gn
@@ -42,6 +42,16 @@
   ]
 }
 
+# This manifest is consumed by the ZBI rule in //build/images to add component_manager to bootfs.
+generate_manifest("component_manager.bootfs") {
+  deps = [
+    ":bin",
+  ]
+
+  args = [ "--entry=bin/component_manager=" +
+           rebase_path("$root_build_dir/component_manager", root_build_dir) ]
+}
+
 package("component_manager") {
   deps = [
     ":bin",