Update cxx to latest master

* Update build to match upstream's use of edition 2021

Test: mmm
Change-Id: Iad58f8bb416050de4fb3f3087c051d680a2180e7
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..764a8c0
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,98 @@
+package {
+    default_applicable_licenses: ["external_rust_cxx_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_cxx_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-Apache-2.0",
+        "SPDX-license-identifier-MIT",
+    ],
+    license_text: [
+        "LICENSE-APACHE",
+        "LICENSE-MIT",
+    ],
+}
+
+rust_library {
+    name: "libcxx",
+    crate_name: "cxx",
+    srcs: ["src/lib.rs"],
+    edition: "2021",
+    features: [
+        "alloc",
+        "std",
+    ],
+    rustlibs: [
+        "libanyhow",
+        "libthiserror",
+    ],
+    proc_macros: [
+        "libcxxbridge_macro",
+    ],
+    whole_static_libs: [
+        "libcxxbridge05",
+    ],
+    shared_libs: ["libc++"],
+    host_supported: true,
+    vendor_available: true,
+    product_available: true,
+    apex_available: [
+        "//apex_available:anyapex",
+        "//apex_available:platform",
+    ],
+    min_sdk_version: "29",
+}
+
+cc_library_static {
+    name: "libcxxbridge05",
+    defaults: ["rust_static_cc_lib_defaults"],
+    cflags: ["-DRUST_CXX_NO_EXCEPTIONS"],
+    srcs: ["src/cxx.cc"],
+    host_supported: true,
+    vendor_available: true,
+    product_available: true,
+    apex_available: [
+        "//apex_available:anyapex",
+        "//apex_available:platform",
+    ],
+    min_sdk_version: "29",
+}
+
+cc_library_static {
+    host_supported: true,
+    name: "libcxx-demo-blobstore",
+    srcs: ["demo/src/blobstore.cc"],
+    generated_headers: [
+        "cxx-demo-bridge-header",
+        "cxx-bridge-header",
+    ],
+    generated_sources: ["cxx-demo-bridge-code"],
+}
+
+genrule {
+    name: "cxx-bridge-header",
+    tools: ["cxxbridge"],
+    cmd: "$(location cxxbridge) --header > $(out)",
+    out: ["rust/cxx.h"],
+}
diff --git a/METADATA b/METADATA
new file mode 100644
index 0000000..85611d6
--- /dev/null
+++ b/METADATA
@@ -0,0 +1,19 @@
+name: "cxx"
+description: "Safe interop between Rust and C++"
+third_party {
+  url {
+    type: HOMEPAGE
+    value: "https://github.com/dtolnay/cxx"
+  }
+  url {
+    type: GIT
+    value: "https://github.com/dtolnay/cxx.git"
+  }
+  version: "36d9ac1fab726e14305ce1919ebf8a3d64949d30"
+  license_type: NOTICE
+  last_upgrade_date {
+    year: 2021
+    month: 9
+    day: 23
+  }
+}
diff --git a/OWNERS b/OWNERS
new file mode 100644
index 0000000..46fc303
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1 @@
+include platform/prebuilts/rust:/OWNERS
diff --git a/cargo_embargo.json b/cargo_embargo.json
new file mode 100644
index 0000000..ce4c2df
--- /dev/null
+++ b/cargo_embargo.json
@@ -0,0 +1,8 @@
+{
+  "module_blocklist": ["demo", "libcxx", "libcxx_build", "libcxx_test_suite", "libcxxbridge_flags"],
+  "package": {
+    "cxxbridge-cmd": { "device_supported": false, "host_first_multilib": true },
+    "cxx-gen": {"device_supported": false, "host_first_multilib": true}
+  },
+  "run_cargo": false
+}
diff --git a/demo/Android.bp b/demo/Android.bp
new file mode 100644
index 0000000..961c43c
--- /dev/null
+++ b/demo/Android.bp
@@ -0,0 +1,32 @@
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "external_rust_cxx_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    //   SPDX-license-identifier-MIT
+    default_applicable_licenses: ["external_rust_cxx_license"],
+}
+
+genrule {
+    name: "cxx-demo-bridge-header",
+    tools: ["cxxbridge"],
+    cmd: "$(location cxxbridge) $(in) --header > $(out)",
+    srcs: ["src/main.rs"],
+    out: ["demo/src/main.rs.h"],
+}
+
+genrule {
+    name: "cxx-demo-bridge-code",
+    tools: ["cxxbridge"],
+    cmd: "$(location cxxbridge) $(in) >> $(out)",
+    srcs: ["src/main.rs"],
+    out: ["demo/generated.cc"],
+}
+
+rust_binary {
+    name: "cxx-demo-rs",
+    srcs: ["src/main.rs"],
+    rlibs: ["libcxx"],
+    static_libs: ["libcxx-demo-blobstore"],
+}
diff --git a/gen/cmd/Android.bp b/gen/cmd/Android.bp
new file mode 100644
index 0000000..b0d6ad4
--- /dev/null
+++ b/gen/cmd/Android.bp
@@ -0,0 +1,29 @@
+// This file is generated by cargo_embargo.
+// Do not modify this file as changes will be overridden on upgrade.
+
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "external_rust_cxx_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    //   SPDX-license-identifier-MIT
+    default_applicable_licenses: ["external_rust_cxx_license"],
+}
+
+rust_binary_host {
+    name: "cxxbridge",
+    crate_name: "cxxbridge",
+    cargo_env_compat: true,
+    cargo_pkg_version: "1.0.93",
+    srcs: ["src/main.rs"],
+    edition: "2021",
+    rustlibs: [
+        "libclap",
+        "libcodespan_reporting",
+        "libproc_macro2",
+        "libquote",
+        "libsyn",
+    ],
+    compile_multilib: "first",
+}
diff --git a/gen/lib/Android.bp b/gen/lib/Android.bp
new file mode 100644
index 0000000..bcafaa5
--- /dev/null
+++ b/gen/lib/Android.bp
@@ -0,0 +1,18 @@
+// This file is generated by cargo_embargo.
+// Do not modify this file as changes will be overridden on upgrade.
+
+rust_library_host {
+    name: "libcxx_gen",
+    crate_name: "cxx_gen",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.7.93",
+    srcs: ["src/lib.rs"],
+    edition: "2021",
+    rustlibs: [
+        "libcodespan_reporting",
+        "libproc_macro2",
+        "libquote",
+        "libsyn",
+    ],
+    compile_multilib: "first",
+}
diff --git a/macro/Android.bp b/macro/Android.bp
new file mode 100644
index 0000000..d5a7405
--- /dev/null
+++ b/macro/Android.bp
@@ -0,0 +1,28 @@
+// This file is generated by cargo_embargo.
+// Do not modify this file as changes will be overridden on upgrade.
+
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "external_rust_cxx_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    //   SPDX-license-identifier-MIT
+    default_applicable_licenses: ["external_rust_cxx_license"],
+}
+
+rust_proc_macro {
+    name: "libcxxbridge_macro",
+    crate_name: "cxxbridge_macro",
+    cargo_env_compat: true,
+    cargo_pkg_version: "1.0.93",
+    srcs: ["src/lib.rs"],
+    edition: "2021",
+    rustlibs: [
+        "libproc_macro2",
+        "libquote",
+        "libsyn",
+    ],
+    product_available: true,
+    vendor_available: true,
+}