[bazel][flash] Add flash script to the build graph

... when only building for Bazel assembly. Flash script is needed for
infra to recover devices.

Change-Id: I2a4971e51fb82b6ceea306666ea3096702fe2463
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/865257
Reviewed-by: Jiaming Li <lijiaming@google.com>
Commit-Queue: Jay Zhuang <jayzhuang@google.com>
diff --git a/build/images/BUILD.gn b/build/images/BUILD.gn
index 0d7daf4..92e1280 100644
--- a/build/images/BUILD.gn
+++ b/build/images/BUILD.gn
@@ -264,12 +264,6 @@
   #    accidentally become load-bearing.
   #
   if (!use_bazel_images_only) {
-    # Bazel assembly uses product bundle to flash.
-    deps += [
-      "//build/images/flash:flash_script",
-      "//build/images/tools:fastboot($host_toolchain)",
-    ]
-
     # Paving is not supported in Bazel assembly.
     if (recovery_is_zedboot) {
       deps += [
@@ -297,8 +291,12 @@
   }
 
   # Even if Bazel assembly uses product bundle to flash, downstream tools can
-  # still expect flash.json to exist for flashing.
-  deps += [ "//build/images/flash:fastboot_manifest" ]
+  # still expect flash.json and flash.sh to exist for flashing.
+  deps += [
+    "//build/images/flash:fastboot_manifest",
+    "//build/images/flash:flash_script",
+    "//build/images/tools:fastboot($host_toolchain)",
+  ]
 
   if (size_checker_input != {
       }) {
diff --git a/build/images/flash/BUILD.gn b/build/images/flash/BUILD.gn
index 0a88404..71d76df 100644
--- a/build/images/flash/BUILD.gn
+++ b/build/images/flash/BUILD.gn
@@ -195,7 +195,7 @@
     "--fvm-image=" + rebase_path(files.fxfs, root_build_dir),
     "--fvm=${fxfs_partition}",
   ]
-  flash_script_deps += [ "//build/images/fuchsia" ]
+  flash_script_deps += [ labels.images ]
 
   parts += [
     {
@@ -208,7 +208,7 @@
     "--fvm-image=" + rebase_path(files.fvm_fastboot, root_build_dir),
     "--fvm=${fvm_partition}",
   ]
-  flash_script_deps += [ "//build/images/fuchsia" ]
+  flash_script_deps += [ labels.images ]
 
   parts += [
     {