aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-03-15 18:09:05 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-03-15 18:09:05 +0000
commit80939e5ec66155254eca8b5c928a70c2b34614ea (patch)
tree8ca860d2d6c80ef5f0ac8ff78df4b2e1a57d3090
parent12720c990441258cd9d90a58f362433ae342cad9 (diff)
parent03a37ce18a955ab4af60e862d89a007bea6ea087 (diff)
downloadmemoffset-build-tools-release.tar.gz
Snap for 11582845 from 03a37ce18a955ab4af60e862d89a007bea6ea087 to build-tools-releasebuild-tools-release
Change-Id: I2976fc22f6e3cc51f2637d05f3248abc2a6d0da4
-rw-r--r--Android.bp37
-rw-r--r--Cargo.toml1
-rw-r--r--cargo_embargo.json16
-rw-r--r--patches/std.diff43
-rw-r--r--src/lib.rs7
-rw-r--r--src/span_of.rs3
6 files changed, 68 insertions, 39 deletions
diff --git a/Android.bp b/Android.bp
index c2f83d7..6aec059 100644
--- a/Android.bp
+++ b/Android.bp
@@ -25,7 +25,7 @@ rust_library {
cargo_env_compat: true,
cargo_pkg_version: "0.9.0",
srcs: ["src/lib.rs"],
- edition: "2015",
+ edition: "2018",
features: ["default"],
cfgs: [
"allow_clippy",
@@ -34,6 +34,7 @@ rust_library {
"raw_ref_macros",
"stable_const",
"tuple_ty",
+ "aosp_force_use_std",
],
apex_available: [
"//apex_available:platform",
@@ -56,7 +57,7 @@ rust_test {
test_options: {
unit_test: true,
},
- edition: "2015",
+ edition: "2018",
features: ["default"],
cfgs: [
"allow_clippy",
@@ -65,5 +66,37 @@ rust_test {
"raw_ref_macros",
"stable_const",
"tuple_ty",
+ "aosp_force_use_std",
],
}
+
+rust_library_rlib {
+ name: "libmemoffset_nostd",
+ crate_name: "memoffset",
+ cargo_env_compat: true,
+ cargo_pkg_version: "0.9.0",
+ srcs: ["src/lib.rs"],
+ edition: "2018",
+ features: ["default"],
+ cfgs: [
+ "allow_clippy",
+ "doctests",
+ "maybe_uninit",
+ "raw_ref_macros",
+ "stable_const",
+ "tuple_ty",
+ ],
+ apex_available: [
+ "//apex_available:platform",
+ "//apex_available:anyapex",
+ ],
+ prefer_rlib: true,
+ no_stdlibs: true,
+ stdlibs: [
+ "liballoc.rust_sysroot",
+ "libcompiler_builtins.rust_sysroot",
+ "libcore.rust_sysroot",
+ ],
+ product_available: true,
+ vendor_available: true,
+}
diff --git a/Cargo.toml b/Cargo.toml
index 77fe68f..bc62b4a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,6 +10,7 @@
# See Cargo.toml.orig for the original contents.
[package]
+edition = "2018" # ANDROID: Required to build dylib in no_std.
name = "memoffset"
version = "0.9.0"
authors = ["Gilad Naaman <gilad.naaman@gmail.com>"]
diff --git a/cargo_embargo.json b/cargo_embargo.json
index c458c58..a503b0a 100644
--- a/cargo_embargo.json
+++ b/cargo_embargo.json
@@ -9,7 +9,23 @@
"variants": [
{
"min_sdk_version": "29",
+ "extra_cfg": [
+ "aosp_force_use_std"
+ ],
"tests": true
+ },
+ {
+ "module_name_overrides": {
+ "libmemoffset": "libmemoffset_nostd"
+ },
+ "package": {
+ "memoffset": {
+ "alloc": true,
+ "force_rlib": true,
+ "host_supported": false,
+ "no_std": true
+ }
+ }
}
]
}
diff --git a/patches/std.diff b/patches/std.diff
index fc4bdbc..034f559 100644
--- a/patches/std.diff
+++ b/patches/std.diff
@@ -1,40 +1,21 @@
+diff --git a/Cargo.toml b/Cargo.toml
+index 77fe68f..bc62b4a 100644
+--- a/Cargo.toml
++++ b/Cargo.toml
+@@ -10,4 +10,5 @@
+ # See Cargo.toml.orig for the original contents.
+
+ [package]
++edition = "2018" # ANDROID: Required to build dylib in no_std.
+ name = "memoffset"
diff --git a/src/lib.rs b/src/lib.rs
index c85fb01..25b0444 100644
--- a/src/lib.rs
+++ b/src/lib.rs
-@@ -56,7 +56,8 @@
+@@ -55,5 +55,5 @@
//! let checksum = crc16(checksum_range);
//! ```
-#![no_std]
-+// ANDROID: include standard library to build as a dylib
-+//#![no_std]
++#![cfg_attr(not(aosp_force_use_std), no_std)]
#![cfg_attr(
- feature = "unstable_const",
- feature(
-@@ -78,9 +79,9 @@
- #[doc(hidden)]
- pub mod __priv {
- #[doc(hidden)]
-- pub use core::mem;
-+ pub use std::mem; // ANDROID: use std instead of core, since we're not building with no-std.
- #[doc(hidden)]
-- pub use core::ptr;
-+ pub use std::ptr; // ANDROID: use std instead of core, since we're not building with no-std.
-
- /// Use type inference to obtain the size of the pointee (without actually using the pointer).
- #[doc(hidden)]
-diff --git a/src/span_of.rs b/src/span_of.rs
-index 0592dbd..369e5c6 100644
---- a/src/span_of.rs
-+++ b/src/span_of.rs
-@@ -155,7 +155,8 @@ macro_rules! span_of {
-
- #[cfg(test)]
- mod tests {
-- use core::mem;
-+ // ANDROID: use std instead of core, since we're not building wiht no-std.
-+ use std::mem;
-
- #[test]
- fn span_simple() { \ No newline at end of file
diff --git a/src/lib.rs b/src/lib.rs
index f0aab7b..8d65d9a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -55,8 +55,7 @@
//! let checksum = crc16(checksum_range);
//! ```
-// ANDROID: include standard library to build as a dylib
-//#![no_std]
+#![cfg_attr(not(aosp_force_use_std), no_std)]
#![cfg_attr(
all(feature = "unstable_const", not(stable_const)),
feature(const_ptr_offset_from)
@@ -76,9 +75,9 @@ doctest!("../README.md");
#[doc(hidden)]
pub mod __priv {
#[doc(hidden)]
- pub use std::mem; // ANDROID: use std instead of core, since we're not building with no-std.
+ pub use core::mem;
#[doc(hidden)]
- pub use std::ptr; // ANDROID: use std instead of core, since we're not building with no-std.
+ pub use core::ptr;
/// Use type inference to obtain the size of the pointee (without actually using the pointer).
#[doc(hidden)]
diff --git a/src/span_of.rs b/src/span_of.rs
index c2030b7..89fccce 100644
--- a/src/span_of.rs
+++ b/src/span_of.rs
@@ -155,8 +155,7 @@ macro_rules! span_of {
#[cfg(test)]
mod tests {
- // ANDROID: use std instead of core, since we're not building wiht no-std.
- use std::mem;
+ use core::mem;
#[test]
fn span_simple() {