From 26ecd6c5974fcd3ec09792394e7b9cdf32f5f64f Mon Sep 17 00:00:00 2001 From: Ivan Lozano Date: Fri, 31 Jul 2020 13:40:31 -0400 Subject: [rust] Add SourceProviders as crates support. This allows SourceProvider modules to create rust_library variants so that generated source can be referenced as an external crate rather than via an include macro. This is done by including rust_bindgen modules like any other library, as a dependency in either rlibs, dylibs, or rustlibs. This renames the stem and flags properties for rust_bindgen modules to source_stem and bindgen_flags, respectively. This deconflicts with the usage in baseCompiler. This also removes 'subName' from the Module struct and moves it over to SourceProvider, which was the only user. This allows us to set it in baseSourceProvider's AndroidMk; setting it in Module's AndroidMk was causing problems finding NOTICE files for bindgen library variants. Bug: 159064919 Test: New Soong tests pass. Test: Local test rust_binary can use rust_bindgen module as a crate. Change-Id: Ieb2cb614c2dd0b5aa7120541d77f6f822a6a1806 --- rust/bindgen.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'rust/bindgen.go') diff --git a/rust/bindgen.go b/rust/bindgen.go index e8bbb35f1..304f8ec38 100644 --- a/rust/bindgen.go +++ b/rust/bindgen.go @@ -61,7 +61,7 @@ type BindgenProperties struct { Wrapper_src *string `android:"path,arch_variant"` // list of bindgen-specific flags and options - Flags []string `android:"arch_variant"` + Bindgen_flags []string `android:"arch_variant"` // list of clang flags required to correctly interpret the headers. Cflags []string `android:"arch_variant"` @@ -121,7 +121,7 @@ func (b *bindgenDecorator) generateSource(ctx android.ModuleContext, deps PathDe } bindgenFlags := defaultBindgenFlags - bindgenFlags = append(bindgenFlags, strings.Join(b.Properties.Flags, " ")) + bindgenFlags = append(bindgenFlags, strings.Join(b.Properties.Bindgen_flags, " ")) wrapperFile := android.OptionalPathForModuleSrc(ctx, b.Properties.Wrapper_src) if !wrapperFile.Valid() { @@ -170,7 +170,13 @@ func NewRustBindgen(hod android.HostOrDeviceSupported) (*Module, *bindgenDecorat baseSourceProvider: NewSourceProvider(), Properties: BindgenProperties{}, } + + _, library := NewRustLibrary(hod) + library.BuildOnlyRust() + library.sourceProvider = bindgen + module.sourceProvider = bindgen + module.compiler = library return module, bindgen } -- cgit v1.2.3-59-g8ed1b