rust: Add Bindgen_flag_files property

Add a new Bindgen_flag_files property to bindgen modules
that let users specify files that contain extra flags for
bindgen.

Bug: 242243245
Test: presubmit
Change-Id: I21d987c08ac417c04aaa3bfb3b75d563fc662d5b
This commit is contained in:
Andrei Homescu
2023-07-08 00:35:15 +00:00
parent 5ad5c918a3
commit 78a1f8dfb8
2 changed files with 45 additions and 5 deletions

View File

@@ -168,3 +168,28 @@ func TestBindgenDisallowedFlags(t *testing.T) {
}
`)
}
func TestBindgenFlagFile(t *testing.T) {
ctx := testRust(t, `
rust_bindgen {
name: "libbindgen",
wrapper_src: "src/any.h",
crate_name: "bindgen",
stem: "libbindgen",
source_stem: "bindings",
bindgen_flag_files: [
"flag_file.txt",
],
}
`)
libbindgen := ctx.ModuleForTests("libbindgen", "android_arm64_armv8-a_source").Output("bindings.rs")
if !strings.Contains(libbindgen.Args["flagfiles"], "/dev/null") {
t.Errorf("missing /dev/null in rust_bindgen rule: flags %#v", libbindgen.Args["flagfiles"])
}
if !strings.Contains(libbindgen.Args["flagfiles"], "flag_file.txt") {
t.Errorf("missing bindgen flags file in rust_bindgen rule: flags %#v", libbindgen.Args["flagfiles"])
}
// TODO: The best we can do right now is check $flagfiles. Once bindgen.go switches to RuleBuilder,
// we may be able to check libbinder.RuleParams.Command to see if it contains $(cat /dev/null flag_file.txt)
}