[bazel] Add rules to build spiflash utility

The SPI Flash tool has multiple purposes. The primary is to interact
with Verilator simulations or FGPA instances of OpenTitan to reset the
chip and bootstrap SW into flash. The second is to split a device BIN
into SPI flash frames that can be used in DV sims to bootstrap the chip.

While the former is now handled by opentitantool, the latter is still
required to build a bootstrap flash image that can be use in DV sim.
This adds bazel rules to support building this utility, and its deps.

Signed-off-by: Timothy Trippel <ttrippel@google.com>
diff --git a/sw/host/spiflash/BUILD b/sw/host/spiflash/BUILD
new file mode 100644
index 0000000..153f4b1
--- /dev/null
+++ b/sw/host/spiflash/BUILD
@@ -0,0 +1,26 @@
+# Copyright lowRISC contributors.
+# Licensed under the Apache License, Version 2.0, see LICENSE for details.
+# SPDX-License-Identifier: Apache-2.0
+
+package(default_visibility = ["//visibility:public"])
+
+cc_binary(
+    name = "spiflash",
+    srcs = [
+        "ftdi_spi_interface.cc",
+        "ftdi_spi_interface.h",
+        "spi_interface.h",
+        "spiflash.cc",
+        "updater.cc",
+        "updater.h",
+        "verilator_spi_interface.cc",
+        "verilator_spi_interface.h",
+    ],
+    linkopts = [
+        "-lftdi1",
+    ],
+    deps = [
+        "//sw/host/vendor:mpsse",
+        "//sw/vendor:cryptoc_sha256",
+    ],
+)
diff --git a/sw/host/vendor/BUILD b/sw/host/vendor/BUILD
new file mode 100644
index 0000000..14314c4
--- /dev/null
+++ b/sw/host/vendor/BUILD
@@ -0,0 +1,26 @@
+# Copyright lowRISC contributors.
+# Licensed under the Apache License, Version 2.0, see LICENSE for details.
+# SPDX-License-Identifier: Apache-2.0
+
+package(default_visibility = ["//visibility:public"])
+
+cc_library(
+    name = "mpsse",
+    srcs = [
+        "mpsse/mpsse.c",
+        "mpsse/support.c",
+        "mpsse/support.h",
+    ],
+    hdrs = [
+        "mpsse/mpsse.h",
+    ],
+    copts = [
+        # TODO: Remove this once https://github.com/lowRISC/opentitan/issues/3182
+        # is resolved.
+        "-Wno-error=deprecated-declarations",
+    ],
+    linkopts = [
+        "-lftdi1",
+        "-lusb-1.0",
+    ],
+)
diff --git a/sw/vendor/BUILD b/sw/vendor/BUILD
index cd07fde..a546d11 100644
--- a/sw/vendor/BUILD
+++ b/sw/vendor/BUILD
@@ -2,4 +2,16 @@
 # Licensed under the Apache License, Version 2.0, see LICENSE for details.
 # SPDX-License-Identifier: Apache-2.0
 
+package(default_visibility = ["//visibility:public"])
+
 exports_files(glob(["veri-titan/gen/*.s"]))
+
+cc_library(
+    name = "cryptoc_sha256",
+    srcs = ["cryptoc/sha256.c"],
+    hdrs = [
+        "cryptoc/include/cryptoc/hash-internal.h",
+        "cryptoc/include/cryptoc/sha256.h",
+    ],
+    strip_include_prefix = "cryptoc/include",
+)