summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Walbran <qwandor@google.com>2023-11-21 19:30:21 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-11-21 19:30:21 +0000
commitd01f0c523b510914fcd660f27955057b099602f4 (patch)
tree1a114fbc5e7b9d3db4563efeb7d95c013bbb93d2
parentcd16eaefb1f1f3245f8ea59f401c1d25a036bf65 (diff)
parente007c3760378ddff0385b9c00a7594c578a3380d (diff)
downloadring-d01f0c523b510914fcd660f27955057b099602f4.tar.gz
Fix cargo test. am: e007c37603
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/ring/+/2841413 Change-Id: I38034b5c259f03e2f31b4426477c320b08b6f617 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--Android.bp16
-rw-r--r--cargo2android.json1
-rw-r--r--cfg_soong.bp1
-rw-r--r--patches/hardcode_prefix.patch53
-rw-r--r--src/prefixed.rs30
5 files changed, 89 insertions, 12 deletions
diff --git a/Android.bp b/Android.bp
index fe6f70f..e187a57 100644
--- a/Android.bp
+++ b/Android.bp
@@ -67,6 +67,7 @@ rust_library {
product_available: true,
vendor_available: true,
min_sdk_version: "29",
+ cfgs: ["soong"],
}
rust_library_rlib {
@@ -101,6 +102,7 @@ rust_library_rlib {
product_available: true,
vendor_available: true,
min_sdk_version: "29",
+ cfgs: ["soong"],
}
rust_test {
@@ -134,6 +136,7 @@ rust_test {
"libring-core",
"libring-test",
],
+ cfgs: ["soong"],
}
rust_defaults {
@@ -169,6 +172,7 @@ rust_test {
test_options: {
unit_test: true,
},
+ cfgs: ["soong"],
}
rust_test {
@@ -180,6 +184,7 @@ rust_test {
test_options: {
unit_test: true,
},
+ cfgs: ["soong"],
}
rust_test {
@@ -191,6 +196,7 @@ rust_test {
test_options: {
unit_test: true,
},
+ cfgs: ["soong"],
}
rust_test {
@@ -202,6 +208,7 @@ rust_test {
test_options: {
unit_test: true,
},
+ cfgs: ["soong"],
}
rust_test {
@@ -213,6 +220,7 @@ rust_test {
test_options: {
unit_test: true,
},
+ cfgs: ["soong"],
}
rust_test {
@@ -224,6 +232,7 @@ rust_test {
test_options: {
unit_test: true,
},
+ cfgs: ["soong"],
}
rust_test {
@@ -235,6 +244,7 @@ rust_test {
test_options: {
unit_test: true,
},
+ cfgs: ["soong"],
}
rust_test {
@@ -246,6 +256,7 @@ rust_test {
test_options: {
unit_test: true,
},
+ cfgs: ["soong"],
}
rust_test {
@@ -257,6 +268,7 @@ rust_test {
test_options: {
unit_test: true,
},
+ cfgs: ["soong"],
}
rust_test {
@@ -268,6 +280,7 @@ rust_test {
test_options: {
unit_test: true,
},
+ cfgs: ["soong"],
}
rust_test {
@@ -279,6 +292,7 @@ rust_test {
test_options: {
unit_test: true,
},
+ cfgs: ["soong"],
}
rust_test {
@@ -290,6 +304,7 @@ rust_test {
test_options: {
unit_test: true,
},
+ cfgs: ["soong"],
}
rust_test {
@@ -301,6 +316,7 @@ rust_test {
test_options: {
unit_test: true,
},
+ cfgs: ["soong"],
}
cc_library_static {
diff --git a/cargo2android.json b/cargo2android.json
index e7b015e..2abef64 100644
--- a/cargo2android.json
+++ b/cargo2android.json
@@ -1,5 +1,6 @@
{
"add-toplevel-block": "cargo2android_cc.bp",
+ "add-module-block": "cfg_soong.bp",
"apex-available": [
"//apex_available:platform",
"com.android.resolv"
diff --git a/cfg_soong.bp b/cfg_soong.bp
new file mode 100644
index 0000000..83a9214
--- /dev/null
+++ b/cfg_soong.bp
@@ -0,0 +1 @@
+cfgs: ["soong"] \ No newline at end of file
diff --git a/patches/hardcode_prefix.patch b/patches/hardcode_prefix.patch
index a37c68a..41d00ec 100644
--- a/patches/hardcode_prefix.patch
+++ b/patches/hardcode_prefix.patch
@@ -1,14 +1,45 @@
-diff --git a/src/prefixed.rs b/src/prefixed.rs
-index 0f1c13e8c..c8ac807ee 100644
---- a/src/prefixed.rs
-+++ b/src/prefixed.rs
-@@ -68,7 +68,8 @@ macro_rules! prefixed_item {
- } => {
- prefixed_item! {
- $attr
-- { concat!(env!("RING_CORE_PREFIX"), stringify!($name)) }
-+ //{ concat!(env!("RING_CORE_PREFIX"), stringify!($name)) }
-+ { concat!("ring_core_android_platform_", stringify!($name)) }
+--- src/prefixed.rs.orig 2023-11-21 14:54:21.563997351 +0000
++++ src/prefixed.rs 2023-11-21 14:48:18.346428666 +0000
+@@ -73,6 +73,7 @@
+ };
+ }
+
++#[cfg(not(soong))]
+ macro_rules! prefixed_item {
+ // Calculate the prefixed name in a separate layer of macro expansion
+ // because rustc won't currently accept a non-literal expression as
+@@ -88,6 +89,34 @@
{ $( $item )+ }
}
};
++
++ // Output the item.
++ {
++ $attr:ident
++ { $prefixed_name:expr }
++ { $( $item:tt )+ }
++ } => {
++ #[$attr = $prefixed_name]
++ $( $item )+
++ };
++}
++
++#[cfg(soong)]
++macro_rules! prefixed_item {
++ // Calculate the prefixed name in a separate layer of macro expansion
++ // because rustc won't currently accept a non-literal expression as
++ // the value for `#[link_name = value]`.
++ {
++ $attr:ident
++ $name:ident
++ { $( $item:tt )+ }
++ } => {
++ prefixed_item! {
++ $attr
++ { concat!("ring_core_android_platform_", stringify!($name)) }
++ { $( $item )+ }
++ }
++ };
+
+ // Output the item.
+ {
diff --git a/src/prefixed.rs b/src/prefixed.rs
index a35f921..0b90721 100644
--- a/src/prefixed.rs
+++ b/src/prefixed.rs
@@ -73,6 +73,35 @@ macro_rules! prefixed_export {
};
}
+#[cfg(not(soong))]
+macro_rules! prefixed_item {
+ // Calculate the prefixed name in a separate layer of macro expansion
+ // because rustc won't currently accept a non-literal expression as
+ // the value for `#[link_name = value]`.
+ {
+ $attr:ident
+ $name:ident
+ { $( $item:tt )+ }
+ } => {
+ prefixed_item! {
+ $attr
+ { concat!(env!("RING_CORE_PREFIX"), stringify!($name)) }
+ { $( $item )+ }
+ }
+ };
+
+ // Output the item.
+ {
+ $attr:ident
+ { $prefixed_name:expr }
+ { $( $item:tt )+ }
+ } => {
+ #[$attr = $prefixed_name]
+ $( $item )+
+ };
+}
+
+#[cfg(soong)]
macro_rules! prefixed_item {
// Calculate the prefixed name in a separate layer of macro expansion
// because rustc won't currently accept a non-literal expression as
@@ -84,7 +113,6 @@ macro_rules! prefixed_item {
} => {
prefixed_item! {
$attr
- //{ concat!(env!("RING_CORE_PREFIX"), stringify!($name)) }
{ concat!("ring_core_android_platform_", stringify!($name)) }
{ $( $item )+ }
}