From 26ecd6c5974fcd3ec09792394e7b9cdf32f5f64f Mon Sep 17 00:00:00 2001 From: Ivan Lozano Date: Fri, 31 Jul 2020 13:40:31 -0400 Subject: [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 --- rust/androidmk.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'rust/androidmk.go') diff --git a/rust/androidmk.go b/rust/androidmk.go index babbf9123..580601734 100644 --- a/rust/androidmk.go +++ b/rust/androidmk.go @@ -55,7 +55,6 @@ func (mod *Module) AndroidMk() android.AndroidMkData { ret := android.AndroidMkData{ OutputFile: mod.outputFile, Include: "$(BUILD_SYSTEM)/soong_rust_prebuilt.mk", - SubName: mod.subName, Extra: []android.AndroidMkExtraFunc{ func(w io.Writer, outputFile android.Path) { if len(mod.Properties.AndroidMkRlibs) > 0 { @@ -76,9 +75,11 @@ func (mod *Module) AndroidMk() android.AndroidMkData { }, }, } - if mod.compiler != nil { + + if mod.compiler != nil && !mod.compiler.Disabled() { mod.subAndroidMk(&ret, mod.compiler) } else if mod.sourceProvider != nil { + // If the compiler is disabled, this is a SourceProvider. mod.subAndroidMk(&ret, mod.sourceProvider) } ret.SubName += mod.Properties.SubName @@ -162,6 +163,7 @@ func (sourceProvider *baseSourceProvider) AndroidMk(ctx AndroidMkContext, ret *a outFile := sourceProvider.outputFile ret.Class = "ETC" ret.OutputFile = android.OptionalPathForPath(outFile) + ret.SubName += sourceProvider.subName ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { _, file := filepath.Split(outFile.String()) stem, suffix, _ := android.SplitFileExt(file) -- cgit v1.2.3-59-g8ed1b