Use OutputFilesProvider in module_test

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: Iaf0b039b17d34e1a696f2c87df2f0db39307fc6d
This commit is contained in:
mrziwang
2024-07-12 12:26:34 -07:00
parent 50fe598e79
commit 1ea01e3c59
2 changed files with 107 additions and 54 deletions

View File

@@ -2491,18 +2491,9 @@ func outputFilesForModule(ctx PathContext, module blueprint.Module, tag string)
if outputFilesFromProvider != nil || err != OutputFilesProviderNotSet {
return outputFilesFromProvider, err
}
// TODO: add error when outputFilesFromProvider and err are both nil after
// OutputFileProducer and SourceFileProducer are deprecated.
if outputFileProducer, ok := module.(OutputFileProducer); ok {
paths, err := outputFileProducer.OutputFiles(tag)
if err != nil {
return nil, fmt.Errorf("failed to get output file from module %q at tag %q: %s",
pathContextName(ctx, module), tag, err.Error())
}
return paths, nil
} else if sourceFileProducer, ok := module.(SourceFileProducer); ok {
if sourceFileProducer, ok := module.(SourceFileProducer); ok {
if tag != "" {
return nil, fmt.Errorf("module %q is a SourceFileProducer, not an OutputFileProducer, and so does not support tag %q", pathContextName(ctx, module), tag)
return nil, fmt.Errorf("module %q is a SourceFileProducer, which does not support tag %q", pathContextName(ctx, module), tag)
}
paths := sourceFileProducer.Srcs()
return paths, nil
@@ -2521,7 +2512,12 @@ func outputFilesForModuleFromProvider(ctx PathContext, module blueprint.Module,
var outputFiles OutputFilesInfo
fromProperty := false
if mctx, isMctx := ctx.(ModuleContext); isMctx {
type OutputFilesProviderModuleContext interface {
OtherModuleProviderContext
Module() Module
}
if mctx, isMctx := ctx.(OutputFilesProviderModuleContext); isMctx {
if mctx.Module() != module {
outputFiles, _ = OtherModuleProvider(mctx, module, OutputFilesProvider)
} else {
@@ -2535,7 +2531,6 @@ func outputFilesForModuleFromProvider(ctx PathContext, module blueprint.Module,
// TODO: Add a check for skipped context
if outputFiles.isEmpty() {
// TODO: Add a check for param module not having OutputFilesProvider set
return nil, OutputFilesProviderNotSet
}