windows build compatability
This commit is contained in:
parent
048bbc1e3e
commit
358cd7147b
3 changed files with 137 additions and 29 deletions
|
@ -37,6 +37,7 @@ func SetGlobalEnv(variable, value string, scope string) error {
|
|||
|
||||
// Run an external command like scp or rsync
|
||||
func runCommand(command string, args ...string) error {
|
||||
fmt.Printf("Running command: %s %v\n", command, args)
|
||||
cmd := exec.Command(command, args...)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
|
@ -83,10 +84,21 @@ func CleanBuild(sourcePath string) {
|
|||
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.")
|
||||
}
|
||||
if err := runCommand("./mach", "clobber"); err != nil {
|
||||
// Clean the build
|
||||
if err := runCommand(machCmd, "clobber"); err != nil {
|
||||
errors = append(errors, "Failed to clean build.")
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +159,7 @@ func UpdatePatches(patchesDir, patchesRepo, sourcePath string) {
|
|||
fmt.Println("Copying files from patches directory to Firefox source directory...")
|
||||
if runtime.GOOS == "windows" {
|
||||
// Use robocopy for Windows
|
||||
if err := runCommand("robocopy", patchesDir, sourcePath, "*", "/E", "/XF", ".git"); err != nil {
|
||||
if err := runCommand("robocopy", patchesDir, sourcePath, "*", "/S", "/XF", ".git", "/XD", ".git"); err != nil {
|
||||
errors = append(errors, "Failed to copy files (Windows robocopy).")
|
||||
}
|
||||
} else {
|
||||
|
@ -155,7 +167,7 @@ func UpdatePatches(patchesDir, patchesRepo, sourcePath string) {
|
|||
if err := runCommand("rsync", "-av", "--exclude=.git", patchesDir+"/", sourcePath+"/"); err != nil {
|
||||
errors = append(errors, "Failed to copy files (rsync).")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Function to configure Spitfire
|
||||
|
@ -165,7 +177,16 @@ func Configure(sourcePath string) {
|
|||
errors = append(errors, "Failed to navigate to source directory.")
|
||||
return
|
||||
}
|
||||
if err := runCommand("./mach", "configure"); err != nil {
|
||||
|
||||
// Use the appropriate mach command for Windows or Unix-like systems
|
||||
var machCmd string
|
||||
if runtime.GOOS == "windows" {
|
||||
machCmd = ".\\mach"
|
||||
} else {
|
||||
machCmd = "./mach"
|
||||
}
|
||||
|
||||
if err := runCommand(machCmd, "configure"); err != nil {
|
||||
errors = append(errors, "Configuration failed.")
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +198,16 @@ func Build(sourcePath string) {
|
|||
errors = append(errors, "Failed to navigate to source directory.")
|
||||
return
|
||||
}
|
||||
if err := runCommand("./mach", "build"); err != nil {
|
||||
|
||||
// Use the appropriate mach command for Windows or Unix-like systems
|
||||
var machCmd string
|
||||
if runtime.GOOS == "windows" {
|
||||
machCmd = ".\\mach"
|
||||
} else {
|
||||
machCmd = "./mach"
|
||||
}
|
||||
|
||||
if err := runCommand(machCmd, "build"); err != nil {
|
||||
errors = append(errors, "Build failed.")
|
||||
}
|
||||
}
|
||||
|
@ -185,11 +215,16 @@ func Build(sourcePath string) {
|
|||
// Function to run the project after build
|
||||
func RunProject(sourcePath string) {
|
||||
fmt.Println("Running the project...")
|
||||
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"
|
||||
}
|
||||
if err := runCommand("./mach", "run"); err != nil {
|
||||
|
||||
if err := runCommand(machCmd, "run"); err != nil {
|
||||
errors = append(errors, "Failed to run the project.")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue