Loading tools/compliance/projectmetadata/projectmetadata.go +30 −1 Original line number Diff line number Diff line Loading @@ -118,6 +118,7 @@ func (pm *ProjectMetadata) UrlsByTypeName() ProjectUrlMap { // a `ProjectMetadata`, pm (can be nil even without error), or a non-nil `err`. type projectIndex struct { project string path string pm *ProjectMetadata err error done chan struct{} Loading Loading @@ -230,6 +231,19 @@ func (ix *Index) MetadataForProjects(projects ...string) ([]*ProjectMetadata, er return result, nil } // AllMetadataFiles returns the sorted list of all METADATA files read thus far. func (ix *Index) AllMetadataFiles() []string { files := []string(nil) ix.projects.Range(func(key, value any) bool { pi := value.(*projectIndex) if pi.path != "" { files = append(files, pi.path) } return true }) return files } // readMetadataFile tries to read and parse a METADATA file at `path` for `project`. func (ix *Index) readMetadataFile(pi *projectIndex, path string) { f, err := ix.rootFS.Open(path) Loading @@ -250,9 +264,24 @@ func (ix *Index) readMetadataFile(pi *projectIndex, path string) { pm := &ProjectMetadata{project: pi.project} err = uo.Unmarshal(data, &pm.proto) if err != nil { pi.err = fmt.Errorf("error in project %q metadata %q: %w", pi.project, path, err) pi.err = fmt.Errorf(`error in project %q METADATA %q: %v METADATA and METADATA.android files must parse as text protobufs defined by build/soong/compliance/project_metadata_proto/project_metadata.proto * unknown fields don't matter * check invalid ENUM names * check quoting * check unescaped nested quotes * check the comment marker for protobuf is '#' not '//' if importing a library that uses a different sort of METADATA file, add a METADATA.android file beside it to parse instead `, pi.project, path, err) return } pi.path = path pi.pm = pm } Loading
tools/compliance/projectmetadata/projectmetadata.go +30 −1 Original line number Diff line number Diff line Loading @@ -118,6 +118,7 @@ func (pm *ProjectMetadata) UrlsByTypeName() ProjectUrlMap { // a `ProjectMetadata`, pm (can be nil even without error), or a non-nil `err`. type projectIndex struct { project string path string pm *ProjectMetadata err error done chan struct{} Loading Loading @@ -230,6 +231,19 @@ func (ix *Index) MetadataForProjects(projects ...string) ([]*ProjectMetadata, er return result, nil } // AllMetadataFiles returns the sorted list of all METADATA files read thus far. func (ix *Index) AllMetadataFiles() []string { files := []string(nil) ix.projects.Range(func(key, value any) bool { pi := value.(*projectIndex) if pi.path != "" { files = append(files, pi.path) } return true }) return files } // readMetadataFile tries to read and parse a METADATA file at `path` for `project`. func (ix *Index) readMetadataFile(pi *projectIndex, path string) { f, err := ix.rootFS.Open(path) Loading @@ -250,9 +264,24 @@ func (ix *Index) readMetadataFile(pi *projectIndex, path string) { pm := &ProjectMetadata{project: pi.project} err = uo.Unmarshal(data, &pm.proto) if err != nil { pi.err = fmt.Errorf("error in project %q metadata %q: %w", pi.project, path, err) pi.err = fmt.Errorf(`error in project %q METADATA %q: %v METADATA and METADATA.android files must parse as text protobufs defined by build/soong/compliance/project_metadata_proto/project_metadata.proto * unknown fields don't matter * check invalid ENUM names * check quoting * check unescaped nested quotes * check the comment marker for protobuf is '#' not '//' if importing a library that uses a different sort of METADATA file, add a METADATA.android file beside it to parse instead `, pi.project, path, err) return } pi.path = path pi.pm = pm }