diff --git a/legacy/builder/container_find_includes.go b/legacy/builder/container_find_includes.go index 5666676c902..d7c0f90ed25 100644 --- a/legacy/builder/container_find_includes.go +++ b/legacy/builder/container_find_includes.go @@ -108,6 +108,7 @@ package builder import ( "encoding/json" + "fmt" "os" "os/exec" "time" @@ -196,19 +197,28 @@ type includeCacheEntry struct { Includepath *paths.Path } +func (entry *includeCacheEntry) String() string { + return fmt.Sprintf("SourceFile: %s; Include: %s; IncludePath: %s", + entry.Sourcefile, entry.Include, entry.Includepath) +} + +func (entry *includeCacheEntry) Equals(other *includeCacheEntry) bool { + return entry.String() == other.String() +} + type includeCache struct { // Are the cache contents valid so far? valid bool // Index into entries of the next entry to be processed. Unused // when the cache is invalid. next int - entries []includeCacheEntry + entries []*includeCacheEntry } // Return the next cache entry. Should only be called when the cache is // valid and a next entry is available (the latter can be checked with // ExpectFile). Does not advance the cache. -func (cache *includeCache) Next() includeCacheEntry { +func (cache *includeCache) Next() *includeCacheEntry { return cache.entries[cache.next] } @@ -227,9 +237,9 @@ func (cache *includeCache) ExpectFile(sourcefile *paths.Path) { // invalidated, or was already invalid, an entry with the given values // is appended. func (cache *includeCache) ExpectEntry(sourcefile *paths.Path, include string, librarypath *paths.Path) { - entry := includeCacheEntry{Sourcefile: sourcefile, Include: include, Includepath: librarypath} + entry := &includeCacheEntry{Sourcefile: sourcefile, Include: include, Includepath: librarypath} if cache.valid { - if cache.next < len(cache.entries) && cache.Next() == entry { + if cache.next < len(cache.entries) && cache.Next().Equals(entry) { cache.next++ } else { cache.valid = false