diff --git a/spitfire/build.go b/spitfire/build.go index 4fc0e34..41d1da5 100644 --- a/spitfire/build.go +++ b/spitfire/build.go @@ -92,8 +92,22 @@ func CleanBuild(sourcePath string, fullClean bool) { errors = append(errors, "Failed to revert changes in Mozilla repository.") } - if fullClean { - // Perform full clean if specified + // Paths for CLOBBER file and last build timestamp + clobberFile := filepath.Join(sourcePath, "obj-x86_64-pc-windows-msvc", "CLOBBER") + buildTimestampFile := filepath.Join(sourcePath, "obj-x86_64-pc-windows-msvc", ".last_build_timestamp") + + // Check if a clobber is required + clobberRequired := false + if _, err := os.Stat(clobberFile); err == nil { + clobberFileInfo, _ := os.Stat(clobberFile) + if buildInfo, err := os.Stat(buildTimestampFile); err != nil || clobberFileInfo.ModTime().After(buildInfo.ModTime()) { + clobberRequired = true + fmt.Println("CLOBBER file has been updated. Clobber is required.") + } + } + + if fullClean || clobberRequired { + // Perform full clean or clobber if necessary var machCmd string if runtime.GOOS == "windows" { machCmd = ".\\mach" @@ -103,6 +117,8 @@ func CleanBuild(sourcePath string, fullClean bool) { if err := runCommand(machCmd, "clobber"); err != nil { errors = append(errors, "Failed to clean build.") + } else { + fmt.Println("Build artifacts cleaned successfully.") } } else { fmt.Println("Skipping full clean. Build artifacts remain intact.")