From c7767922e06fd6513e0b1e6846a21dfe44df8823 Mon Sep 17 00:00:00 2001 From: Andrei Homescu Date: Wed, 5 Aug 2020 06:36:19 -0700 Subject: Export Rust SourceProvider types and methods The AIDL compiler now uses SourceProvider to compiler the generated Rust code from system/tools/aidl/build/aidl_interface.go using its own SourceProvider object, which needs access to baseSourceProvider and all methods of SourceProvider. Test: mmma system/tools/aidl with 1357705 applied Change-Id: I226609a7fccca2e7e1bfbad5d69d1821d37e43a1 --- rust/bindgen.go | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'rust/bindgen.go') diff --git a/rust/bindgen.go b/rust/bindgen.go index 2224a9cca..844290742 100644 --- a/rust/bindgen.go +++ b/rust/bindgen.go @@ -86,12 +86,12 @@ type BindgenProperties struct { } type bindgenDecorator struct { - *baseSourceProvider + *BaseSourceProvider Properties BindgenProperties } -func (b *bindgenDecorator) generateSource(ctx android.ModuleContext, deps PathDeps) android.Path { +func (b *bindgenDecorator) GenerateSource(ctx android.ModuleContext, deps PathDeps) android.Path { ccToolchain := ccConfig.FindToolchain(ctx.Os(), ctx.Arch()) var cflags []string @@ -134,7 +134,7 @@ func (b *bindgenDecorator) generateSource(ctx android.ModuleContext, deps PathDe ctx.PropertyErrorf("wrapper_src", "invalid path to wrapper source") } - outputFile := android.PathForModuleOut(ctx, b.baseSourceProvider.getStem(ctx)+".rs") + outputFile := android.PathForModuleOut(ctx, b.BaseSourceProvider.getStem(ctx)+".rs") var cmd, cmdDesc string if b.Properties.Custom_bindgen != "" { @@ -158,12 +158,12 @@ func (b *bindgenDecorator) generateSource(ctx android.ModuleContext, deps PathDe }, }) - b.baseSourceProvider.outputFile = outputFile + b.BaseSourceProvider.OutputFile = outputFile return outputFile } -func (b *bindgenDecorator) sourceProviderProps() []interface{} { - return append(b.baseSourceProvider.sourceProviderProps(), +func (b *bindgenDecorator) SourceProviderProps() []interface{} { + return append(b.BaseSourceProvider.SourceProviderProps(), &b.Properties) } @@ -181,27 +181,18 @@ func RustBindgenHostFactory() android.Module { } func NewRustBindgen(hod android.HostOrDeviceSupported) (*Module, *bindgenDecorator) { - module := newModule(hod, android.MultilibBoth) - bindgen := &bindgenDecorator{ - baseSourceProvider: NewSourceProvider(), + BaseSourceProvider: NewSourceProvider(), Properties: BindgenProperties{}, } - _, library := NewRustLibrary(hod) - library.BuildOnlyRust() - library.setNoLint() - library.sourceProvider = bindgen - - module.sourceProvider = bindgen - module.compiler = library - module.setClippy(false) + module := NewSourceProviderModule(hod, bindgen, false) return module, bindgen } -func (b *bindgenDecorator) sourceProviderDeps(ctx DepsContext, deps Deps) Deps { - deps = b.baseSourceProvider.sourceProviderDeps(ctx, deps) +func (b *bindgenDecorator) SourceProviderDeps(ctx DepsContext, deps Deps) Deps { + deps = b.BaseSourceProvider.SourceProviderDeps(ctx, deps) if ctx.toolchain().Bionic() { deps = bionicDeps(deps) } -- cgit v1.2.3-59-g8ed1b