Merge "Migrate to cargo_embargo." into main am: 4f7172de65 am: 5ca6575857

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

Change-Id: Ib04f0d1566c8e3a0a46df6bfd58e667b45437897
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/Android.bp b/Android.bp
index e187a57..f1ae06f 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,4 +1,4 @@
-// This file is generated by cargo2android.py --config cargo2android.json.
+// This file is generated by cargo_embargo.
 // Do not modify this file as changes will be overridden on upgrade.
 
 package {
@@ -36,7 +36,6 @@
 
 rust_library {
     name: "libring",
-    // has rustc warnings
     host_supported: true,
     crate_name: "ring",
     cargo_env_compat: true,
@@ -70,9 +69,431 @@
     cfgs: ["soong"],
 }
 
+rust_test {
+    name: "ring_test_src_lib",
+    host_supported: true,
+    crate_name: "ring",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.17.0-alpha.11",
+    srcs: ["src/lib.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    test_options: {
+        unit_test: true,
+    },
+    edition: "2018",
+    features: [
+        "alloc",
+        "default",
+        "dev_urandom_fallback",
+        "once_cell",
+        "std",
+    ],
+    rustlibs: [
+        "liblibc",
+        "libonce_cell",
+        "libspin",
+        "libuntrusted",
+    ],
+    whole_static_libs: [
+        "libring-core",
+        "libring-test",
+    ],
+    cfgs: ["soong"],
+}
+
+rust_test {
+    name: "ring_test_tests_aead_tests",
+    host_supported: true,
+    crate_name: "aead_tests",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.17.0-alpha.11",
+    srcs: ["tests/aead_tests.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    test_options: {
+        unit_test: true,
+    },
+    edition: "2018",
+    features: [
+        "alloc",
+        "default",
+        "dev_urandom_fallback",
+        "once_cell",
+        "std",
+    ],
+    rustlibs: [
+        "liblibc",
+        "libonce_cell",
+        "libring",
+        "libspin",
+        "libuntrusted",
+    ],
+    cfgs: ["soong"],
+}
+
+rust_test {
+    name: "ring_test_tests_agreement_tests",
+    host_supported: true,
+    crate_name: "agreement_tests",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.17.0-alpha.11",
+    srcs: ["tests/agreement_tests.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    test_options: {
+        unit_test: true,
+    },
+    edition: "2018",
+    features: [
+        "alloc",
+        "default",
+        "dev_urandom_fallback",
+        "once_cell",
+        "std",
+    ],
+    rustlibs: [
+        "liblibc",
+        "libonce_cell",
+        "libring",
+        "libspin",
+        "libuntrusted",
+    ],
+    cfgs: ["soong"],
+}
+
+rust_test {
+    name: "ring_test_tests_constant_time_tests",
+    host_supported: true,
+    crate_name: "constant_time_tests",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.17.0-alpha.11",
+    srcs: ["tests/constant_time_tests.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    test_options: {
+        unit_test: true,
+    },
+    edition: "2018",
+    features: [
+        "alloc",
+        "default",
+        "dev_urandom_fallback",
+        "once_cell",
+        "std",
+    ],
+    rustlibs: [
+        "liblibc",
+        "libonce_cell",
+        "libring",
+        "libspin",
+        "libuntrusted",
+    ],
+    cfgs: ["soong"],
+}
+
+rust_test {
+    name: "ring_test_tests_digest_tests",
+    host_supported: true,
+    crate_name: "digest_tests",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.17.0-alpha.11",
+    srcs: ["tests/digest_tests.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    test_options: {
+        unit_test: true,
+    },
+    edition: "2018",
+    features: [
+        "alloc",
+        "default",
+        "dev_urandom_fallback",
+        "once_cell",
+        "std",
+    ],
+    rustlibs: [
+        "liblibc",
+        "libonce_cell",
+        "libring",
+        "libspin",
+        "libuntrusted",
+    ],
+    cfgs: ["soong"],
+}
+
+rust_test {
+    name: "ring_test_tests_ecdsa_tests",
+    host_supported: true,
+    crate_name: "ecdsa_tests",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.17.0-alpha.11",
+    srcs: ["tests/ecdsa_tests.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    test_options: {
+        unit_test: true,
+    },
+    edition: "2018",
+    features: [
+        "alloc",
+        "default",
+        "dev_urandom_fallback",
+        "once_cell",
+        "std",
+    ],
+    rustlibs: [
+        "liblibc",
+        "libonce_cell",
+        "libring",
+        "libspin",
+        "libuntrusted",
+    ],
+    cfgs: ["soong"],
+}
+
+rust_test {
+    name: "ring_test_tests_ed25519_tests",
+    host_supported: true,
+    crate_name: "ed25519_tests",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.17.0-alpha.11",
+    srcs: ["tests/ed25519_tests.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    test_options: {
+        unit_test: true,
+    },
+    edition: "2018",
+    features: [
+        "alloc",
+        "default",
+        "dev_urandom_fallback",
+        "once_cell",
+        "std",
+    ],
+    rustlibs: [
+        "liblibc",
+        "libonce_cell",
+        "libring",
+        "libspin",
+        "libuntrusted",
+    ],
+    cfgs: ["soong"],
+}
+
+rust_test {
+    name: "ring_test_tests_hkdf_tests",
+    host_supported: true,
+    crate_name: "hkdf_tests",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.17.0-alpha.11",
+    srcs: ["tests/hkdf_tests.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    test_options: {
+        unit_test: true,
+    },
+    edition: "2018",
+    features: [
+        "alloc",
+        "default",
+        "dev_urandom_fallback",
+        "once_cell",
+        "std",
+    ],
+    rustlibs: [
+        "liblibc",
+        "libonce_cell",
+        "libring",
+        "libspin",
+        "libuntrusted",
+    ],
+    cfgs: ["soong"],
+}
+
+rust_test {
+    name: "ring_test_tests_hmac_tests",
+    host_supported: true,
+    crate_name: "hmac_tests",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.17.0-alpha.11",
+    srcs: ["tests/hmac_tests.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    test_options: {
+        unit_test: true,
+    },
+    edition: "2018",
+    features: [
+        "alloc",
+        "default",
+        "dev_urandom_fallback",
+        "once_cell",
+        "std",
+    ],
+    rustlibs: [
+        "liblibc",
+        "libonce_cell",
+        "libring",
+        "libspin",
+        "libuntrusted",
+    ],
+    cfgs: ["soong"],
+}
+
+rust_test {
+    name: "ring_test_tests_pbkdf2_tests",
+    host_supported: true,
+    crate_name: "pbkdf2_tests",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.17.0-alpha.11",
+    srcs: ["tests/pbkdf2_tests.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    test_options: {
+        unit_test: true,
+    },
+    edition: "2018",
+    features: [
+        "alloc",
+        "default",
+        "dev_urandom_fallback",
+        "once_cell",
+        "std",
+    ],
+    rustlibs: [
+        "liblibc",
+        "libonce_cell",
+        "libring",
+        "libspin",
+        "libuntrusted",
+    ],
+    cfgs: ["soong"],
+}
+
+rust_test {
+    name: "ring_test_tests_quic_tests",
+    host_supported: true,
+    crate_name: "quic_tests",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.17.0-alpha.11",
+    srcs: ["tests/quic_tests.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    test_options: {
+        unit_test: true,
+    },
+    edition: "2018",
+    features: [
+        "alloc",
+        "default",
+        "dev_urandom_fallback",
+        "once_cell",
+        "std",
+    ],
+    rustlibs: [
+        "liblibc",
+        "libonce_cell",
+        "libring",
+        "libspin",
+        "libuntrusted",
+    ],
+    cfgs: ["soong"],
+}
+
+rust_test {
+    name: "ring_test_tests_rand_tests",
+    host_supported: true,
+    crate_name: "rand_tests",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.17.0-alpha.11",
+    srcs: ["tests/rand_tests.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    test_options: {
+        unit_test: true,
+    },
+    edition: "2018",
+    features: [
+        "alloc",
+        "default",
+        "dev_urandom_fallback",
+        "once_cell",
+        "std",
+    ],
+    rustlibs: [
+        "liblibc",
+        "libonce_cell",
+        "libring",
+        "libspin",
+        "libuntrusted",
+    ],
+    cfgs: ["soong"],
+}
+
+rust_test {
+    name: "ring_test_tests_rsa_tests",
+    host_supported: true,
+    crate_name: "rsa_tests",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.17.0-alpha.11",
+    srcs: ["tests/rsa_tests.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    test_options: {
+        unit_test: true,
+    },
+    edition: "2018",
+    features: [
+        "alloc",
+        "default",
+        "dev_urandom_fallback",
+        "once_cell",
+        "std",
+    ],
+    rustlibs: [
+        "liblibc",
+        "libonce_cell",
+        "libring",
+        "libspin",
+        "libuntrusted",
+    ],
+    cfgs: ["soong"],
+}
+
+rust_test {
+    name: "ring_test_tests_signature_tests",
+    host_supported: true,
+    crate_name: "signature_tests",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.17.0-alpha.11",
+    srcs: ["tests/signature_tests.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    test_options: {
+        unit_test: true,
+    },
+    edition: "2018",
+    features: [
+        "alloc",
+        "default",
+        "dev_urandom_fallback",
+        "once_cell",
+        "std",
+    ],
+    rustlibs: [
+        "liblibc",
+        "libonce_cell",
+        "libring",
+        "libspin",
+        "libuntrusted",
+    ],
+    cfgs: ["soong"],
+}
+
 rust_library_rlib {
     name: "libring_nostd",
-    // has rustc warnings
     crate_name: "ring",
     cargo_env_compat: true,
     cargo_pkg_version: "0.17.0-alpha.11",
@@ -105,220 +526,6 @@
     cfgs: ["soong"],
 }
 
-rust_test {
-    name: "ring_test_src_lib",
-    // has rustc warnings
-    host_supported: true,
-    crate_name: "ring",
-    cargo_env_compat: true,
-    cargo_pkg_version: "0.17.0-alpha.11",
-    srcs: ["src/lib.rs"],
-    test_suites: ["general-tests"],
-    auto_gen_config: true,
-    test_options: {
-        unit_test: true,
-    },
-    edition: "2018",
-    features: [
-        "alloc",
-        "default",
-        "dev_urandom_fallback",
-        "once_cell",
-        "std",
-    ],
-    rustlibs: [
-        "liblibc",
-        "libonce_cell",
-        "libspin",
-        "libuntrusted",
-    ],
-    whole_static_libs: [
-        "libring-core",
-        "libring-test",
-    ],
-    cfgs: ["soong"],
-}
-
-rust_defaults {
-    name: "ring_test_defaults",
-    crate_name: "ring",
-    cargo_env_compat: true,
-    cargo_pkg_version: "0.17.0-alpha.11",
-    test_suites: ["general-tests"],
-    auto_gen_config: true,
-    edition: "2018",
-    features: [
-        "alloc",
-        "default",
-        "dev_urandom_fallback",
-        "once_cell",
-        "std",
-    ],
-    rustlibs: [
-        "liblibc",
-        "libonce_cell",
-        "libring",
-        "libspin",
-        "libuntrusted",
-    ],
-}
-
-rust_test {
-    name: "ring_test_tests_aead_tests",
-    defaults: ["ring_test_defaults"],
-    // has rustc warnings
-    host_supported: true,
-    srcs: ["tests/aead_tests.rs"],
-    test_options: {
-        unit_test: true,
-    },
-    cfgs: ["soong"],
-}
-
-rust_test {
-    name: "ring_test_tests_agreement_tests",
-    defaults: ["ring_test_defaults"],
-    // has rustc warnings
-    host_supported: true,
-    srcs: ["tests/agreement_tests.rs"],
-    test_options: {
-        unit_test: true,
-    },
-    cfgs: ["soong"],
-}
-
-rust_test {
-    name: "ring_test_tests_constant_time_tests",
-    defaults: ["ring_test_defaults"],
-    // has rustc warnings
-    host_supported: true,
-    srcs: ["tests/constant_time_tests.rs"],
-    test_options: {
-        unit_test: true,
-    },
-    cfgs: ["soong"],
-}
-
-rust_test {
-    name: "ring_test_tests_digest_tests",
-    defaults: ["ring_test_defaults"],
-    // has rustc warnings
-    host_supported: true,
-    srcs: ["tests/digest_tests.rs"],
-    test_options: {
-        unit_test: true,
-    },
-    cfgs: ["soong"],
-}
-
-rust_test {
-    name: "ring_test_tests_ecdsa_tests",
-    defaults: ["ring_test_defaults"],
-    // has rustc warnings
-    host_supported: true,
-    srcs: ["tests/ecdsa_tests.rs"],
-    test_options: {
-        unit_test: true,
-    },
-    cfgs: ["soong"],
-}
-
-rust_test {
-    name: "ring_test_tests_ed25519_tests",
-    defaults: ["ring_test_defaults"],
-    // has rustc warnings
-    host_supported: true,
-    srcs: ["tests/ed25519_tests.rs"],
-    test_options: {
-        unit_test: true,
-    },
-    cfgs: ["soong"],
-}
-
-rust_test {
-    name: "ring_test_tests_hkdf_tests",
-    defaults: ["ring_test_defaults"],
-    // has rustc warnings
-    host_supported: true,
-    srcs: ["tests/hkdf_tests.rs"],
-    test_options: {
-        unit_test: true,
-    },
-    cfgs: ["soong"],
-}
-
-rust_test {
-    name: "ring_test_tests_hmac_tests",
-    defaults: ["ring_test_defaults"],
-    // has rustc warnings
-    host_supported: true,
-    srcs: ["tests/hmac_tests.rs"],
-    test_options: {
-        unit_test: true,
-    },
-    cfgs: ["soong"],
-}
-
-rust_test {
-    name: "ring_test_tests_pbkdf2_tests",
-    defaults: ["ring_test_defaults"],
-    // has rustc warnings
-    host_supported: true,
-    srcs: ["tests/pbkdf2_tests.rs"],
-    test_options: {
-        unit_test: true,
-    },
-    cfgs: ["soong"],
-}
-
-rust_test {
-    name: "ring_test_tests_quic_tests",
-    defaults: ["ring_test_defaults"],
-    // has rustc warnings
-    host_supported: true,
-    srcs: ["tests/quic_tests.rs"],
-    test_options: {
-        unit_test: true,
-    },
-    cfgs: ["soong"],
-}
-
-rust_test {
-    name: "ring_test_tests_rand_tests",
-    defaults: ["ring_test_defaults"],
-    // has rustc warnings
-    host_supported: true,
-    srcs: ["tests/rand_tests.rs"],
-    test_options: {
-        unit_test: true,
-    },
-    cfgs: ["soong"],
-}
-
-rust_test {
-    name: "ring_test_tests_rsa_tests",
-    defaults: ["ring_test_defaults"],
-    // has rustc warnings
-    host_supported: true,
-    srcs: ["tests/rsa_tests.rs"],
-    test_options: {
-        unit_test: true,
-    },
-    cfgs: ["soong"],
-}
-
-rust_test {
-    name: "ring_test_tests_signature_tests",
-    defaults: ["ring_test_defaults"],
-    // has rustc warnings
-    host_supported: true,
-    srcs: ["tests/signature_tests.rs"],
-    test_options: {
-        unit_test: true,
-    },
-    cfgs: ["soong"],
-}
-
 cc_library_static {
     name: "libring-core",
     host_supported: true,
diff --git a/cargo2android.json b/cargo2android.json
deleted file mode 100644
index 2abef64..0000000
--- a/cargo2android.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
-  "add-toplevel-block": "cargo2android_cc.bp",
-  "add-module-block": "cfg_soong.bp",
-  "apex-available": [
-    "//apex_available:platform",
-    "com.android.resolv"
-  ],
-  "dependencies": true,
-  "device": true,
-  "features": "alloc,default,dev_urandom_fallback,once_cell,std",
-  "min-sdk-version": "29",
-  "patch": "patches/Android.bp.patch",
-  "run": true,
-  "tests": true,
-  "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/cargo_embargo.json b/cargo_embargo.json
new file mode 100644
index 0000000..39fd8d0
--- /dev/null
+++ b/cargo_embargo.json
@@ -0,0 +1,51 @@
+{
+  "apex_available": [
+    "//apex_available:platform",
+    "com.android.resolv"
+  ],
+  "min_sdk_version": "29",
+  "package": {
+    "ring": {
+      "add_module_block": "cfg_soong.bp",
+      "add_toplevel_block": "cargo2android_cc.bp",
+      "whole_static_libs": [
+        "libring-core",
+        "libring-test"
+      ]
+    }
+  },
+  "variants": [
+    {
+      "features": [
+        "alloc",
+        "default",
+        "dev_urandom_fallback",
+        "once_cell",
+        "std"
+      ],
+      "module_name_overrides": {
+        "libring_core_0_17_0_alpha_11_": "libring-core",
+        "libring_core_0_17_0_alpha_11_test": "libring-test"
+      },
+      "tests": true
+    },
+    {
+      "features": [
+        "once_cell"
+      ],
+      "module_name_overrides": {
+        "libring_core_0_17_0_alpha_11_": "libring-core",
+        "libring_core_0_17_0_alpha_11_test": "libring-test",
+        "libring": "libring_nostd",
+        "libspin": "libspin_nostd"
+      },
+      "package": {
+        "ring": {
+          "force_rlib": true,
+          "host_supported": false,
+          "no_std": true
+        }
+      }
+    }
+  ]
+}
diff --git a/patches/Android.bp.patch b/patches/Android.bp.patch
deleted file mode 100644
index 9e02f93..0000000
--- a/patches/Android.bp.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-diff --git a/Android.bp b/Android.bp
-index 9690d3d..9c28b81 100644
---- a/Android.bp
-+++ b/Android.bp
-@@ -56,9 +56,9 @@ rust_library {
-         "libspin",
-         "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",
-@@ -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",
-     ],
--    static_libs: [
--        "libring_core_0_17_0_alpha_11_",
--        "libring_core_0_17_0_alpha_11_test",
-+    whole_static_libs: [
-+        "libring-core",
-+        "libring-test",
-     ],
- }