Delete Stale Metrics Files
Test: Run `m --bazle-mode-dev nothing` again after `m --bazel-mode-dev nothing`. bp2build_metrics.pb no longer exists, the rest metrics files have the timestamp of the latest creation time. Bug: 256617990 Change-Id: I869d1b9c3abcb517744e66b21e5c12d6b5b1e97b
This commit is contained in:
@@ -110,6 +110,15 @@ func inList(s string, list []string) bool {
|
|||||||
return indexList(s, list) != -1
|
return indexList(s, list) != -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func deleteStaleMetrics(metricsFilePathSlice []string) error {
|
||||||
|
for _, metricsFilePath := range metricsFilePathSlice {
|
||||||
|
if err := os.Remove(metricsFilePath); err != nil && !os.IsNotExist(err) {
|
||||||
|
return fmt.Errorf("Failed to remove %s\nError message: %w", metricsFilePath, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Main execution of soong_ui. The command format is as follows:
|
// Main execution of soong_ui. The command format is as follows:
|
||||||
//
|
//
|
||||||
// soong_ui <command> [<arg 1> <arg 2> ... <arg n>]
|
// soong_ui <command> [<arg 1> <arg 2> ... <arg n>]
|
||||||
@@ -117,7 +126,6 @@ func inList(s string, list []string) bool {
|
|||||||
// Command is the type of soong_ui execution. Only one type of
|
// Command is the type of soong_ui execution. Only one type of
|
||||||
// execution is specified. The args are specific to the command.
|
// execution is specified. The args are specific to the command.
|
||||||
func main() {
|
func main() {
|
||||||
//TODO(juu): Add logic to soong_ui to delete a hardcoded list of metrics files
|
|
||||||
shared.ReexecWithDelveMaybe(os.Getenv("SOONG_UI_DELVE"), shared.ResolveDelveBinary())
|
shared.ReexecWithDelveMaybe(os.Getenv("SOONG_UI_DELVE"), shared.ResolveDelveBinary())
|
||||||
|
|
||||||
buildStarted := time.Now()
|
buildStarted := time.Now()
|
||||||
@@ -187,6 +195,12 @@ func main() {
|
|||||||
bp2buildMetricsFile := filepath.Join(logsDir, c.logsPrefix+"bp2build_metrics.pb")
|
bp2buildMetricsFile := filepath.Join(logsDir, c.logsPrefix+"bp2build_metrics.pb")
|
||||||
soongBuildMetricsFile := filepath.Join(logsDir, c.logsPrefix+"soong_build_metrics.pb")
|
soongBuildMetricsFile := filepath.Join(logsDir, c.logsPrefix+"soong_build_metrics.pb")
|
||||||
|
|
||||||
|
//Delete the stale metrics files
|
||||||
|
staleFileSlice := []string{buildErrorFile, rbeMetricsFile, soongMetricsFile, bp2buildMetricsFile, soongBuildMetricsFile}
|
||||||
|
if err := deleteStaleMetrics(staleFileSlice); err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
|
||||||
build.PrintOutDirWarning(buildCtx, config)
|
build.PrintOutDirWarning(buildCtx, config)
|
||||||
|
|
||||||
os.MkdirAll(logsDir, 0777)
|
os.MkdirAll(logsDir, 0777)
|
||||||
|
Reference in New Issue
Block a user