summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Drysdale <drysdale@google.com>2022-02-02 17:04:17 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-11-15 01:47:22 +0000
commitc022f1c5ca2b97fd459252ca26cd6872a63155d6 (patch)
tree5e06709d4eb6fb449856a106fb53f3dd1aa83c39
parent4f45dace02ca4d06b97db7b0c1b52f9a0acbc87b (diff)
downloadboringssl-c022f1c5ca2b97fd459252ca26cd6872a63155d6.tar.gz
Use genrule to pull in bindgen-erated source
Rather than having a local modification of the upstream Rust source, instead use a genrule to replace the `${INCLUDES}` placeholder with a re-export of everything from the bindgen-created code. This change means that the upstream BoringSSL source no longer has a local modification, making it easier to import new versions. Also add a rust_test for the bindgen layout tests along the way. Bug: 177080016 Test: build targets, atest libbssl_sys_raw_test Change-Id: Iabf1b6ac4ae7d3a391cc038b29f157347fb36f2f Merged-In: Iabf1b6ac4ae7d3a391cc038b29f157347fb36f2f (cherry picked from commit 71257a0a0347296eba49f1ca39c0e6b024243ffb) (cherry picked from commit 1364953c681d19461b5bf3f291cc336c1ec0f625) Merged-In: Iabf1b6ac4ae7d3a391cc038b29f157347fb36f2f
-rw-r--r--Android.bp24
-rw-r--r--TEST_MAPPING7
-rw-r--r--src/rust/src/lib.rs4
3 files changed, 33 insertions, 2 deletions
diff --git a/Android.bp b/Android.bp
index 99617760..40acf086 100644
--- a/Android.bp
+++ b/Android.bp
@@ -576,6 +576,8 @@ rust_bindgen {
wrapper_src: "src/rust/wrapper.h",
vendor_available: true,
bindgen_flags: [
+ // Adapted from upstream the src/rust/CMakeLists.txt file at:
+ // https://boringssl.googlesource.com/boringssl/+/refs/heads/master/rust/CMakeLists.txt
"--no-derive-default",
"--enable-function-attribute-detection",
"--use-core",
@@ -603,6 +605,21 @@ rust_bindgen {
],
}
+// Encapsulate the bindgen-generated layout tests as a test target.
+rust_test {
+ name: "libbssl_sys_raw_test",
+ srcs: [
+ ":libbssl_sys_raw",
+ ],
+ crate_name: "bssl_sys_raw_test",
+ test_suites: ["general-tests"],
+ auto_gen_config: true,
+ clippy_lints: "none",
+ lints: "none",
+}
+
+// Rust's bindgen doesn't cope with macros, so this target includes C functions that
+// do the same thing as macros defined in BoringSSL header files.
cc_library_static {
name: "libbssl_rust_support",
host_supported: true,
@@ -614,6 +631,13 @@ cc_library_static {
],
}
+// Replace the upstream CMake placeholder with a re-export of all of the local bindgen output.
+gensrcs {
+ name: "libbssl_sys_src",
+ srcs: ["src/rust/src/lib.rs"],
+ cmd: "sed 's@^.{INCLUDES}@pub use bssl_sys_raw::*;@' $(in) > $(out)",
+}
+
rust_library {
name: "libbssl_ffi",
host_supported: true,
diff --git a/TEST_MAPPING b/TEST_MAPPING
new file mode 100644
index 00000000..ce976386
--- /dev/null
+++ b/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+ "presubmit": [
+ {
+ "name": "libbssl_sys_raw_test"
+ }
+ ]
+}
diff --git a/src/rust/src/lib.rs b/src/rust/src/lib.rs
index b691baba..d8c2c000 100644
--- a/src/rust/src/lib.rs
+++ b/src/rust/src/lib.rs
@@ -2,8 +2,8 @@
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
-// ANDROID: Use Soong-generated bindings rather than CMake-generated
-pub use bssl_sys_raw::*;
+// populated by cmake
+${INCLUDES}
pub fn ERR_GET_LIB(packed_error: u32) -> i32 {
unsafe { ERR_GET_LIB_RUST(packed_error) }