improving windows compatability
This commit is contained in:
parent
921540d5a4
commit
8de4db960a
6 changed files with 73 additions and 107 deletions
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue