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
This commit is contained in:
Andrei Homescu
2020-08-05 06:36:19 -07:00
parent d13b308960
commit c7767922e0
4 changed files with 62 additions and 54 deletions

View File

@@ -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)
}