diff options
author | 2020-07-31 13:40:31 -0400 | |
---|---|---|
committer | 2020-08-04 08:13:24 -0400 | |
commit | 26ecd6c5974fcd3ec09792394e7b9cdf32f5f64f (patch) | |
tree | 19a888dd32d382a9a26abea71e5965fc9ab19154 /rust/source_provider.go | |
parent | d118b1c2b74a1028f86f570db602a3b39e2009e1 (diff) |
[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
Diffstat (limited to 'rust/source_provider.go')
-rw-r--r-- | rust/source_provider.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/rust/source_provider.go b/rust/source_provider.go index da6147a15..8bb784951 100644 --- a/rust/source_provider.go +++ b/rust/source_provider.go @@ -19,8 +19,13 @@ import ( ) type SourceProviderProperties struct { - // sets name of the output - Stem *string `android:"arch_variant"` + // name for the generated source file. Defaults to module name (e.g. moduleNameFoo.rs is produced by default). + // Importantly, the inherited "stem" property for this module sets the output filename for the generated library + // variants only + Source_stem *string `android:"arch_variant"` + + // crate name, used for the library variant of this source provider. See additional details in rust_library. + Crate_name string `android:"arch_variant"` } type baseSourceProvider struct { @@ -28,6 +33,7 @@ type baseSourceProvider struct { outputFile android.Path subAndroidMkOnce map[subAndroidMkProvider]bool + subName string } var _ SourceProvider = (*baseSourceProvider)(nil) @@ -37,6 +43,7 @@ type SourceProvider interface { Srcs() android.Paths sourceProviderProps() []interface{} sourceProviderDeps(ctx DepsContext, deps Deps) Deps + setSubName(subName string) } func (sp *baseSourceProvider) Srcs() android.Paths { @@ -59,8 +66,8 @@ func NewSourceProvider() *baseSourceProvider { func (sp *baseSourceProvider) getStem(ctx android.ModuleContext) string { stem := ctx.ModuleName() - if String(sp.Properties.Stem) != "" { - stem = String(sp.Properties.Stem) + if String(sp.Properties.Source_stem) != "" { + stem = String(sp.Properties.Source_stem) } return stem } @@ -68,3 +75,7 @@ func (sp *baseSourceProvider) getStem(ctx android.ModuleContext) string { func (sp *baseSourceProvider) sourceProviderDeps(ctx DepsContext, deps Deps) Deps { return deps } + +func (sp *baseSourceProvider) setSubName(subName string) { + sp.subName = subName +} |