From 60b657631fbf273436569b355ef91d66e062563a Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Thu, 14 Apr 2022 11:52:01 +0000 Subject: Add no_std version of library, with different set of features enabled. This is necessary to use the spinlock implementation in no_std binaries such as pVM firmware. Other users need the std features of the library so we can't use the same target for both. Bug: 223166344 Test: Ran pVM firmware with spinlock for console UART. Change-Id: Ia06b1abedd3c6da0f75b0b131a669a7216db8877 --- Android.bp | 20 ++++++++++++++++++++ cargo2android.json | 1 + cargo2android_nostd.bp | 18 ++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 cargo2android_nostd.bp diff --git a/Android.bp b/Android.bp index ff9b357..6d0e88c 100644 --- a/Android.bp +++ b/Android.bp @@ -71,6 +71,26 @@ rust_test { ], } +rust_library_rlib { + name: "libspin_nostd", + host_supported: true, + crate_name: "spin", + cargo_env_compat: true, + cargo_pkg_version: "0.9.2", + srcs: ["src/lib.rs"], + edition: "2015", + features: [ + "mutex", + "spin_mutex", + ], + apex_available: [ + "//apex_available:platform", + "com.android.virt", + ], + min_sdk_version: "29", +} + + // Errors when listing tests: // error[E0433]: failed to resolve: could not find `Mutex` in `spin` // error[E0433]: failed to resolve: could not find `RwLock` in `spin` diff --git a/cargo2android.json b/cargo2android.json index 1fff1ac..086d38a 100644 --- a/cargo2android.json +++ b/cargo2android.json @@ -1,4 +1,5 @@ { + "add-toplevel-block": "cargo2android_nostd.bp", "apex-available": [ "//apex_available:platform", "com.android.compos", diff --git a/cargo2android_nostd.bp b/cargo2android_nostd.bp new file mode 100644 index 0000000..49d0318 --- /dev/null +++ b/cargo2android_nostd.bp @@ -0,0 +1,18 @@ +rust_library_rlib { + name: "libspin_nostd", + host_supported: true, + crate_name: "spin", + cargo_env_compat: true, + cargo_pkg_version: "0.9.2", + srcs: ["src/lib.rs"], + edition: "2015", + features: [ + "mutex", + "spin_mutex", + ], + apex_available: [ + "//apex_available:platform", + "com.android.virt", + ], + min_sdk_version: "29", +} -- cgit v1.2.3