[v2] Target ARM on Apple Silicon, even if CLI is compiled for AMD64

This commit is contained in:
Lea Anthony
2021-07-03 16:32:47 +10:00
parent 1f3351ffa5
commit 642c1d5ec5
2 changed files with 32 additions and 4 deletions

View File

@@ -1,10 +1,12 @@
package system
import (
"github.com/wailsapp/wails/v2/internal/system/operatingsystem"
"github.com/wailsapp/wails/v2/internal/system/packagemanager"
"os/exec"
"strings"
"syscall"
"github.com/wailsapp/wails/v2/internal/system/operatingsystem"
"github.com/wailsapp/wails/v2/internal/system/packagemanager"
)
// Info holds information about the current operating system,
@@ -105,3 +107,14 @@ func checkDocker() *packagemanager.Dependancy {
External: false,
}
}
// 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"
}