Go: overlay workaround for cgo-processed files

This commit is contained in:
Nick Rolfe
2025-09-24 16:38:13 +01:00
parent 5aaed8941a
commit 50e01283da
2 changed files with 25 additions and 3 deletions

View File

@@ -732,8 +732,13 @@ func (extraction *Extraction) extractFile(ast *ast.File, pkg *packages.Package)
return nil
}
path := normalizedPath(ast, fset)
if extraction.OverlayChanges != nil && !extraction.OverlayChanges[path] {
// This file did not change since the base was extracted
// If we're extracting an overlay, we want to skip extraction of files that haven't changed.
// Since some files may be outside the source directory (e.g. files preprocessed by cgo) we
// can't easily know if they have changed (or came from source files that changed), so we always
// extract a file if it's not in the package directory.
if extraction.OverlayChanges != nil &&
!extraction.OverlayChanges[path] &&
strings.HasPrefix(path+string(filepath.Separator), pkg.Dir) {
return nil
}