Add SourceProviders and a rust_bindgen module type
Add SourceProvider modules which provides a base interface for more complex code generation usecases such as bindgen. Also adds the rust_bindgen module type which calls bindgen to generate Rust FFI bindings to C. Bug: 159064919 Test: Local test module generates bindings. Test: New Soong tests pass. Change-Id: Ie31467bbbe423497666ad837cf5fe1acd1e76bd8
This commit is contained in:
14
rust/rust.go
14
rust/rust.go
@@ -42,6 +42,7 @@ func init() {
|
||||
ctx.BottomUp("rust_begin", BeginMutator).Parallel()
|
||||
})
|
||||
pctx.Import("android/soong/rust/config")
|
||||
pctx.ImportAs("ccConfig", "android/soong/cc/config")
|
||||
}
|
||||
|
||||
type Flags struct {
|
||||
@@ -79,8 +80,11 @@ type Module struct {
|
||||
coverage *coverage
|
||||
clippy *clippy
|
||||
cachedToolchain config.Toolchain
|
||||
sourceProvider SourceProvider
|
||||
subAndroidMkOnce map[subAndroidMkProvider]bool
|
||||
outputFile android.OptionalPath
|
||||
|
||||
subName string
|
||||
}
|
||||
|
||||
var _ android.ImageInterface = (*Module)(nil)
|
||||
@@ -348,6 +352,7 @@ func DefaultsFactory(props ...interface{}) android.Module {
|
||||
&LibraryCompilerProperties{},
|
||||
&ProcMacroCompilerProperties{},
|
||||
&PrebuiltProperties{},
|
||||
&SourceProviderProperties{},
|
||||
&TestProperties{},
|
||||
&cc.CoverageProperties{},
|
||||
&ClippyProperties{},
|
||||
@@ -507,6 +512,9 @@ func (mod *Module) Init() android.Module {
|
||||
if mod.clippy != nil {
|
||||
mod.AddProperties(mod.clippy.props()...)
|
||||
}
|
||||
if mod.sourceProvider != nil {
|
||||
mod.AddProperties(mod.sourceProvider.sourceProviderProps()...)
|
||||
}
|
||||
|
||||
android.InitAndroidArchModule(mod, mod.hod, mod.multilib)
|
||||
|
||||
@@ -645,6 +653,10 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
|
||||
if !mod.Properties.PreventInstall {
|
||||
mod.compiler.install(ctx, mod.outputFile.Path())
|
||||
}
|
||||
} else if mod.sourceProvider != nil {
|
||||
outputFile := mod.sourceProvider.generateSource(ctx)
|
||||
mod.outputFile = android.OptionalPathForPath(outputFile)
|
||||
mod.subName = ctx.ModuleSubDir()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -653,6 +665,8 @@ func (mod *Module) deps(ctx DepsContext) Deps {
|
||||
|
||||
if mod.compiler != nil {
|
||||
deps = mod.compiler.compilerDeps(ctx, deps)
|
||||
} else if mod.sourceProvider != nil {
|
||||
deps = mod.sourceProvider.sourceProviderDeps(ctx, deps)
|
||||
}
|
||||
|
||||
if mod.coverage != nil {
|
||||
|
Reference in New Issue
Block a user