added '--full-clean' flag
This commit is contained in:
parent
a21ff16308
commit
993bf58ecd
2 changed files with 22 additions and 15 deletions
8
main.go
8
main.go
|
@ -18,6 +18,7 @@ var (
|
|||
all bool
|
||||
buildFlag bool
|
||||
clean bool
|
||||
fullClean bool
|
||||
update bool
|
||||
prePatch bool
|
||||
postPatch bool
|
||||
|
@ -53,7 +54,8 @@ func init() {
|
|||
flag.StringVar(&platform, "platform", runtime.GOOS, "Platform (default: system platform)")
|
||||
flag.BoolVar(&all, "a", false, "Perform all steps (build, clean, update)")
|
||||
flag.BoolVar(&buildFlag, "b", false, "Build Spitfire")
|
||||
flag.BoolVar(&clean, "clean", false, "Clean build")
|
||||
flag.BoolVar(&clean, "clean", false, "Revert uncommitted changes without removing build artifacts")
|
||||
flag.BoolVar(&fullClean, "full-clean", false, "Perform a full clean by removing all build artifacts (clobber)")
|
||||
flag.BoolVar(&update, "u", false, "Update Mozilla repository")
|
||||
flag.BoolVar(&prePatch, "pre-patch", false, "Apply pre-build patches")
|
||||
flag.BoolVar(&postPatch, "post-patch", false, "Apply post-build patches")
|
||||
|
@ -172,7 +174,7 @@ func BuildProcess() {
|
|||
if all {
|
||||
spitfire.DownloadSource(sourcePath, sourceRepo)
|
||||
spitfire.DiscardChanges(sourcePath)
|
||||
spitfire.CleanBuild(sourcePath)
|
||||
spitfire.CleanBuild(sourcePath, fullClean)
|
||||
spitfire.UpdateRepo(sourcePath)
|
||||
if err := spitfire.ApplyPatches(sourcePath, patchesRepo, "pre-compile-patches", filepath.Join(sourcePath, "patcher"), skipPatchUpdate); err != nil {
|
||||
log.Fatalf("Error during patch application: %v", err)
|
||||
|
@ -204,7 +206,7 @@ func BuildProcess() {
|
|||
}
|
||||
fmt.Println("Spitfire build completed successfully.")
|
||||
} else if clean {
|
||||
spitfire.CleanBuild(sourcePath)
|
||||
spitfire.CleanBuild(sourcePath, fullClean)
|
||||
fmt.Println("Cleaned Firefox build.")
|
||||
} else if update {
|
||||
spitfire.DownloadSource(sourcePath, sourceRepo)
|
||||
|
|
|
@ -79,28 +79,33 @@ func DiscardChanges(sourcePath string) {
|
|||
}
|
||||
|
||||
// Function to clean build
|
||||
func CleanBuild(sourcePath string) {
|
||||
func CleanBuild(sourcePath string, fullClean bool) {
|
||||
fmt.Println("Cleaning build...")
|
||||
|
||||
if err := os.Chdir(sourcePath); err != nil {
|
||||
errors = append(errors, "Failed to navigate to source directory.")
|
||||
return
|
||||
}
|
||||
|
||||
// Use the appropriate mach command for Windows or Unix-like systems
|
||||
var machCmd string
|
||||
if runtime.GOOS == "windows" {
|
||||
machCmd = ".\\mach"
|
||||
} else {
|
||||
machCmd = "./mach"
|
||||
}
|
||||
|
||||
// Revert uncommitted changes
|
||||
if err := runCommand("hg", "revert", "--all", "--no-backup"); err != nil {
|
||||
errors = append(errors, "Failed to revert changes in Mozilla repository.")
|
||||
}
|
||||
// Clean the build
|
||||
if err := runCommand(machCmd, "clobber"); err != nil {
|
||||
errors = append(errors, "Failed to clean build.")
|
||||
|
||||
if fullClean {
|
||||
// Perform full clean if specified
|
||||
var machCmd string
|
||||
if runtime.GOOS == "windows" {
|
||||
machCmd = ".\\mach"
|
||||
} else {
|
||||
machCmd = "./mach"
|
||||
}
|
||||
|
||||
if err := runCommand(machCmd, "clobber"); err != nil {
|
||||
errors = append(errors, "Failed to clean build.")
|
||||
}
|
||||
} else {
|
||||
fmt.Println("Skipping full clean. Build artifacts remain intact.")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue