Migrate to cargo_embargo.

Bug: 293289578
Test: Ran cargo_embargo, compared Android.bp
Change-Id: I7d08b12684a40bfee1c2fdd380c8f7d173578906
diff --git a/Android.bp b/Android.bp
index e937d69..c619d67 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 {
@@ -62,13 +62,17 @@
     ],
 }
 
-rust_defaults {
-    name: "flate2_test_defaults",
-    crate_name: "flate2",
+rust_test {
+    name: "flate2_test_tests_early-flush",
+    crate_name: "early_flush",
     cargo_env_compat: true,
     cargo_pkg_version: "1.0.25",
+    srcs: ["tests/early-flush.rs"],
     test_suites: ["general-tests"],
     auto_gen_config: true,
+    test_options: {
+        unit_test: true,
+    },
     edition: "2018",
     features: [
         "any_zlib",
@@ -85,30 +89,55 @@
 }
 
 rust_test {
-    name: "flate2_test_tests_early-flush",
-    defaults: ["flate2_test_defaults"],
-    srcs: ["tests/early-flush.rs"],
-    test_options: {
-        unit_test: true,
-    },
-}
-
-rust_test {
     name: "flate2_test_tests_empty-read",
-    defaults: ["flate2_test_defaults"],
+    crate_name: "empty_read",
+    cargo_env_compat: true,
+    cargo_pkg_version: "1.0.25",
     srcs: ["tests/empty-read.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
     test_options: {
         unit_test: true,
     },
+    edition: "2018",
+    features: [
+        "any_zlib",
+        "libz-sys",
+        "zlib",
+    ],
+    rustlibs: [
+        "libcrc32fast",
+        "libflate2",
+        "liblibz_sys",
+        "libquickcheck",
+        "librand",
+    ],
 }
 
 rust_test {
     name: "flate2_test_tests_gunzip",
-    defaults: ["flate2_test_defaults"],
+    crate_name: "gunzip",
+    cargo_env_compat: true,
+    cargo_pkg_version: "1.0.25",
     srcs: ["tests/gunzip.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
     test_options: {
         unit_test: true,
     },
+    edition: "2018",
+    features: [
+        "any_zlib",
+        "libz-sys",
+        "zlib",
+    ],
+    rustlibs: [
+        "libcrc32fast",
+        "libflate2",
+        "liblibz_sys",
+        "libquickcheck",
+        "librand",
+    ],
     data: [
         "tests/corrupt-gz-file.bin",
         "tests/good-file.gz",
@@ -120,11 +149,28 @@
 
 rust_test {
     name: "flate2_test_tests_zero-write",
-    defaults: ["flate2_test_defaults"],
+    crate_name: "zero_write",
+    cargo_env_compat: true,
+    cargo_pkg_version: "1.0.25",
     srcs: ["tests/zero-write.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
     test_options: {
         unit_test: true,
     },
+    edition: "2018",
+    features: [
+        "any_zlib",
+        "libz-sys",
+        "zlib",
+    ],
+    rustlibs: [
+        "libcrc32fast",
+        "libflate2",
+        "liblibz_sys",
+        "libquickcheck",
+        "librand",
+    ],
 }
 
 rust_library {
diff --git a/cargo2android.json b/cargo2android.json
deleted file mode 100644
index 11879eb..0000000
--- a/cargo2android.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-  "apex-available": [
-    "//apex_available:platform",
-    "com.android.virt"
-  ],
-  "device": true,
-  "features": "zlib",
-  "run": true,
-  "patch": "patches/Android.bp.patch",
-  "tests": true,
-  "test-data": [
-    "tests/gunzip.rs=tests/corrupt-gz-file.bin",
-    "tests/gunzip.rs=tests/good-file.gz",
-    "tests/gunzip.rs=tests/good-file.txt",
-    "tests/gunzip.rs=tests/multi.gz",
-    "tests/gunzip.rs=tests/multi.txt"
-  ]
-}
diff --git a/cargo_embargo.json b/cargo_embargo.json
new file mode 100644
index 0000000..9651dbe
--- /dev/null
+++ b/cargo_embargo.json
@@ -0,0 +1,25 @@
+{
+  "apex_available": [
+    "//apex_available:platform",
+    "com.android.virt"
+  ],
+  "features": [
+    "zlib"
+  ],
+  "package": {
+    "flate2": {
+      "patch": "patches/Android.bp.patch",
+      "test_data": {
+        "tests/gunzip.rs": [
+          "tests/corrupt-gz-file.bin",
+          "tests/good-file.gz",
+          "tests/good-file.txt",
+          "tests/multi.gz",
+          "tests/multi.txt"
+        ]
+      }
+    }
+  },
+  "run_cargo": false,
+  "tests": true
+}
diff --git a/patches/Android.bp.patch b/patches/Android.bp.patch
index 903ecfe..03e8060 100644
--- a/patches/Android.bp.patch
+++ b/patches/Android.bp.patch
@@ -1,44 +1,42 @@
-diff --git a/Android.bp b/Android.bp
-index 0d89ca8..d52dddd 100644
---- a/Android.bp
-+++ b/Android.bp
-@@ -39,7 +39,6 @@ license {
+--- Android.bp	2023-11-10 17:11:23.235848680 +0000
++++ Android.bp.new	2023-11-10 17:11:11.483678524 +0000
+@@ -39,7 +39,6 @@
  
  rust_test {
      name: "flate2_test_src_lib",
 -    host_supported: true,
      crate_name: "flate2",
      cargo_env_compat: true,
-     cargo_pkg_version: "1.0.24",
-@@ -88,7 +87,6 @@ rust_defaults {
+     cargo_pkg_version: "1.0.25",
+@@ -65,7 +64,6 @@
+ 
  rust_test {
      name: "flate2_test_tests_early-flush",
-     defaults: ["flate2_test_defaults"],
 -    host_supported: true,
-     srcs: ["tests/early-flush.rs"],
-     test_options: {
-         unit_test: true,
-@@ -98,7 +96,6 @@ rust_test {
+     crate_name: "early_flush",
+     cargo_env_compat: true,
+     cargo_pkg_version: "1.0.25",
+@@ -92,7 +90,6 @@
+ 
  rust_test {
      name: "flate2_test_tests_empty-read",
-     defaults: ["flate2_test_defaults"],
 -    host_supported: true,
-     srcs: ["tests/empty-read.rs"],
-     test_options: {
-         unit_test: true,
-@@ -108,7 +105,6 @@ rust_test {
+     crate_name: "empty_read",
+     cargo_env_compat: true,
+     cargo_pkg_version: "1.0.25",
+@@ -119,7 +116,6 @@
+ 
  rust_test {
      name: "flate2_test_tests_gunzip",
-     defaults: ["flate2_test_defaults"],
 -    host_supported: true,
-     srcs: ["tests/gunzip.rs"],
-     test_options: {
-         unit_test: true,
-@@ -125,7 +121,6 @@ rust_test {
+     crate_name: "gunzip",
+     cargo_env_compat: true,
+     cargo_pkg_version: "1.0.25",
+@@ -153,7 +149,6 @@
+ 
  rust_test {
      name: "flate2_test_tests_zero-write",
-     defaults: ["flate2_test_defaults"],
 -    host_supported: true,
-     srcs: ["tests/zero-write.rs"],
-     test_options: {
-         unit_test: true,
+     crate_name: "zero_write",
+     cargo_env_compat: true,
+     cargo_pkg_version: "1.0.25",