Merge "Adds support to bindgen to handle static inline fcts" into main
This commit is contained in:
commit
5e94e60cb7
2 changed files with 25 additions and 0 deletions
|
@ -101,6 +101,9 @@ type BindgenProperties struct {
|
|||
//
|
||||
// "my_bindgen [flags] wrapper_header.h -o [output_path] -- [clang flags]"
|
||||
Custom_bindgen string
|
||||
|
||||
// flag to indicate if bindgen should handle `static inline` functions (default is false)
|
||||
Handle_static_inline bool
|
||||
}
|
||||
|
||||
type bindgenDecorator struct {
|
||||
|
@ -232,6 +235,9 @@ func (b *bindgenDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) andr
|
|||
|
||||
bindgenFlags := defaultBindgenFlags
|
||||
bindgenFlags = append(bindgenFlags, esc(b.Properties.Bindgen_flags)...)
|
||||
if b.Properties.Handle_static_inline {
|
||||
bindgenFlags = append(bindgenFlags, "--experimental --wrap-static-fns")
|
||||
}
|
||||
|
||||
// cat reads from stdin if its command line is empty,
|
||||
// so we pass in /dev/null if there are no other flag files
|
||||
|
|
|
@ -227,3 +227,22 @@ func TestBindgenFlagFile(t *testing.T) {
|
|||
// 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)
|
||||
}
|
||||
|
||||
|
||||
func TestBindgenHandleStaticInlining(t *testing.T) {
|
||||
ctx := testRust(t, `
|
||||
rust_bindgen {
|
||||
name: "libbindgen",
|
||||
wrapper_src: "src/any.h",
|
||||
crate_name: "bindgen",
|
||||
stem: "libbindgen",
|
||||
source_stem: "bindings",
|
||||
handle_static_inline: true
|
||||
}
|
||||
`)
|
||||
libbindgen := ctx.ModuleForTests("libbindgen", "android_arm64_armv8-a_source").Output("bindings.rs")
|
||||
// Make sure the flag to support `static inline` functions is present
|
||||
if !strings.Contains(libbindgen.Args["flags"], "--wrap-static-fns") {
|
||||
t.Errorf("missing flag to handle static inlining in rust_bindgen rule: flags %#v", libbindgen.Args["flags"])
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue