aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Clément Tosi <ptosi@google.com>2022-11-01 17:01:01 +0000
committerPierre-Clément Tosi <ptosi@google.com>2022-11-14 20:28:39 +0000
commit34a3955d942937139aeb0adf28b2b4c2fca2c7d5 (patch)
tree09a76155cb53a2f088b6a9d211023eb5b95fd543
parent16cc42d73a749e72552abc03c8c5dc961aef47c8 (diff)
downloadzeroize-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.bp22
-rw-r--r--cargo2android.json1
-rw-r--r--cargo2android_nostd.bp20
3 files changed, 43 insertions, 0 deletions
diff --git a/Android.bp b/Android.bp
index c0c8306..bd184d8 100644
--- a/Android.bp
+++ b/Android.bp
@@ -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",
+}