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: I158dab8eda7562ba634c2a9f72dfbe490609ae50
diff --git a/Android.bp b/Android.bp
index 15791de..7a44be6 100644
--- a/Android.bp
+++ b/Android.bp
@@ -49,6 +49,40 @@
         "libspki",
         "libzeroize",
     ],
+}
+
+rust_library_rlib {
+    name: "libpkcs1_nostd",
+    crate_name: "pkcs1",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.4.1",
+    srcs: ["src/lib.rs"],
+    edition: "2021",
+    features: [
+        "alloc",
+        "pkcs8",
+        "zeroize",
+    ],
+    rustlibs: [
+        "libder_nostd",
+        "libpkcs8_nostd",
+        "libspki_nostd",
+        "libzeroize_nostd",
+    ],
+    apex_available: [
+        "//apex_available:platform",
+        "com.android.virt",
+    ],
+    prefer_rlib: true,
+    no_stdlibs: true,
+    stdlibs: [
+        "libcompiler_builtins.rust_sysroot",
+        "libcore.rust_sysroot",
+    ],
     product_available: true,
     vendor_available: true,
+    visibility: [
+         "//system/keymint:__subpackages__",
+    ]
+    ,
 }
diff --git a/cargo2android.json b/cargo2android.json
index e26e552..e6baa85 100644
--- a/cargo2android.json
+++ b/cargo2android.json
@@ -5,5 +5,18 @@
   ],
   "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",
+      "no-std": true
+    }
+  ]
 }
diff --git a/cargo2android_viz.bp b/cargo2android_viz.bp
new file mode 100644
index 0000000..6912520
--- /dev/null
+++ b/cargo2android_viz.bp
@@ -0,0 +1,3 @@
+visibility: [
+     "//system/keymint:__subpackages__",
+]