removed '--patches' flag, added '--pre-patch', '--post-patch', '--skip-patch-update'
This commit is contained in:
parent
f497ac9999
commit
ad7f7bf778
2 changed files with 65 additions and 32 deletions
28
main.go
28
main.go
|
@ -19,7 +19,9 @@ var (
|
|||
buildFlag bool
|
||||
clean bool
|
||||
update bool
|
||||
patches bool
|
||||
prePatch bool
|
||||
postPatch bool
|
||||
skipPatchUpdate bool
|
||||
run bool
|
||||
compress bool
|
||||
buildPath string
|
||||
|
@ -53,7 +55,9 @@ func init() {
|
|||
flag.BoolVar(&buildFlag, "b", false, "Build Spitfire")
|
||||
flag.BoolVar(&clean, "clean", false, "Clean build")
|
||||
flag.BoolVar(&update, "u", false, "Update Mozilla repository")
|
||||
flag.BoolVar(&patches, "patches", false, "Update patches")
|
||||
flag.BoolVar(&prePatch, "pre-patch", false, "Apply pre-build patches")
|
||||
flag.BoolVar(&postPatch, "post-patch", false, "Apply post-build patches")
|
||||
flag.BoolVar(&skipPatchUpdate, "skip-patch-update", false, "Skip updating the patches repository")
|
||||
flag.BoolVar(&run, "r", false, "Run the project after build")
|
||||
flag.BoolVar(&upload, "upload", false, "Upload the compressed build file to SourceForge")
|
||||
flag.StringVar(&uploadPath, "upload-path", "", "Path to the file to upload if no build present")
|
||||
|
@ -141,7 +145,7 @@ func main() {
|
|||
fmt.Printf("Resolved uploadPath: %s\n", uploadPath)
|
||||
}
|
||||
|
||||
if all || buildFlag || patches || clean || update {
|
||||
if all || buildFlag || prePatch || postPatch || clean || update {
|
||||
BuildProcess()
|
||||
}
|
||||
|
||||
|
@ -170,12 +174,12 @@ func BuildProcess() {
|
|||
spitfire.DiscardChanges(sourcePath)
|
||||
spitfire.CleanBuild(sourcePath)
|
||||
spitfire.UpdateRepo(sourcePath)
|
||||
if err := spitfire.ApplyPatches(sourcePath, patchesRepo, "pre-compile-patches", filepath.Join(sourcePath, "patcher")); err != nil {
|
||||
if err := spitfire.ApplyPatches(sourcePath, patchesRepo, "pre-compile-patches", filepath.Join(sourcePath, "patcher"), skipPatchUpdate); err != nil {
|
||||
log.Fatalf("Error during patch application: %v", err)
|
||||
}
|
||||
spitfire.Configure(sourcePath)
|
||||
spitfire.Build(sourcePath)
|
||||
if err := spitfire.ApplyPatches(buildDir, patchesRepo, "post-compile-patches", filepath.Join(sourcePath, "patcher")); err != nil {
|
||||
if err := spitfire.ApplyPatches(buildDir, patchesRepo, "post-compile-patches", filepath.Join(sourcePath, "patcher"), skipPatchUpdate); err != nil {
|
||||
log.Fatalf("Error during patch application: %v", err)
|
||||
}
|
||||
if run {
|
||||
|
@ -189,18 +193,26 @@ func BuildProcess() {
|
|||
spitfire.DownloadSource(sourcePath, sourceRepo)
|
||||
spitfire.UpdateRepo(sourcePath)
|
||||
fmt.Println("Mozilla repository updated.")
|
||||
} else if patches {
|
||||
} else if prePatch {
|
||||
spitfire.DownloadSource(sourcePath, sourceRepo)
|
||||
if err := spitfire.ApplyPatches(sourcePath, patchesRepo, "pre-compile-patches", filepath.Join(sourcePath, "patcher")); err != nil {
|
||||
if err := spitfire.ApplyPatches(sourcePath, patchesRepo, "pre-compile-patches", filepath.Join(sourcePath, "patcher"), skipPatchUpdate); err != nil {
|
||||
log.Fatalf("Error during patch application: %v", err)
|
||||
}
|
||||
fmt.Println("Patches updated.")
|
||||
} else if postPatch {
|
||||
if _, err := os.Stat(buildDir); err == nil {
|
||||
if err := spitfire.ApplyPatches(buildDir, patchesRepo, "post-compile-patches", filepath.Join(sourcePath, "patcher"), skipPatchUpdate); err != nil {
|
||||
log.Fatalf("Error during patch application: %v", err)
|
||||
}
|
||||
}
|
||||
} else if buildFlag {
|
||||
spitfire.Configure(sourcePath)
|
||||
spitfire.Build(sourcePath)
|
||||
if err := spitfire.ApplyPatches(buildDir, patchesRepo, "post-compile-patches", filepath.Join(sourcePath, "patcher")); err != nil {
|
||||
if postPatch {
|
||||
if err := spitfire.ApplyPatches(buildDir, patchesRepo, "post-compile-patches", filepath.Join(sourcePath, "patcher"), skipPatchUpdate); err != nil {
|
||||
log.Fatalf("Error during patch application: %v", err)
|
||||
}
|
||||
}
|
||||
if run {
|
||||
spitfire.RunProject(sourcePath)
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
// ApplyPatches handles cloning, updating, and applying patches
|
||||
func ApplyPatches(sourcePath string, patchesRepo string, patchesPath string, patchesCloneDir string) error {
|
||||
func ApplyPatches(sourcePath string, patchesRepo string, patchesPath string, patchesCloneDir string, skipUpdateRepo bool) error {
|
||||
// Define the full patches path
|
||||
fullPatchesPath := filepath.Join(patchesCloneDir, patchesPath) // Cleaned path without double slashes
|
||||
|
||||
|
@ -28,6 +28,27 @@ func ApplyPatches(sourcePath string, patchesRepo string, patchesPath string, pat
|
|||
return fmt.Errorf("failed to clone patches repository: %v", err)
|
||||
}
|
||||
fmt.Println("Patches repository cloned successfully.")
|
||||
} else {
|
||||
if skipUpdateRepo {
|
||||
// If the directory exists, fetch and pull the latest changes
|
||||
fmt.Println("Patches directory already exists. Fetching latest changes.")
|
||||
cmdFetch := exec.Command("git", "fetch", "--all")
|
||||
cmdFetch.Dir = patchesCloneDir
|
||||
cmdFetch.Stdout = os.Stdout
|
||||
cmdFetch.Stderr = os.Stderr
|
||||
if err := cmdFetch.Run(); err != nil {
|
||||
return fmt.Errorf("failed to fetch updates for patches repository: %v", err)
|
||||
}
|
||||
|
||||
cmdReset := exec.Command("git", "reset", "--hard", "origin/main")
|
||||
cmdReset.Dir = patchesCloneDir
|
||||
cmdReset.Stdout = os.Stdout
|
||||
cmdReset.Stderr = os.Stderr
|
||||
if err := cmdReset.Run(); err != nil {
|
||||
return fmt.Errorf("failed to reset patches repository to latest state: %v", err)
|
||||
}
|
||||
fmt.Println("Patches repository updated successfully.")
|
||||
}
|
||||
}
|
||||
|
||||
// Verify the patches directory exists
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue