Add source file provider for genrule/srcs, python libraries and rust libraries.

Change-Id: I2d7d4684a10c15aeecc27b8db800ab27a807d2e2
This commit is contained in:
Aditya Choudhary 2023-11-29 16:42:42 +00:00
parent 8094b6bf9d
commit 26df39fe44
13 changed files with 19 additions and 22 deletions

View file

@ -93,7 +93,6 @@ bootstrap_go_package {
"singleton.go", "singleton.go",
"singleton_module.go", "singleton_module.go",
"soong_config_modules.go", "soong_config_modules.go",
"source_file_provider.go",
"test_asserts.go", "test_asserts.go",
"test_suites.go", "test_suites.go",
"testing.go", "testing.go",

View file

@ -290,6 +290,7 @@ func (fg *fileGroup) GenerateAndroidBuildActions(ctx ModuleContext) {
if fg.properties.Path != nil { if fg.properties.Path != nil {
fg.srcs = PathsWithModuleSrcSubDir(ctx, fg.srcs, String(fg.properties.Path)) fg.srcs = PathsWithModuleSrcSubDir(ctx, fg.srcs, String(fg.properties.Path))
} }
ctx.SetProvider(blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: fg.srcs.Strings()})
} }
func (fg *fileGroup) Srcs() Paths { func (fg *fileGroup) Srcs() Paths {

View file

@ -1,11 +0,0 @@
package android
import (
"github.com/google/blueprint"
)
type SrcsFileProviderData struct {
SrcPaths Paths
}
var SrcsFileProviderKey = blueprint.NewProvider(SrcsFileProviderData{})

View file

@ -206,6 +206,7 @@ func (bpf *bpf) GenerateAndroidBuildActions(ctx android.ModuleContext) {
} }
} }
ctx.SetProvider(blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: srcs.Strings()})
} }
func (bpf *bpf) AndroidMk() android.AndroidMkData { func (bpf *bpf) AndroidMk() android.AndroidMkData {

View file

@ -2322,6 +2322,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
if c.testModule { if c.testModule {
ctx.SetProvider(testing.TestModuleProviderKey, testing.TestModuleProviderData{}) ctx.SetProvider(testing.TestModuleProviderKey, testing.TestModuleProviderData{})
} }
ctx.SetProvider(blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: deps.GeneratedSources.Strings()})
aconfig.CollectTransitiveAconfigFiles(ctx, &c.transitiveAconfigFiles) aconfig.CollectTransitiveAconfigFiles(ctx, &c.transitiveAconfigFiles)

View file

@ -424,6 +424,7 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) {
return srcFiles return srcFiles
} }
srcFiles := addLabelsForInputs("srcs", g.properties.Srcs, g.properties.Exclude_srcs) srcFiles := addLabelsForInputs("srcs", g.properties.Srcs, g.properties.Exclude_srcs)
ctx.SetProvider(blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: srcFiles.Strings()})
var copyFrom android.Paths var copyFrom android.Paths
var outputFiles android.WritablePaths var outputFiles android.WritablePaths

View file

@ -24,6 +24,7 @@ import (
"github.com/google/blueprint/pathtools" "github.com/google/blueprint/pathtools"
"github.com/google/blueprint/proptools" "github.com/google/blueprint/proptools"
"github.com/google/blueprint"
"android/soong/aconfig" "android/soong/aconfig"
"android/soong/android" "android/soong/android"
@ -1170,6 +1171,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
uniqueSrcFiles = append(uniqueSrcFiles, uniqueJavaFiles...) uniqueSrcFiles = append(uniqueSrcFiles, uniqueJavaFiles...)
uniqueSrcFiles = append(uniqueSrcFiles, uniqueKtFiles...) uniqueSrcFiles = append(uniqueSrcFiles, uniqueKtFiles...)
j.uniqueSrcFiles = uniqueSrcFiles j.uniqueSrcFiles = uniqueSrcFiles
ctx.SetProvider(blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: uniqueSrcFiles.Strings()})
// We don't currently run annotation processors in turbine, which means we can't use turbine // We don't currently run annotation processors in turbine, which means we can't use turbine
// generated header jars when an annotation processor that generates API is enabled. One // generated header jars when an annotation processor that generates API is enabled. One

View file

@ -1477,7 +1477,6 @@ func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
} }
} }
ctx.SetProvider(android.AdditionalSdkInfoProvider, android.AdditionalSdkInfo{additionalSdkInfo}) ctx.SetProvider(android.AdditionalSdkInfoProvider, android.AdditionalSdkInfo{additionalSdkInfo})
ctx.SetProvider(android.SrcsFileProviderKey, android.SrcsFileProviderData{SrcPaths: module.uniqueSrcFiles})
} }
func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries { func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries {

View file

@ -430,6 +430,7 @@ func (p *PythonLibraryModule) AddDepsOnPythonLauncherAndStdlib(ctx android.Botto
// GenerateAndroidBuildActions performs build actions common to all Python modules // GenerateAndroidBuildActions performs build actions common to all Python modules
func (p *PythonLibraryModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { func (p *PythonLibraryModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
expandedSrcs := android.PathsForModuleSrcExcludes(ctx, p.properties.Srcs, p.properties.Exclude_srcs) expandedSrcs := android.PathsForModuleSrcExcludes(ctx, p.properties.Srcs, p.properties.Exclude_srcs)
ctx.SetProvider(blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: expandedSrcs.Strings()})
// expand data files from "data" property. // expand data files from "data" property.
expandedData := android.PathsForModuleSrc(ctx, p.properties.Data) expandedData := android.PathsForModuleSrc(ctx, p.properties.Data)

View file

@ -951,6 +951,7 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
sourceLib := sourceMod.(*Module).compiler.(*libraryDecorator) sourceLib := sourceMod.(*Module).compiler.(*libraryDecorator)
mod.sourceProvider.setOutputFiles(sourceLib.sourceProvider.Srcs()) mod.sourceProvider.setOutputFiles(sourceLib.sourceProvider.Srcs())
} }
ctx.SetProvider(blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: mod.sourceProvider.Srcs().Strings()})
} }
if mod.compiler != nil && !mod.compiler.Disabled() { if mod.compiler != nil && !mod.compiler.Disabled() {

View file

@ -272,6 +272,7 @@ func (s *ShBinary) generateAndroidBuildActions(ctx android.ModuleContext) {
Output: s.outputFilePath, Output: s.outputFilePath,
Input: s.sourceFilePath, Input: s.sourceFilePath,
}) })
ctx.SetProvider(blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: []string{s.sourceFilePath.String()}})
} }
func (s *ShBinary) GenerateAndroidBuildActions(ctx android.ModuleContext) { func (s *ShBinary) GenerateAndroidBuildActions(ctx android.ModuleContext) {

View file

@ -254,12 +254,13 @@ func (m *syspropLibrary) CurrentSyspropApiFile() android.OptionalPath {
// generated java_library will depend on these API files. // generated java_library will depend on these API files.
func (m *syspropLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { func (m *syspropLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
baseModuleName := m.BaseModuleName() baseModuleName := m.BaseModuleName()
srcs := android.PathsForModuleSrc(ctx, m.properties.Srcs)
for _, syspropFile := range android.PathsForModuleSrc(ctx, m.properties.Srcs) { for _, syspropFile := range srcs {
if syspropFile.Ext() != ".sysprop" { if syspropFile.Ext() != ".sysprop" {
ctx.PropertyErrorf("srcs", "srcs contains non-sysprop file %q", syspropFile.String()) ctx.PropertyErrorf("srcs", "srcs contains non-sysprop file %q", syspropFile.String())
} }
} }
ctx.SetProvider(blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: srcs.Strings()})
if ctx.Failed() { if ctx.Failed() {
return return
@ -277,7 +278,7 @@ func (m *syspropLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
rule.Command(). rule.Command().
BuiltTool("sysprop_api_dump"). BuiltTool("sysprop_api_dump").
Output(m.dumpedApiFile). Output(m.dumpedApiFile).
Inputs(android.PathsForModuleSrc(ctx, m.properties.Srcs)) Inputs(srcs)
rule.Build(baseModuleName+"_api_dump", baseModuleName+" api dump") rule.Build(baseModuleName+"_api_dump", baseModuleName+" api dump")
// check API rule // check API rule

View file

@ -95,11 +95,11 @@ func (module *CodeMetadataModule) GenerateAndroidBuildActions(ctx android.Module
for _, m := range ctx.GetDirectDepsWithTag(codeDepTag) { for _, m := range ctx.GetDirectDepsWithTag(codeDepTag) {
targetName := m.Name() targetName := m.Name()
var moduleSrcs android.Paths var moduleSrcs []string
if ctx.OtherModuleHasProvider(m, android.SrcsFileProviderKey) { if ctx.OtherModuleHasProvider(m, blueprint.SrcsFileProviderKey) {
moduleSrcs = ctx.OtherModuleProvider( moduleSrcs = ctx.OtherModuleProvider(
m, android.SrcsFileProviderKey, m, blueprint.SrcsFileProviderKey,
).(android.SrcsFileProviderData).SrcPaths ).(blueprint.SrcsFileProviderData).SrcPaths
} }
if module.properties.MultiOwnership { if module.properties.MultiOwnership {
metadata := &code_metadata_internal_proto.CodeMetadataInternal_TargetOwnership{ metadata := &code_metadata_internal_proto.CodeMetadataInternal_TargetOwnership{
@ -107,7 +107,7 @@ func (module *CodeMetadataModule) GenerateAndroidBuildActions(ctx android.Module
TrendyTeamId: &module.properties.TeamId, TrendyTeamId: &module.properties.TeamId,
Path: &bpFilePath, Path: &bpFilePath,
MultiOwnership: &module.properties.MultiOwnership, MultiOwnership: &module.properties.MultiOwnership,
SourceFiles: moduleSrcs.Strings(), SourceFiles: moduleSrcs,
} }
metadataList = append(metadataList, metadata) metadataList = append(metadataList, metadata)
} else { } else {
@ -115,7 +115,7 @@ func (module *CodeMetadataModule) GenerateAndroidBuildActions(ctx android.Module
TargetName: &targetName, TargetName: &targetName,
TrendyTeamId: &module.properties.TeamId, TrendyTeamId: &module.properties.TeamId,
Path: &bpFilePath, Path: &bpFilePath,
SourceFiles: moduleSrcs.Strings(), SourceFiles: moduleSrcs,
} }
metadataList = append(metadataList, metadata) metadataList = append(metadataList, metadata)
} }