Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0617b26f authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add AllMetadataFiles() method to track deps." am: 904dd87a am: 389f4adf

parents ee1ab966 389f4adf
Loading
Loading
Loading
Loading
+30 −1
Original line number Original line Diff line number Diff line
@@ -118,6 +118,7 @@ func (pm *ProjectMetadata) UrlsByTypeName() ProjectUrlMap {
// a `ProjectMetadata`, pm (can be nil even without error), or a non-nil `err`.
// a `ProjectMetadata`, pm (can be nil even without error), or a non-nil `err`.
type projectIndex struct {
type projectIndex struct {
	project string
	project string
	path    string
	pm      *ProjectMetadata
	pm      *ProjectMetadata
	err     error
	err     error
	done    chan struct{}
	done    chan struct{}
@@ -230,6 +231,19 @@ func (ix *Index) MetadataForProjects(projects ...string) ([]*ProjectMetadata, er
	return result, nil
	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`.
// readMetadataFile tries to read and parse a METADATA file at `path` for `project`.
func (ix *Index) readMetadataFile(pi *projectIndex, path string) {
func (ix *Index) readMetadataFile(pi *projectIndex, path string) {
	f, err := ix.rootFS.Open(path)
	f, err := ix.rootFS.Open(path)
@@ -250,9 +264,24 @@ func (ix *Index) readMetadataFile(pi *projectIndex, path string) {
	pm := &ProjectMetadata{project: pi.project}
	pm := &ProjectMetadata{project: pi.project}
	err = uo.Unmarshal(data, &pm.proto)
	err = uo.Unmarshal(data, &pm.proto)
	if err != nil {
	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
		return
	}
	}


	pi.path = path
	pi.pm = pm
	pi.pm = pm
}
}