summaryrefslogtreecommitdiff
path: root/rust/bindgen_test.go
diff options
context:
space:
mode:
author Ivan Lozano <ivanlozano@google.com> 2020-08-04 15:43:37 -0400
committer Ivan Lozano <ivanlozano@google.com> 2020-08-05 10:51:43 -0400
commitc564d2d5a46af4c213e424ee5a7ad7ff9cb2ba3a (patch)
treeef2c92477a3ff898e8d534947ef2ac9cfc2ba98d /rust/bindgen_test.go
parentb14e14151964df77548e37de84300b433592013e (diff)
Add support for custom bindgen binaries.
In some cases customized logic is required to generate the expected bindgen bindings. This adds support for rust_bindgen modules to define a HostTool module to use instead of bindgen. Bug: 161816141 Test: New Soong tests pass. Test: Local test case shows custom_binary module being used for bindgen generation. Change-Id: Id52aec4f25c38206d7e585d8e662be7836aa1d4b
Diffstat (limited to 'rust/bindgen_test.go')
-rw-r--r--rust/bindgen_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/rust/bindgen_test.go b/rust/bindgen_test.go
index c42834843..0b529ca5a 100644
--- a/rust/bindgen_test.go
+++ b/rust/bindgen_test.go
@@ -55,3 +55,29 @@ func TestRustBindgen(t *testing.T) {
t.Errorf("missing static_libs exported includes in rust_bindgen rule: cflags %#v", libbindgen.Args["cflags"])
}
}
+
+func TestRustBindgenCustomBindgen(t *testing.T) {
+ ctx := testRust(t, `
+ rust_bindgen {
+ name: "libbindgen",
+ wrapper_src: "src/any.h",
+ crate_name: "bindgen",
+ stem: "libbindgen",
+ source_stem: "bindings",
+ custom_bindgen: "my_bindgen"
+ }
+ rust_binary_host {
+ name: "my_bindgen",
+ srcs: ["foo.rs"],
+ }
+ `)
+
+ libbindgen := ctx.ModuleForTests("libbindgen", "android_arm64_armv8-a").Output("bindings.rs")
+
+ // The rule description should contain the custom binary name rather than bindgen, so checking the description
+ // should be sufficient.
+ if !strings.Contains(libbindgen.Description, "my_bindgen") {
+ t.Errorf("Custom bindgen binary %s not used for libbindgen: rule description %#v", "my_bindgen",
+ libbindgen.Description)
+ }
+}