Adding '_nostd' variant for ring crate. am: 630e65a949

Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/ring/+/2797497

Change-Id: I58d4f8486c6871685a9f24b1d0bee36178f44e48
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/Android.bp b/Android.bp
index a2148cc..fe6f70f 100644
--- a/Android.bp
+++ b/Android.bp
@@ -69,6 +69,40 @@
     min_sdk_version: "29",
 }
 
+rust_library_rlib {
+    name: "libring_nostd",
+    // has rustc warnings
+    crate_name: "ring",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.17.0-alpha.11",
+    srcs: ["src/lib.rs"],
+    edition: "2018",
+    features: ["once_cell"],
+    rustlibs: [
+        "liblibc",
+        "libonce_cell",
+        "libspin_nostd",
+        "libuntrusted",
+    ],
+    whole_static_libs: [
+        "libring-core",
+        "libring-test",
+    ],
+    apex_available: [
+        "//apex_available:platform",
+        "com.android.resolv",
+    ],
+    prefer_rlib: true,
+    no_stdlibs: true,
+    stdlibs: [
+        "libcompiler_builtins.rust_sysroot",
+        "libcore.rust_sysroot",
+    ],
+    product_available: true,
+    vendor_available: true,
+    min_sdk_version: "29",
+}
+
 rust_test {
     name: "ring_test_src_lib",
     // has rustc warnings
diff --git a/cargo2android.json b/cargo2android.json
index ae417f7..e7b015e 100644
--- a/cargo2android.json
+++ b/cargo2android.json
@@ -14,5 +14,17 @@
   "whole-static-libs": [
     "ring-core",
     "ring-test"
+  ],
+  "variants": [
+    {},
+    {
+      "no-host": true,
+      "suffix": "_nostd",
+      "no-std": true,
+      "alloc": false,
+      "force-rlib": true,
+      "features": "once_cell",
+      "tests": false
+    }
   ]
 }
diff --git a/patches/Android.bp.patch b/patches/Android.bp.patch
index 5bbfbe8..9e02f93 100644
--- a/patches/Android.bp.patch
+++ b/patches/Android.bp.patch
@@ -1,5 +1,5 @@
 diff --git a/Android.bp b/Android.bp
-index 2fffd32fb..eb06e7878 100644
+index 9690d3d..9c28b81 100644
 --- a/Android.bp
 +++ b/Android.bp
 @@ -56,9 +56,9 @@ rust_library {
@@ -15,7 +15,24 @@
      ],
      apex_available: [
          "//apex_available:platform",
-@@ -94,9 +94,9 @@ rust_test {
+@@ -82,12 +80,12 @@ rust_library_rlib {
+     rustlibs: [
+         "liblibc",
+         "libonce_cell",
+-        "libspin",
++        "libspin_nostd",
+         "libuntrusted",
+     ],
+-    static_libs: [
+-        "libring_core_0_17_0_alpha_11_",
+-        "libring_core_0_17_0_alpha_11_test",
++    whole_static_libs: [
++        "libring-core",
++        "libring-test",
+     ],
+     apex_available: [
+         "//apex_available:platform",
+@@ -131,9 +129,9 @@ rust_test {
          "libspin",
          "libuntrusted",
      ],
@@ -27,4 +44,3 @@
 +        "libring-test",
      ],
  }
-