diff options
author | Pierre-Clément Tosi <ptosi@google.com> | 2022-11-01 17:01:01 +0000 |
---|---|---|
committer | Pierre-Clément Tosi <ptosi@google.com> | 2022-11-14 20:28:39 +0000 |
commit | 34a3955d942937139aeb0adf28b2b4c2fca2c7d5 (patch) | |
tree | 09a76155cb53a2f088b6a9d211023eb5b95fd543 | |
parent | 16cc42d73a749e72552abc03c8c5dc961aef47c8 (diff) | |
download | zeroize-34a3955d942937139aeb0adf28b2b4c2fca2c7d5.tar.gz |
Add a no_std variant of libzeroize
The current "libzeroize" requires std support so add a new rust_library
that links against the core library, instead.
As the crate's "alloc" feature requires an allocator and as there isn't
a single standard implementation of it in no_std, don't enable the
feature for "libzeroize_nostd". Otherwise, given how Android builds Rust
libraries, this would force all users of the rust_library to use and
share the same allocator implementation.
Test: m pvmfw_bin # libzeroize_nostd linked in aosp/2280853
Change-Id: Ia971829111cd4678cedc16c7e8435a20476caa85
-rw-r--r-- | Android.bp | 22 | ||||
-rw-r--r-- | cargo2android.json | 1 | ||||
-rw-r--r-- | cargo2android_nostd.bp | 20 |
3 files changed, 43 insertions, 0 deletions
@@ -90,3 +90,25 @@ rust_test { unit_test: true, }, } + +rust_library_rlib { + name: "libzeroize_nostd", + crate_name: "zeroize", + cargo_env_compat: true, + cargo_pkg_version: "1.5.7", + srcs: ["src/lib.rs"], + edition: "2018", + proc_macros: ["libzeroize_derive"], + prefer_rlib: true, + no_stdlibs: true, + stdlibs: [ + "libcompiler_builtins.rust_sysroot", + "libcore.rust_sysroot", + ], + features: [ + "zeroize_derive", + ], + vendor_available: true, + min_sdk_version: "Tiramisu", +} + diff --git a/cargo2android.json b/cargo2android.json index 29e5445..d05dd9f 100644 --- a/cargo2android.json +++ b/cargo2android.json @@ -1,4 +1,5 @@ { + "add-toplevel-block": "cargo2android_nostd.bp", "apex-available": [ "//apex_available:platform", "com.android.uwb", diff --git a/cargo2android_nostd.bp b/cargo2android_nostd.bp new file mode 100644 index 0000000..d7f5eb2 --- /dev/null +++ b/cargo2android_nostd.bp @@ -0,0 +1,20 @@ +rust_library_rlib { + name: "libzeroize_nostd", + crate_name: "zeroize", + cargo_env_compat: true, + cargo_pkg_version: "1.5.7", + srcs: ["src/lib.rs"], + edition: "2018", + proc_macros: ["libzeroize_derive"], + prefer_rlib: true, + no_stdlibs: true, + stdlibs: [ + "libcompiler_builtins.rust_sysroot", + "libcore.rust_sysroot", + ], + features: [ + "zeroize_derive", + ], + vendor_available: true, + min_sdk_version: "Tiramisu", +} |