improving windows compatability
This commit is contained in:
parent
921540d5a4
commit
8de4db960a
6 changed files with 73 additions and 107 deletions
|
@ -82,33 +82,12 @@ func DiscardChanges(sourcePath string) {
|
|||
func CleanBuild(sourcePath string, fullClean bool) {
|
||||
fmt.Println("Cleaning build...")
|
||||
|
||||
// Resolve the build directory dynamically
|
||||
buildDir, err := ResolveBuildDir(sourcePath)
|
||||
if err != nil {
|
||||
errors = append(errors, fmt.Sprintf("Failed to resolve build directory: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Revert uncommitted changes
|
||||
if err := runCommand("hg", "revert", "--all", "--no-backup"); err != nil {
|
||||
errors = append(errors, "Failed to revert changes in Mozilla repository.")
|
||||
}
|
||||
|
||||
// Paths for CLOBBER file and last build timestamp
|
||||
clobberFile := filepath.Join(buildDir, "CLOBBER")
|
||||
buildTimestampFile := filepath.Join(buildDir, ".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 {
|
||||
if fullClean {
|
||||
// Perform full clean or clobber if necessary
|
||||
var machCmd string
|
||||
if runtime.GOOS == "windows" {
|
||||
|
@ -181,7 +160,7 @@ func UpdatePatches(patchesDir, patchesRepo, sourcePath string) {
|
|||
|
||||
// Handle platform-specific rsync command
|
||||
fmt.Println("Copying files from patches directory to Firefox source directory...")
|
||||
if runtime.GOOS == "windows" {
|
||||
if runtime.GOOS == "windows" || !isMsys2() {
|
||||
// Use robocopy for Windows
|
||||
if err := runCommand("robocopy", patchesDir, sourcePath, "*", "/S", "/XF", ".git", "/XD", ".git"); err != nil {
|
||||
errors = append(errors, "Failed to copy files (Windows robocopy).")
|
||||
|
|
|
@ -6,44 +6,47 @@ import (
|
|||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// CheckSystemDependencies ensures that required tools for building are installed.
|
||||
func CheckSystemDependencies() error {
|
||||
requiredTools := map[string]string{
|
||||
"git": "https://git-scm.com/download/win", // Git
|
||||
"python": "https://www.python.org/downloads/", // Python
|
||||
"pip3": "https://pip.pypa.io/en/stable/installing/", // Pip3
|
||||
// CheckDependencies ensures that all required tools and dependencies for the build are installed.
|
||||
func CheckDependencies() error {
|
||||
// Common dependencies
|
||||
dependencies := map[string]string{
|
||||
"git": "https://git-scm.com/download/win", // Git
|
||||
"python": "https://www.python.org/downloads/", // Python
|
||||
"pip3": "https://pip.pypa.io/en/stable/installing/", // Pip3
|
||||
"mercurial": "https://www.mercurial-scm.org/", // Mercurial (hg)
|
||||
}
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
// Check for MozillaBuild installation
|
||||
// Add platform-specific dependencies
|
||||
if runtime.GOOS == "windows" || !isMsys2() {
|
||||
mozBuildPath := os.Getenv("MOZILLABUILD")
|
||||
if mozBuildPath == "" {
|
||||
mozBuildPath = "C:\\mozilla-build" // Default to standard MozillaBuild path
|
||||
mozBuildPath = "C:\\mozilla-build" // Default path for MozillaBuild
|
||||
}
|
||||
|
||||
// Check if MozillaBuild exists at the specified location
|
||||
if !dirExists(mozBuildPath) {
|
||||
requiredTools["mozbuild"] = "https://ftp.mozilla.org/pub/mozilla/libraries/win32/MozillaBuildSetup-Latest.exe"
|
||||
dependencies["mozbuild"] = "https://ftp.mozilla.org/pub/mozilla/libraries/win32/MozillaBuildSetup-Latest.exe"
|
||||
}
|
||||
} else if runtime.GOOS != "windows" || !isMsys2() {
|
||||
dependencies["rsync"] = "https://rsync.samba.org/download.html" // rsync for non-Windows platforms
|
||||
}
|
||||
|
||||
// Check for missing tools
|
||||
missingTools := []string{}
|
||||
|
||||
// Check for each required tool
|
||||
for tool, downloadLink := range requiredTools {
|
||||
for tool, downloadLink := range dependencies {
|
||||
if !isCommandAvailable(tool) {
|
||||
missingTools = append(missingTools, fmt.Sprintf("%s (Download: %s)", tool, downloadLink))
|
||||
}
|
||||
}
|
||||
|
||||
// Special check for mach in the local source directory (mozilla-central)
|
||||
// Special check for `mach` in the local source directory
|
||||
machPath := filepath.Join("mozilla-central", "mach")
|
||||
if !fileExists(machPath) {
|
||||
missingTools = append(missingTools, fmt.Sprintf("mach (run from mozilla-central directory)"))
|
||||
missingTools = append(missingTools, "mach (ensure you are in the mozilla-central directory)")
|
||||
}
|
||||
|
||||
// Report missing tools if any
|
||||
if len(missingTools) > 0 {
|
||||
fmt.Println("The following tools are missing and are required for the build:")
|
||||
for _, tool := range missingTools {
|
||||
|
@ -76,3 +79,8 @@ func dirExists(path string) bool {
|
|||
}
|
||||
return info.IsDir()
|
||||
}
|
||||
|
||||
// isMsys2 detects if the environment is MSYS2 by checking the MSYSTEM environment variable.
|
||||
func isMsys2() bool {
|
||||
return strings.Contains(strings.ToLower(os.Getenv("MSYSTEM")), "msys")
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ func ApplyPatches(sourcePath string, patchesRepo string, patchesPath string, pat
|
|||
}
|
||||
|
||||
// Apply the patches using `run.sh`
|
||||
applyCmd := exec.Command("go", "run", ".", "--path", sourcePath, "--patches", fullPatchesPath) applyCmd.Dir = patchesCloneDir // Run from the patches directory
|
||||
applyCmd := exec.Command("go", "run", ".", "--path", sourcePath, "--patches", fullPatchesPath)
|
||||
applyCmd.Dir = patchesCloneDir // Run from the patches directory
|
||||
applyCmd.Stdout = os.Stdout
|
||||
applyCmd.Stderr = os.Stderr
|
||||
|
|
|
@ -26,16 +26,24 @@ type Config struct {
|
|||
func LoadConfig() (*Config, error) {
|
||||
file, err := os.Open("sourceforge_config.json") // Assuming a JSON config file
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("failed to open config file: %v", err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
config := &Config{}
|
||||
if err := json.NewDecoder(file).Decode(config); err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("failed to decode config file: %v", err)
|
||||
}
|
||||
|
||||
config.SFKeyPath = filepath.FromSlash(config.SFKeyPath)
|
||||
// Normalize the SSH key path for the current OS
|
||||
config.SFKeyPath = filepath.Clean(config.SFKeyPath)
|
||||
|
||||
// Validate that the key file exists
|
||||
if _, err := os.Stat(config.SFKeyPath); os.IsNotExist(err) {
|
||||
return nil, fmt.Errorf("SSH key file not found at path: %s", config.SFKeyPath)
|
||||
} else if err != nil {
|
||||
return nil, fmt.Errorf("error accessing SSH key file: %v", err)
|
||||
}
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
@ -74,7 +82,9 @@ func CompressDirectory(srcDir, dstFile string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
header.Name = relPath
|
||||
|
||||
// Normalize paths to UNIX-style for tar compatibility
|
||||
header.Name = filepath.ToSlash(relPath)
|
||||
|
||||
// Explicitly set the type flag for directories
|
||||
if fi.IsDir() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue