relax the restriction on .proto files in data

Context: yaqs/7447701439926763520#a1

Bug: b/339454115
Test: go test
Change-Id: If3ed81334a192993d32404301b55ca7b4f5780ae
This commit is contained in:
Raphael Blistein
2024-05-08 16:15:53 +00:00
parent d02d710570
commit 5985846f29
2 changed files with 11 additions and 11 deletions

View File

@@ -506,8 +506,8 @@ func (p *PythonLibraryModule) genModulePathMappings(ctx android.ModuleContext, p
} }
for _, d := range expandedData { for _, d := range expandedData {
if d.Ext() == pyExt || d.Ext() == protoExt { if d.Ext() == pyExt {
ctx.PropertyErrorf("data", "found (.py|.proto) file: %q!", d.String()) ctx.PropertyErrorf("data", "found (.py) file: %q!", d.String())
continue continue
} }
runfilesPath := filepath.Join(pkgPath, d.Rel()) runfilesPath := filepath.Join(pkgPath, d.Rel())
@@ -523,19 +523,19 @@ func (p *PythonLibraryModule) createSrcsZip(ctx android.ModuleContext, pkgPath s
relativeRootMap := make(map[string]android.Paths) relativeRootMap := make(map[string]android.Paths)
var protoSrcs android.Paths var protoSrcs android.Paths
addPathMapping := func(path pathMapping) { addPathMapping := func(path pathMapping) {
// handle proto sources separately relativeRoot := strings.TrimSuffix(path.src.String(), path.src.Rel())
if path.src.Ext() == protoExt { relativeRootMap[relativeRoot] = append(relativeRootMap[relativeRoot], path.src)
protoSrcs = append(protoSrcs, path.src)
} else {
relativeRoot := strings.TrimSuffix(path.src.String(), path.src.Rel())
relativeRootMap[relativeRoot] = append(relativeRootMap[relativeRoot], path.src)
}
} }
// "srcs" or "data" properties may contain filegroups so it might happen that // "srcs" or "data" properties may contain filegroups so it might happen that
// the root directory for each source path is different. // the root directory for each source path is different.
for _, path := range p.srcsPathMappings { for _, path := range p.srcsPathMappings {
addPathMapping(path) // handle proto sources separately
if path.src.Ext() == protoExt {
protoSrcs = append(protoSrcs, path.src)
} else {
addPathMapping(path)
}
} }
for _, path := range p.dataPathMappings { for _, path := range p.dataPathMappings {
addPathMapping(path) addPathMapping(path)

View File

@@ -50,7 +50,7 @@ var (
" Second file: in module %s at path %q." " Second file: in module %s at path %q."
noSrcFileErr = moduleVariantErrTemplate + "doesn't have any source files!" noSrcFileErr = moduleVariantErrTemplate + "doesn't have any source files!"
badSrcFileExtErr = moduleVariantErrTemplate + "srcs: found non (.py|.proto) file: %q!" badSrcFileExtErr = moduleVariantErrTemplate + "srcs: found non (.py|.proto) file: %q!"
badDataFileExtErr = moduleVariantErrTemplate + "data: found (.py|.proto) file: %q!" badDataFileExtErr = moduleVariantErrTemplate + "data: found (.py) file: %q!"
bpFile = "Android.bp" bpFile = "Android.bp"
data = []struct { data = []struct {