Allow structopt crate in com.android.virt apex

Also add TEST_MAPPING generated by the script.

Bug: 182570135
Test: m
Change-Id: I924ca0bce2bd134e25183a0b91ba667f4da0eefb
diff --git a/Android.bp b/Android.bp
index 89661d4..19a4071 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,40 +1,5 @@
-// This file is generated by cargo2android.py --run --device --dependencies.
-
-package {
-    default_applicable_licenses: ["external_rust_crates_structopt_license"],
-}
-
-// Added automatically by a large-scale-change that took the approach of
-// 'apply every license found to every target'. While this makes sure we respect
-// every license restriction, it may not be entirely correct.
-//
-// e.g. GPL in an MIT project might only apply to the contrib/ directory.
-//
-// Please consider splitting the single license below into multiple licenses,
-// taking care not to lose any license_kind information, and overriding the
-// default license using the 'licenses: [...]' property on targets as needed.
-//
-// For unused files, consider creating a 'fileGroup' with "//visibility:private"
-// to attach the license to, and including a comment whether the files may be
-// used in the current project.
-//
-// large-scale-change included anything that looked like it might be a license
-// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
-//
-// Please consider removing redundant or irrelevant files from 'license_text:'.
-// See: http://go/android-license-faq
-license {
-    name: "external_rust_crates_structopt_license",
-    visibility: [":__subpackages__"],
-    license_kinds: [
-        "SPDX-license-identifier-Apache-2.0",
-        "SPDX-license-identifier-MIT",
-    ],
-    license_text: [
-        "LICENSE-APACHE",
-        "LICENSE-MIT",
-    ],
-}
+// This file is generated by cargo2android.py --run --device --dependencies --patch=patches/Android.bp.patch.
+// Do not modify this file as changes will be overridden on upgrade.
 
 rust_library {
     name: "libstructopt",
@@ -48,6 +13,10 @@
         "liblazy_static",
     ],
     proc_macros: ["libstructopt_derive"],
+    apex_available: [
+        "//apex_available:platform",
+        "com.android.virt",
+    ],
 }
 
 // dependent_library ["feature_list"]
@@ -55,16 +24,16 @@
 //   atty-0.2.14
 //   bitflags-1.2.1 "default"
 //   clap-2.33.3 "ansi_term,atty,color,default,strsim,suggestions,vec_map"
-//   heck-0.3.1
+//   heck-0.3.2
 //   lazy_static-1.4.0
-//   libc-0.2.80
+//   libc-0.2.88
 //   proc-macro-error-1.0.4 "default,syn,syn-error"
 //   proc-macro-error-attr-1.0.4
 //   proc-macro2-1.0.24 "default,proc-macro"
-//   quote-1.0.7 "default,proc-macro"
+//   quote-1.0.9 "default,proc-macro"
 //   strsim-0.8.0
 //   structopt-derive-0.4.14
-//   syn-1.0.53 "clone-impls,default,derive,full,parsing,printing,proc-macro,quote,visit"
+//   syn-1.0.63 "clone-impls,default,derive,full,parsing,printing,proc-macro,quote"
 //   textwrap-0.11.0
 //   unicode-segmentation-1.7.1
 //   unicode-width-0.1.8 "default"
diff --git a/TEST_MAPPING b/TEST_MAPPING
new file mode 100644
index 0000000..0f4f93c
--- /dev/null
+++ b/TEST_MAPPING
@@ -0,0 +1,8 @@
+// Generated by update_crate_tests.py for tests that depend on this crate.
+{
+  "presubmit": [
+    {
+      "name": "authfs_device_test_src_lib"
+    }
+  ]
+}
diff --git a/patches/Android.bp.patch b/patches/Android.bp.patch
new file mode 100644
index 0000000..979197c
--- /dev/null
+++ b/patches/Android.bp.patch
@@ -0,0 +1,15 @@
+diff --git a/Android.bp b/Android.bp
+index 2695275..01ae097 100644
+--- a/Android.bp
++++ b/Android.bp
+@@ -13,6 +13,10 @@ rust_library {
+         "liblazy_static",
+     ],
+     proc_macros: ["libstructopt_derive"],
++    apex_available: [
++        "//apex_available:platform",
++        "com.android.virt",
++    ],
+ }
+ 
+ // dependent_library ["feature_list"]