Add baremetal _nostd variant
Note that product_available and vendor_available are dropped from the
existing target because they are irrelevant for a _host target (as per
the change in aosp/2763825).
Add a visibility restriction to the new variant to preserve the
limitation that this crate should not be used in general Android code.
Bug: 303192701
Test: build both variants
Change-Id: I6126d328055a1a70934e43ab504a35dc8bef4577
diff --git a/Android.bp b/Android.bp
index 185840e..e892168 100644
--- a/Android.bp
+++ b/Android.bp
@@ -42,6 +42,37 @@
rustlibs: [
"libder",
],
+}
+
+rust_library_rlib {
+ name: "libspki_nostd",
+ crate_name: "spki",
+ cargo_env_compat: true,
+ cargo_pkg_version: "0.6.0",
+ srcs: ["src/lib.rs"],
+ edition: "2021",
+ features: ["alloc"],
+ rustlibs: [
+ "libder_nostd",
+ ],
+ apex_available: [
+ "//apex_available:platform",
+ "com.android.virt",
+ ],
+ prefer_rlib: true,
+ no_stdlibs: true,
+ stdlibs: [
+ "liballoc.rust_sysroot",
+ "libcompiler_builtins.rust_sysroot",
+ "libcore.rust_sysroot",
+ ],
product_available: true,
vendor_available: true,
+ visibility: [
+ "//external/rust/crates/pkcs1:__subpackages__",
+ "//external/rust/crates/pkcs8:__subpackages__",
+ "//external/rust/crates/x509-cert:__subpackages__",
+ "//system/keymint:__subpackages__",
+ ]
+ ,
}
diff --git a/cargo2android.json b/cargo2android.json
index e26e552..602fbb5 100644
--- a/cargo2android.json
+++ b/cargo2android.json
@@ -5,5 +5,19 @@
],
"run": true,
"vendor-available": true,
- "features": "alloc"
+ "features": "alloc",
+ "variants": [
+ {
+ },
+ {
+ "device": true,
+ "no-host": true,
+ "add-module-block": "cargo2android_viz.bp",
+ "dependency_suffix": "_nostd",
+ "force-rlib": true,
+ "suffix": "_nostd",
+ "alloc": true,
+ "no-std": true
+ }
+ ]
}
diff --git a/cargo2android_viz.bp b/cargo2android_viz.bp
new file mode 100644
index 0000000..f9ef72a
--- /dev/null
+++ b/cargo2android_viz.bp
@@ -0,0 +1,6 @@
+visibility: [
+ "//external/rust/crates/pkcs1:__subpackages__",
+ "//external/rust/crates/pkcs8:__subpackages__",
+ "//external/rust/crates/x509-cert:__subpackages__",
+ "//system/keymint:__subpackages__",
+]