From c564d2d5a46af4c213e424ee5a7ad7ff9cb2ba3a Mon Sep 17 00:00:00 2001 From: Ivan Lozano Date: Tue, 4 Aug 2020 15:43:37 -0400 Subject: 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 --- rust/rust.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'rust/rust.go') diff --git a/rust/rust.go b/rust/rust.go index 01952477e..7ec2d736b 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -722,10 +722,11 @@ type dependencyTag struct { } var ( - rlibDepTag = dependencyTag{name: "rlibTag", library: true} - dylibDepTag = dependencyTag{name: "dylib", library: true} - procMacroDepTag = dependencyTag{name: "procMacro", proc_macro: true} - testPerSrcDepTag = dependencyTag{name: "rust_unit_tests"} + customBindgenDepTag = dependencyTag{name: "customBindgenTag"} + rlibDepTag = dependencyTag{name: "rlibTag", library: true} + dylibDepTag = dependencyTag{name: "dylib", library: true} + procMacroDepTag = dependencyTag{name: "procMacro", proc_macro: true} + testPerSrcDepTag = dependencyTag{name: "rust_unit_tests"} ) type autoDep struct { @@ -1009,6 +1010,13 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) { actx.AddVariationDependencies(commonDepVariations, cc.CrtEndDepTag, deps.CrtEnd) } + if mod.sourceProvider != nil { + if bindgen, ok := mod.sourceProvider.(*bindgenDecorator); ok && + bindgen.Properties.Custom_bindgen != "" { + actx.AddFarVariationDependencies(ctx.Config().BuildOSTarget.Variations(), customBindgenDepTag, + bindgen.Properties.Custom_bindgen) + } + } // proc_macros are compiler plugins, and so we need the host arch variant as a dependendcy. actx.AddFarVariationDependencies(ctx.Config().BuildOSTarget.Variations(), procMacroDepTag, deps.ProcMacros...) } -- cgit v1.2.3-59-g8ed1b