mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 23:51:44 +08:00
[v2/Mac] Add Apple Silicon
hardware detection to wails doctor
(#3129)
* [v2/Mac] Add Apple Silicon hardware detection to `wails doctor` * add change log
This commit is contained in:
parent
3aaa1f8e34
commit
5f457dba8e
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/wailsapp/wails/v2/internal/shell"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -93,7 +94,14 @@ func diagnoseEnvironment(f *flags.Doctor) error {
|
|||||||
systemTabledata = append(systemTabledata, []string{prefix, cpu.Model})
|
systemTabledata = append(systemTabledata, []string{prefix, cpu.Model})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
systemTabledata = append(systemTabledata, []string{"CPU", "Unknown"})
|
cpuInfo := "Unknown"
|
||||||
|
if runtime.GOOS == "darwin" {
|
||||||
|
// Try to get CPU info from sysctl
|
||||||
|
if stdout, _, err := shell.RunCommand("", "sysctl", "-n", "machdep.cpu.brand_string"); err == nil {
|
||||||
|
cpuInfo = strings.TrimSpace(stdout)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
systemTabledata = append(systemTabledata, []string{"CPU", cpuInfo})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Probe GPU
|
// Probe GPU
|
||||||
@ -112,14 +120,47 @@ func diagnoseEnvironment(f *flags.Doctor) error {
|
|||||||
systemTabledata = append(systemTabledata, []string{prefix, details})
|
systemTabledata = append(systemTabledata, []string{prefix, details})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
systemTabledata = append(systemTabledata, []string{"GPU", "Unknown"})
|
gpuInfo := "Unknown"
|
||||||
|
if runtime.GOOS == "darwin" {
|
||||||
|
// Try to get GPU info from system_profiler
|
||||||
|
if stdout, _, err := shell.RunCommand("", "system_profiler", "SPDisplaysDataType"); err == nil {
|
||||||
|
var (
|
||||||
|
startCapturing bool
|
||||||
|
gpuInfoDetails []string
|
||||||
|
)
|
||||||
|
for _, line := range strings.Split(stdout, "\n") {
|
||||||
|
if strings.Contains(line, "Chipset Model") {
|
||||||
|
startCapturing = true
|
||||||
|
}
|
||||||
|
if startCapturing {
|
||||||
|
gpuInfoDetails = append(gpuInfoDetails, strings.TrimSpace(line))
|
||||||
|
}
|
||||||
|
if strings.Contains(line, "Metal Support") {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(gpuInfoDetails) > 0 {
|
||||||
|
gpuInfo = strings.Join(gpuInfoDetails, " ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
systemTabledata = append(systemTabledata, []string{"GPU", gpuInfo})
|
||||||
}
|
}
|
||||||
|
|
||||||
memory, _ := ghw.Memory()
|
memory, _ := ghw.Memory()
|
||||||
if memory != nil {
|
if memory != nil {
|
||||||
systemTabledata = append(systemTabledata, []string{"Memory", strconv.Itoa(int(memory.TotalPhysicalBytes/1024/1024/1024)) + "GB"})
|
systemTabledata = append(systemTabledata, []string{"Memory", strconv.Itoa(int(memory.TotalPhysicalBytes/1024/1024/1024)) + "GB"})
|
||||||
} else {
|
} else {
|
||||||
systemTabledata = append(systemTabledata, []string{"Memory", "Unknown"})
|
memInfo := "Unknown"
|
||||||
|
if runtime.GOOS == "darwin" {
|
||||||
|
// Try to get Memory info from sysctl
|
||||||
|
if stdout, _, err := shell.RunCommand("", "sysctl", "-n", "hw.memsize"); err == nil {
|
||||||
|
if memSize, err := strconv.Atoi(strings.TrimSpace(stdout)); err == nil {
|
||||||
|
memInfo = strconv.Itoa(memSize/1024/1024/1024) + "GB"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
systemTabledata = append(systemTabledata, []string{"Memory", memInfo})
|
||||||
}
|
}
|
||||||
|
|
||||||
err = pterm.DefaultTable.WithBoxed().WithData(systemTabledata).Render()
|
err = pterm.DefaultTable.WithBoxed().WithData(systemTabledata).Render()
|
||||||
|
@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Add Apple Silicon hardware detection to `wails doctor`. Changed by @almas1992 in [PR](https://github.com/wailsapp/wails/pull/3129)
|
||||||
|
|
||||||
## v2.7.1 - 2023-12-10
|
## v2.7.1 - 2023-12-10
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
Loading…
Reference in New Issue
Block a user