summaryrefslogtreecommitdiff
path: root/rust/bindgen.go
diff options
context:
space:
mode:
author Ivan Lozano <ivanlozano@google.com> 2020-07-31 13:40:31 -0400
committer Ivan Lozano <ivanlozano@google.com> 2020-08-04 08:13:24 -0400
commit26ecd6c5974fcd3ec09792394e7b9cdf32f5f64f (patch)
tree19a888dd32d382a9a26abea71e5965fc9ab19154 /rust/bindgen.go
parentd118b1c2b74a1028f86f570db602a3b39e2009e1 (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/bindgen.go')
-rw-r--r--rust/bindgen.go10
1 files changed, 8 insertions, 2 deletions
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
}