Snap for 11135399 from 285b521de555997b53b054674708de2760377477 to simpleperf-release

Change-Id: I1d4644b48634fd72281c7b1923759f2dd0d7547c
diff --git a/.cargo/config.toml b/.cargo/config.toml
index e2b197d..278afcd 100644
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -1,2 +1,2 @@
 [patch.crates-io]
-bssl-ffi = { package = "bssl-sys", version = "0.1.0", path = "../../../boringssl/build/rust", optional=true }
+bssl-ffi = { package = "bssl-sys", version = "0.1.0", path = "../../../boringssl/src/rust/bssl-sys", optional=true }
diff --git a/Android.bp b/Android.bp
index 7d2407d..c650f2e 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.
 
 // WARNING! This crate has a change in dependency structure that is not yet
@@ -45,18 +45,22 @@
     ],
 }
 
-rust_defaults {
-    name: "libopenssl_defaults",
+rust_library {
+    name: "libopenssl",
     host_supported: true,
     crate_name: "openssl",
     cargo_env_compat: true,
-    cargo_pkg_version: "0.10.43",
+    cargo_pkg_version: "0.10.45",
     srcs: ["src/lib.rs"],
     edition: "2018",
     features: ["unstable_boringssl"],
-    cfgs: ["boringssl", "soong"],
+    cfgs: [
+        "boringssl",
+        "soong",
+    ],
     rustlibs: [
         "libbitflags-1.3.2",
+        "libbssl_ffi",
         "libcfg_if",
         "libforeign_types",
         "liblibc",
@@ -67,18 +71,31 @@
         "//apex_available:platform",
         "com.android.virt",
     ],
-    vendor_available: true,
     product_available: true,
-}
-
-rust_library {
-    name: "libopenssl",
-    defaults: ["libopenssl_defaults"],
-    rustlibs: ["libbssl_ffi"],
+    vendor_available: true,
 }
 
 rust_library_host_rlib {
     name: "libopenssl_static",
-    defaults: ["libopenssl_defaults"],
-    rlibs: ["libbssl_ffi_static"],
+    crate_name: "openssl",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.10.45",
+    srcs: ["src/lib.rs"],
+    edition: "2018",
+    features: ["unstable_boringssl"],
+    cfgs: [
+        "boringssl",
+        "soong",
+    ],
+    rustlibs: [
+        "libbitflags-1.3.2",
+        "libcfg_if",
+        "libforeign_types",
+        "liblibc",
+        "libonce_cell",
+    ],
+    rlibs: [
+        "libbssl_ffi_static",
+    ],
+    proc_macros: ["libopenssl_macros"],
 }
diff --git a/README.android b/README.android
index 1957c30..d4f6465 100644
--- a/README.android
+++ b/README.android
@@ -1,34 +1,7 @@
 ## Steps for updating this crate
 
-1.  In order to run cargo2android, for this crate, the BoringSSL rust bindings first needs to be
-    built. Copy `googletest` to `boringssl`, which is needed to build the rust bindings
-
-    ```
-    $ cp -r external/googletest/googletest external/boringssl/src/third_party/
-    ```
-2.  Build the rust bindings (More information at
-    https://boringssl.googlesource.com/boringssl/+/HEAD/BUILDING.md)
-
-    ```
-    $ cd external/boringssl
-    $ mkdir build && cd build
-    $ cmake .. -DRUST_BINDINGS=x86_64-unknown-linux-gnu
-    $ make
-    ```
-3.  Run `tools/external_updater/updater.sh update rust/crates/openssl`. Cargo errors causing the
-    command to fail are expected (since the boringSSL crate is outside of the `openssl` directory,
-    redshell is not able to access it).
-4.  The repository should now be in a `tmp_auto_upgrade` branch, and the Android.bp will contain
-    some error message.
-5.  Run cargo2android
-
-    ```
-    $ cargo2android.py --config ./cargo2android.json
-    ```
-6.  Clean up the changes in external/boringssl repository, and double check that the resulting
-    Android.bp builds correctly by running `m libopenssl`.
-7.  Commit the changes and upload the CL.
-8.  `external/rust/crates/openssl-macros` should also be updated at the same time.
+1.  Run `tools/external_updater/updater.sh update rust/crates/openssl`.
+2.  `external/rust/crates/openssl-macros` should also be updated at the same time.
 
 ## Generating patch files
 
diff --git a/cargo2android.json b/cargo2android.json
deleted file mode 100644
index 4caae30..0000000
--- a/cargo2android.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
-  "apex-available": [
-    "//apex_available:platform",
-    "com.android.virt"
-  ],
-  "device": true,
-  "features": "unstable_boringssl",
-  "run": true,
-  "vendor-available": true,
-  "patch": "patches/Android.bp.diff"
-}
diff --git a/cargo_embargo.json b/cargo_embargo.json
new file mode 100644
index 0000000..16df1d0
--- /dev/null
+++ b/cargo_embargo.json
@@ -0,0 +1,36 @@
+{
+  "apex_available": [
+    "//apex_available:platform",
+    "com.android.virt"
+  ],
+  "extra_cfg": ["boringssl", "soong"],
+  "features": [
+    "unstable_boringssl"
+  ],
+  "package": {
+    "openssl": {
+      "patch": "patches/Android.bp.diff"
+    }
+  },
+  "run_cargo": false,
+  "variants": [
+    {
+      "module_name_overrides": {
+        "libbitflags": "libbitflags-1.3.2",
+        "libopenssl_sys": "libbssl_ffi"
+      }
+    },
+    {
+      "module_name_overrides": {
+        "libbitflags": "libbitflags-1.3.2",
+        "libopenssl": "libopenssl_static"
+      },
+      "package": {
+        "openssl": {
+          "device_supported": false,
+          "force_rlib": true
+        }
+      }
+    }
+  ]
+}
diff --git a/patches/0001-cfgs.diff b/patches/0001-cfgs.diff
index f118c41..ae6ba11 100644
--- a/patches/0001-cfgs.diff
+++ b/patches/0001-cfgs.diff
@@ -5,7 +5,7 @@
 +++ b/.cargo/config.toml
 @@ -0,0 +1,2 @@
 +[patch.crates-io]
-+bssl-ffi = { package = "bssl-sys", version = "0.1.0", path = "../../../boringssl/build/rust", optional=true }
++bssl-ffi = { package = "bssl-sys", version = "0.1.0", path = "../../../boringssl/src/rust/bssl-sys", optional=true }
 diff --git a/src/cipher.rs b/src/cipher.rs
 index ab5f49d..84a8265 100644
 --- a/src/cipher.rs
diff --git a/patches/Android.bp.diff b/patches/Android.bp.diff
index ef0ab4f..b9f0654 100644
--- a/patches/Android.bp.diff
+++ b/patches/Android.bp.diff
@@ -1,19 +1,15 @@
 diff --git a/Android.bp b/Android.bp
-index 6628b2a..0ece701 100644
+index 1e027e2..c650f2e 100644
 --- a/Android.bp
 +++ b/Android.bp
-@@ -54,11 +54,11 @@ rust_library {
-     srcs: ["src/lib.rs"],
-     edition: "2018",
-     features: ["unstable_boringssl"],
--    cfgs: ["boringssl"],
-+    cfgs: ["boringssl", "soong"],
-     rustlibs: [
--        "libbitflags",
-+        "libbitflags-1.3.2",
-         "libcfg_if",
--        "libopenssl_sys",
-+        "libbssl_ffi",
+@@ -93,7 +93,9 @@ rust_library_host_rlib {
          "libforeign_types",
          "liblibc",
          "libonce_cell",
+-        "libopenssl_sys",
++    ],
++    rlibs: [
++        "libbssl_ffi_static",
+     ],
+     proc_macros: ["libopenssl_macros"],
+ }