Use OutputFilesProvider on buildinfo_prop and some android test modules
In the context of incremental soong, the output files
inter-module-communication will be through OutputFilesProvider.
The OutputFileProducer interface will be deprecated.
Test: CI
Bug: 339477385
Change-Id: Ic0c1217f3651b14ae3ac58a0ce4a25e8ab8d4dda
diff --git a/android/androidmk_test.go b/android/androidmk_test.go
index ae2187f..72b8654 100644
--- a/android/androidmk_test.go
+++ b/android/androidmk_test.go
@@ -36,10 +36,6 @@
data AndroidMkData
distFiles TaggedDistFiles
outputFile OptionalPath
-
- // The paths that will be used as the default dist paths if no tag is
- // specified.
- defaultDistPaths Paths
}
const (
@@ -51,6 +47,7 @@
func (m *customModule) GenerateAndroidBuildActions(ctx ModuleContext) {
m.base().licenseMetadataFile = PathForOutput(ctx, "meta_lic")
+ var defaultDistPaths Paths
// If the dist_output_file: true then create an output file that is stored in
// the OutputFile property of the AndroidMkEntry.
@@ -62,7 +59,7 @@
// property in AndroidMkEntry when determining the default dist paths.
// Setting this first allows it to be overridden based on the
// default_dist_files setting replicating that previous behavior.
- m.defaultDistPaths = Paths{path}
+ defaultDistPaths = Paths{path}
}
// Based on the setting of the default_dist_files property possibly create a
@@ -71,29 +68,40 @@
defaultDistFiles := proptools.StringDefault(m.properties.Default_dist_files, defaultDistFiles_Tagged)
switch defaultDistFiles {
case defaultDistFiles_None:
- // Do nothing
+ m.setOutputFiles(ctx, defaultDistPaths)
case defaultDistFiles_Default:
path := PathForTesting("default-dist.out")
- m.defaultDistPaths = Paths{path}
+ defaultDistPaths = Paths{path}
+ m.setOutputFiles(ctx, defaultDistPaths)
m.distFiles = MakeDefaultDistFiles(path)
case defaultDistFiles_Tagged:
// Module types that set AndroidMkEntry.DistFiles to the result of calling
// GenerateTaggedDistFiles(ctx) relied on no tag being treated as "" which
- // meant that the default dist paths would be whatever was returned by
- // OutputFiles(""). In order to preserve that behavior when treating no tag
- // as being equal to DefaultDistTag this ensures that
- // OutputFiles(DefaultDistTag) will return the same as OutputFiles("").
- m.defaultDistPaths = PathsForTesting("one.out")
+ // meant that the default dist paths would be the same as empty-string-tag
+ // output files. In order to preserve that behavior when treating no tag
+ // as being equal to DefaultDistTag this ensures that DefaultDistTag output
+ // will be the same as empty-string-tag output.
+ defaultDistPaths = PathsForTesting("one.out")
+ m.setOutputFiles(ctx, defaultDistPaths)
// This must be called after setting defaultDistPaths/outputFile as
- // GenerateTaggedDistFiles calls into OutputFiles(tag) which may use those
- // fields.
+ // GenerateTaggedDistFiles calls into outputFiles property which may use
+ // those fields.
m.distFiles = m.GenerateTaggedDistFiles(ctx)
}
}
+func (m *customModule) setOutputFiles(ctx ModuleContext, defaultDistPaths Paths) {
+ ctx.SetOutputFiles(PathsForTesting("one.out"), "")
+ ctx.SetOutputFiles(PathsForTesting("two.out", "three/four.out"), ".multiple")
+ ctx.SetOutputFiles(PathsForTesting("another.out"), ".another-tag")
+ if defaultDistPaths != nil {
+ ctx.SetOutputFiles(defaultDistPaths, DefaultDistTag)
+ }
+}
+
func (m *customModule) AndroidMk() AndroidMkData {
return AndroidMkData{
Custom: func(w io.Writer, name, prefix, moduleDir string, data AndroidMkData) {
@@ -102,25 +110,6 @@
}
}
-func (m *customModule) OutputFiles(tag string) (Paths, error) {
- switch tag {
- case DefaultDistTag:
- if m.defaultDistPaths != nil {
- return m.defaultDistPaths, nil
- } else {
- return nil, fmt.Errorf("default dist tag is not available")
- }
- case "":
- return PathsForTesting("one.out"), nil
- case ".multiple":
- return PathsForTesting("two.out", "three/four.out"), nil
- case ".another-tag":
- return PathsForTesting("another.out"), nil
- default:
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
- }
-}
-
func (m *customModule) AndroidMkEntries() []AndroidMkEntries {
return []AndroidMkEntries{
{