summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Geisler <mgeisler@google.com>2024-04-23 14:07:07 +0200
committerMartin Geisler <mgeisler@google.com>2024-04-23 17:45:31 +0200
commit1559a0d87a4f3ea7029fe92513ce60fce292a444 (patch)
tree26eb9d7b1177d5289610b1e586f4ea41c94a6f6f
parente28e2f6f4fdcee451d5a06d7746c58054aba4411 (diff)
downloadoneshot-uniffi-1559a0d87a4f3ea7029fe92513ce60fce292a444.tar.gz
Generate Android.bp for oneshot-uniffi
The crate is a bit special: it’s identical to the oneshot crate, but with a dependency removed: https://github.com/faern/oneshot/compare/main...bendk:oneshot:main As such, the crate is called oneshot-uniffi, but the rest of the UniFFI crates import it as just “oneshot”. The same applies to the tests in the crate itself. Patching the `crate_name` seems like the easiest way to accommodate this. The library is visibility restricted so this will only be visible to `uniffi_core`. Bug: 330717829 Test: atest --host Change-Id: I8dc3b9c39abcce5ca48bf0f7b8adeb7b149090b3
-rw-r--r--Android.bp226
-rw-r--r--cargo_embargo.json12
-rw-r--r--patches/Android.bp.patch13
-rw-r--r--patches/disable-async-tests.patch9
-rw-r--r--tests/async.rs1
5 files changed, 261 insertions, 0 deletions
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..3066400
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,226 @@
+// This file is generated by cargo_embargo.
+// Do not modify this file after the first "rust_*" or "genrule" module
+// because the changes will be overridden on upgrade.
+// Content before the first "rust_*" or "genrule" module is preserved.
+
+package {
+ default_applicable_licenses: ["external_rust_crates_oneshot_uniffi_license"],
+}
+
+// See: http://go/android-license-faq
+license {
+ name: "external_rust_crates_oneshot_uniffi_license",
+ visibility: [":__subpackages__"],
+ license_kinds: [
+ "SPDX-license-identifier-Apache-2.0",
+ "SPDX-license-identifier-MIT",
+ ],
+ license_text: [
+ "LICENSE-APACHE",
+ "LICENSE-MIT",
+ ],
+}
+
+rust_library {
+ name: "liboneshot_uniffi",
+ host_supported: true,
+ crate_name: "oneshot",
+ cargo_env_compat: true,
+ cargo_pkg_version: "0.1.6",
+ srcs: ["src/lib.rs"],
+ edition: "2021",
+ features: [
+ "async",
+ "default",
+ "std",
+ ],
+ cfgs: ["soong"],
+ apex_available: [
+ "//apex_available:platform",
+ "//apex_available:anyapex",
+ ],
+ product_available: true,
+ vendor_available: true,
+ visibility: ["//external/rust/crates/uniffi_core"],
+}
+
+rust_test {
+ name: "oneshot-uniffi_test_src_lib",
+ host_supported: true,
+ crate_name: "oneshot_uniffi",
+ cargo_env_compat: true,
+ cargo_pkg_version: "0.1.6",
+ srcs: ["src/lib.rs"],
+ test_suites: ["general-tests"],
+ auto_gen_config: true,
+ test_options: {
+ unit_test: true,
+ },
+ edition: "2021",
+ features: [
+ "async",
+ "default",
+ "std",
+ ],
+ cfgs: ["soong"],
+ rustlibs: [
+ "libcriterion",
+ "libtokio",
+ ],
+}
+
+rust_test {
+ name: "oneshot-uniffi_test_tests_assert_mem",
+ host_supported: true,
+ crate_name: "assert_mem",
+ cargo_env_compat: true,
+ cargo_pkg_version: "0.1.6",
+ srcs: ["tests/assert_mem.rs"],
+ test_suites: ["general-tests"],
+ auto_gen_config: true,
+ test_options: {
+ unit_test: true,
+ },
+ edition: "2021",
+ features: [
+ "async",
+ "default",
+ "std",
+ ],
+ cfgs: ["soong"],
+ rustlibs: [
+ "libcriterion",
+ "liboneshot_uniffi",
+ "libtokio",
+ ],
+}
+
+rust_test {
+ name: "oneshot-uniffi_test_tests_async",
+ host_supported: true,
+ crate_name: "async",
+ cargo_env_compat: true,
+ cargo_pkg_version: "0.1.6",
+ srcs: ["tests/async.rs"],
+ test_suites: ["general-tests"],
+ auto_gen_config: true,
+ test_options: {
+ unit_test: true,
+ },
+ edition: "2021",
+ features: [
+ "async",
+ "default",
+ "std",
+ ],
+ cfgs: ["soong"],
+ rustlibs: [
+ "libcriterion",
+ "liboneshot_uniffi",
+ "libtokio",
+ ],
+}
+
+rust_test {
+ name: "oneshot-uniffi_test_tests_future",
+ host_supported: true,
+ crate_name: "future",
+ cargo_env_compat: true,
+ cargo_pkg_version: "0.1.6",
+ srcs: ["tests/future.rs"],
+ test_suites: ["general-tests"],
+ auto_gen_config: true,
+ test_options: {
+ unit_test: true,
+ },
+ edition: "2021",
+ features: [
+ "async",
+ "default",
+ "std",
+ ],
+ cfgs: ["soong"],
+ rustlibs: [
+ "libcriterion",
+ "liboneshot_uniffi",
+ "libtokio",
+ ],
+}
+
+rust_test {
+ name: "oneshot-uniffi_test_tests_loom",
+ host_supported: true,
+ crate_name: "loom",
+ cargo_env_compat: true,
+ cargo_pkg_version: "0.1.6",
+ srcs: ["tests/loom.rs"],
+ test_suites: ["general-tests"],
+ auto_gen_config: true,
+ test_options: {
+ unit_test: true,
+ },
+ edition: "2021",
+ features: [
+ "async",
+ "default",
+ "std",
+ ],
+ cfgs: ["soong"],
+ rustlibs: [
+ "libcriterion",
+ "liboneshot_uniffi",
+ "libtokio",
+ ],
+}
+
+rust_test {
+ name: "oneshot-uniffi_test_tests_raw",
+ host_supported: true,
+ crate_name: "raw",
+ cargo_env_compat: true,
+ cargo_pkg_version: "0.1.6",
+ srcs: ["tests/raw.rs"],
+ test_suites: ["general-tests"],
+ auto_gen_config: true,
+ test_options: {
+ unit_test: true,
+ },
+ edition: "2021",
+ features: [
+ "async",
+ "default",
+ "std",
+ ],
+ cfgs: ["soong"],
+ rustlibs: [
+ "libcriterion",
+ "liboneshot_uniffi",
+ "libtokio",
+ ],
+}
+
+rust_test {
+ name: "oneshot-uniffi_test_tests_sync",
+ host_supported: true,
+ crate_name: "sync",
+ cargo_env_compat: true,
+ cargo_pkg_version: "0.1.6",
+ srcs: ["tests/sync.rs"],
+ test_suites: ["general-tests"],
+ auto_gen_config: true,
+ test_options: {
+ unit_test: true,
+ },
+ edition: "2021",
+ features: [
+ "async",
+ "default",
+ "std",
+ ],
+ cfgs: ["soong"],
+ rustlibs: [
+ "libcriterion",
+ "liboneshot_uniffi",
+ "libtokio",
+ ],
+}
diff --git a/cargo_embargo.json b/cargo_embargo.json
index 762838b..7d882dc 100644
--- a/cargo_embargo.json
+++ b/cargo_embargo.json
@@ -1,8 +1,20 @@
{
"run_cargo": false,
+ "tests": true,
"module_visibility": {
"liboneshot_uniffi": [
"//external/rust/crates/uniffi_core"
]
+ },
+ "extra_cfg": [
+ "soong"
+ ],
+ "package": {
+ "oneshot-uniffi": {
+ "patch": "patches/Android.bp.patch",
+ "dep_blocklist": [
+ "libasync_std"
+ ]
+ }
}
}
diff --git a/patches/Android.bp.patch b/patches/Android.bp.patch
new file mode 100644
index 0000000..e9ba659
--- /dev/null
+++ b/patches/Android.bp.patch
@@ -0,0 +1,13 @@
+diff --git a/Android.bp b/Android.bp
+index cc2a9fa..bb9f5cf 100644
+--- a/Android.bp
++++ b/Android.bp
+@@ -7,7 +7,7 @@
+ rust_library {
+ name: "liboneshot_uniffi",
+ host_supported: true,
+- crate_name: "oneshot_uniffi",
++ crate_name: "oneshot",
+ cargo_env_compat: true,
+ cargo_pkg_version: "0.1.6",
+ srcs: ["src/lib.rs"],
diff --git a/patches/disable-async-tests.patch b/patches/disable-async-tests.patch
new file mode 100644
index 0000000..7e07ab1
--- /dev/null
+++ b/patches/disable-async-tests.patch
@@ -0,0 +1,9 @@
+diff --git a/tests/async.rs b/tests/async.rs
+index e7633aa..59acbf5 100644
+--- a/tests/async.rs
++++ b/tests/async.rs
+@@ -1,3 +1,4 @@
++#![cfg(not(soong))]
+ #![cfg(all(feature = "async", not(loom)))]
+
+ use core::mem;
diff --git a/tests/async.rs b/tests/async.rs
index e7633aa..59acbf5 100644
--- a/tests/async.rs
+++ b/tests/async.rs
@@ -1,3 +1,4 @@
+#![cfg(not(soong))]
#![cfg(all(feature = "async", not(loom)))]
use core::mem;