Make removing abandoned files optional

Build logic can now implement a RemoveAbandonedFiles, and the bootstrap
logic will only remove abandoned files if that method returns true.
Leaving the method unimplemented will result in the existing behavior of
always removing abandoned files.
This commit is contained in:
Colin Cross 2015-11-17 16:16:58 -08:00
parent e6006362da
commit 6d529f0e16
2 changed files with 12 additions and 4 deletions

View file

@ -161,10 +161,12 @@ func Main(ctx *blueprint.Context, config interface{}, extraNinjaFileDeps ...stri
}
}
srcDir := filepath.Dir(bootstrapConfig.topLevelBlueprintsFile)
err = removeAbandonedFiles(ctx, bootstrapConfig, srcDir, manifestFile)
if err != nil {
fatalf("error removing abandoned files: %s", err)
if c, ok := config.(ConfigRemoveAbandonedFiles); !ok || c.RemoveAbandonedFiles() {
srcDir := filepath.Dir(bootstrapConfig.topLevelBlueprintsFile)
err := removeAbandonedFiles(ctx, bootstrapConfig, srcDir, manifestFile)
if err != nil {
fatalf("error removing abandoned files: %s", err)
}
}
}

View file

@ -38,6 +38,12 @@ type ConfigInterface interface {
GeneratingPrimaryBuilder() bool
}
type ConfigRemoveAbandonedFiles interface {
// RemoveAbandonedFiles should return true if files listed in the
// .ninja_log but not the output build.ninja file should be deleted.
RemoveAbandonedFiles() bool
}
type Stage int
const (