mirror of
https://github.com/taigrr/wails.git
synced 2026-04-02 05:08:54 -07:00
Add webview2 to wails doctor, refactored IsAppleSilicon
This commit is contained in:
@@ -162,7 +162,7 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
|||||||
// Calculate platform and arch
|
// Calculate platform and arch
|
||||||
platformSplit := strings.Split(platform, "/")
|
platformSplit := strings.Split(platform, "/")
|
||||||
buildOptions.Platform = platformSplit[0]
|
buildOptions.Platform = platformSplit[0]
|
||||||
if system.IsAppleSilicon() {
|
if system.IsAppleSilicon {
|
||||||
buildOptions.Arch = "arm64"
|
buildOptions.Arch = "arm64"
|
||||||
} else {
|
} else {
|
||||||
buildOptions.Arch = runtime.GOARCH
|
buildOptions.Arch = runtime.GOARCH
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
IsAppleSilicon bool
|
||||||
|
)
|
||||||
|
|
||||||
// Info holds information about the current operating system,
|
// Info holds information about the current operating system,
|
||||||
// package manager and required dependancies
|
// package manager and required dependancies
|
||||||
type Info struct {
|
type Info struct {
|
||||||
|
|||||||
@@ -1,17 +1,27 @@
|
|||||||
|
//go:build darwin
|
||||||
// +build darwin
|
// +build darwin
|
||||||
|
|
||||||
package system
|
package system
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/wailsapp/wails/v2/internal/system/packagemanager"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v2/internal/system/packagemanager"
|
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v2/internal/system/operatingsystem"
|
"github.com/wailsapp/wails/v2/internal/system/operatingsystem"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Determine if the app is running on Apple Silicon
|
||||||
|
// Credit: https://www.yellowduck.be/posts/detecting-apple-silicon-via-go/
|
||||||
|
func init() {
|
||||||
|
r, err := syscall.Sysctl("sysctl.proc_translated")
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
IsAppleSilicon = r == "\x00\x00\x00" || r == "\x01\x00\x00"
|
||||||
|
}
|
||||||
|
|
||||||
func (i *Info) discover() error {
|
func (i *Info) discover() error {
|
||||||
var err error
|
var err error
|
||||||
osinfo, err := operatingsystem.Info()
|
osinfo, err := operatingsystem.Info()
|
||||||
@@ -45,14 +55,3 @@ func (i *Info) discover() error {
|
|||||||
i.Dependencies = append(i.Dependencies, checkUPX())
|
i.Dependencies = append(i.Dependencies, checkUPX())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsAppleSilicon returns true if the app is running on Apple Silicon
|
|
||||||
// Credit: https://www.yellowduck.be/posts/detecting-apple-silicon-via-go/
|
|
||||||
func IsAppleSilicon() bool {
|
|
||||||
r, err := syscall.Sysctl("sysctl.proc_translated")
|
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return r == "\x00\x00\x00" || r == "\x01\x00\x00"
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
//go:build linux
|
||||||
// +build linux
|
// +build linux
|
||||||
|
|
||||||
package system
|
package system
|
||||||
@@ -27,10 +28,3 @@ func (i *Info) discover() error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsAppleSilicon returns true if the app is running on Apple Silicon
|
|
||||||
// Credit: https://www.yellowduck.be/posts/detecting-apple-silicon-via-go/
|
|
||||||
// NOTE: Not applicable to linux
|
|
||||||
func IsAppleSilicon() bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
|
//go:build windows
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package system
|
package system
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/leaanthony/webview2runtime"
|
||||||
"github.com/wailsapp/wails/v2/internal/system/operatingsystem"
|
"github.com/wailsapp/wails/v2/internal/system/operatingsystem"
|
||||||
|
"github.com/wailsapp/wails/v2/internal/system/packagemanager"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (i *Info) discover() error {
|
func (i *Info) discover() error {
|
||||||
@@ -15,6 +18,7 @@ func (i *Info) discover() error {
|
|||||||
}
|
}
|
||||||
i.OS = osinfo
|
i.OS = osinfo
|
||||||
|
|
||||||
|
i.Dependencies = append(i.Dependencies, checkWebView2())
|
||||||
i.Dependencies = append(i.Dependencies, checkNPM())
|
i.Dependencies = append(i.Dependencies, checkNPM())
|
||||||
i.Dependencies = append(i.Dependencies, checkUPX())
|
i.Dependencies = append(i.Dependencies, checkUPX())
|
||||||
i.Dependencies = append(i.Dependencies, checkDocker())
|
i.Dependencies = append(i.Dependencies, checkDocker())
|
||||||
@@ -22,9 +26,20 @@ func (i *Info) discover() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsAppleSilicon returns true if the app is running on Apple Silicon
|
func checkWebView2() *packagemanager.Dependancy {
|
||||||
// Credit: https://www.yellowduck.be/posts/detecting-apple-silicon-via-go/
|
|
||||||
// NOTE: Not applicable to windows
|
info := webview2runtime.GetInstalledVersion()
|
||||||
func IsAppleSilicon() bool {
|
version := info.Version
|
||||||
return false
|
installed := version != ""
|
||||||
|
|
||||||
|
return &packagemanager.Dependancy{
|
||||||
|
Name: "WebView2 ",
|
||||||
|
PackageName: "N/A",
|
||||||
|
Installed: installed,
|
||||||
|
InstallCommand: "Available at https://developer.microsoft.com/en-us/microsoft-edge/webview2/",
|
||||||
|
Version: version,
|
||||||
|
Optional: false,
|
||||||
|
External: true,
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user