[bazel] Build `rom_ext_signer` with Bazel
This commit:
- adds `BUILD` files for the rom_ext_signer and lib, and
- adds the `pkcs1v15` feature to mundane Bazel build to support the above.
This enables integrating the current signing tool into the
`opentitan_functest` Bazel macro. Note, in the future, the `rom_ext_signer`
functionality will be integrated into opentitantool.
This addresses a task in #10864.
Signed-off-by: Timothy Trippel <ttrippel@google.com>
diff --git a/sw/host/rom_ext_image_tools/signer/BUILD b/sw/host/rom_ext_image_tools/signer/BUILD
new file mode 100644
index 0000000..7b515b2
--- /dev/null
+++ b/sw/host/rom_ext_image_tools/signer/BUILD
@@ -0,0 +1,19 @@
+# Copyright lowRISC contributors.
+# Licensed under the Apache License, Version 2.0, see LICENSE for details.
+# SPDX-License-Identifier: Apache-2.0
+
+load("@rules_rust//rust:defs.bzl", "rust_binary")
+load("//third_party/cargo:crates.bzl", "all_crate_deps")
+
+package(default_visibility = ["//visibility:public"])
+
+rust_binary(
+ name = "rom_ext_signer",
+ srcs = [
+ "src/main.rs",
+ ],
+ deps = [
+ "//sw/host/rom_ext_image_tools/signer/image:rom_ext_image",
+ "@mundane//:mundane",
+ ] + all_crate_deps(),
+)
diff --git a/sw/host/rom_ext_image_tools/signer/Cargo.toml b/sw/host/rom_ext_image_tools/signer/Cargo.toml
index 0dd888a..4e90a64 100644
--- a/sw/host/rom_ext_image_tools/signer/Cargo.toml
+++ b/sw/host/rom_ext_image_tools/signer/Cargo.toml
@@ -25,6 +25,10 @@
thiserror = "1.0.24"
zerocopy = "0.5.0"
+# We depend on mundane, but `cargo raze` can't auto generate bazel rules for it.
+# In order to not break the current meson-based build system, we'll leave
+# mundane as a dependency. To regenerate the bazel dependency rules via
+# `cargo raze`, you'll have to temporarily comment out `mundane`.
[dependencies.mundane]
version = "0.5.0"
features = ["rsa-pkcs1v15"]
diff --git a/sw/host/rom_ext_image_tools/signer/image/BUILD b/sw/host/rom_ext_image_tools/signer/image/BUILD
new file mode 100644
index 0000000..bb4af7f
--- /dev/null
+++ b/sw/host/rom_ext_image_tools/signer/image/BUILD
@@ -0,0 +1,23 @@
+# Copyright lowRISC contributors.
+# Licensed under the Apache License, Version 2.0, see LICENSE for details.
+# SPDX-License-Identifier: Apache-2.0
+
+load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
+load("//third_party/cargo:crates.bzl", "all_crate_deps")
+
+package(default_visibility = ["//visibility:public"])
+
+rust_library(
+ name = "rom_ext_image",
+ srcs = [
+ "src/image.rs",
+ "src/lib.rs",
+ "src/manifest.rs",
+ ],
+ deps = all_crate_deps(),
+)
+
+rust_test(
+ name = "rom_ext_image_test",
+ crate = ":rom_ext_image",
+)
diff --git a/sw/host/rom_ext_image_tools/signer/image/Cargo.toml b/sw/host/rom_ext_image_tools/signer/image/Cargo.toml
index 14b5f31..0b7c9ad 100644
--- a/sw/host/rom_ext_image_tools/signer/image/Cargo.toml
+++ b/sw/host/rom_ext_image_tools/signer/image/Cargo.toml
@@ -12,4 +12,3 @@
memoffset = "0.6.0"
thiserror = "1.0.24"
zerocopy = "0.5.0"
-
diff --git a/sw/vendor/patches/mundane/build_with_bazel.patch b/sw/vendor/patches/mundane/build_with_bazel.patch
index 381f46e..01543c9 100644
--- a/sw/vendor/patches/mundane/build_with_bazel.patch
+++ b/sw/vendor/patches/mundane/build_with_bazel.patch
@@ -12,7 +12,7 @@
index 0000000..649d2b5
--- /dev/null
+++ b/BUILD.bazel
-@@ -0,0 +1,47 @@
+@@ -0,0 +1,48 @@
+load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
+
+package(default_visibility = ["//visibility:public"])
@@ -46,6 +46,7 @@
+ ],
+ crate_features = [
+ "bazel_build",
++ "rsa-pkcs1v15",
+ ],
+ edition = "2015",
+ deps = [