diff --git a/docs/package_index_json-specification.md b/docs/package_index_json-specification.md index e05756daf86..3f92f66e70d 100644 --- a/docs/package_index_json-specification.md +++ b/docs/package_index_json-specification.md @@ -172,21 +172,22 @@ Each tool version may come in different build flavours for different OS. Each fl array. The IDE will take care to install the right flavour for the user's OS by matching the `host` value with the following table or fail if a needed flavour is missing. -| OS flavour | `host` regexp | suggested `host` value | -| --------------- | ------------------------------------- | ----------------------------------- | -| Linux 32 | `i[3456]86-.*linux-gnu` | `i686-linux-gnu` | -| Linux 64 | `x86_64-.*linux-gnu` | `x86_64-linux-gnu` | -| Linux Arm | `arm.*-linux-gnueabihf` | `arm-linux-gnueabihf` | -| Linux Arm64 | `(aarch64\|arm64)-linux-gnu` | `aarch64-linux-gnu` | -| Linux RISC-V 64 | `riscv64-linux-gnu` | `riscv64-linux-gnu` | -| Windows 32 | `i[3456]86-.*(mingw32\|cygwin)` | `i686-mingw32` or `i686-cygwin` | -| Windows 64 | `(amd64\|x86_64)-.*(mingw32\|cygwin)` | `x86_64-mingw32` or `x86_64-cygwin` | -| MacOSX 32 | `i[3456]86-apple-darwin.*` | `i686-apple-darwin` | -| MacOSX 64 | `x86_64-apple-darwin.*` | `x86_64-apple-darwin` | -| MacOSX Arm64 | `arm64-apple-darwin.*` | `arm64-apple-darwin` | -| FreeBSD 32 | `i?[3456]86-freebsd[0-9]*` | `i686-freebsd` | -| FreeBSD 64 | `amd64-freebsd[0-9]*` | `amd64-freebsd` | -| FreeBSD Arm | `arm.*-freebsd[0-9]*` | `arm-freebsd` | +| OS flavour | `host` regexp | suggested `host` value | +| --------------- | -------------------------------------- | ----------------------------------- | +| Linux 32 | `i[3456]86-.*linux-gnu` | `i686-linux-gnu` | +| Linux 64 | `x86_64-.*linux-gnu` | `x86_64-linux-gnu` | +| Linux Arm | `arm.*-linux-gnueabihf` | `arm-linux-gnueabihf` | +| Linux Arm64 | `(aarch64\|arm64)-linux-gnu` | `aarch64-linux-gnu` | +| Linux RISC-V 64 | `riscv64-linux-gnu` | `riscv64-linux-gnu` | +| Windows 32 | `i[3456]86-.*(mingw32\|cygwin)` | `i686-mingw32` or `i686-cygwin` | +| Windows 64 | `(amd64\|x86_64)-.*(mingw32\|cygwin)` | `x86_64-mingw32` or `x86_64-cygwin` | +| Windows Arm64 | `(aarch64\|arm64)-.*(mingw32\|cygwin)` | `arm64-mingw32` or `arm64-cygwin` | +| MacOSX 32 | `i[3456]86-apple-darwin.*` | `i686-apple-darwin` | +| MacOSX 64 | `x86_64-apple-darwin.*` | `x86_64-apple-darwin` | +| MacOSX Arm64 | `arm64-apple-darwin.*` | `arm64-apple-darwin` | +| FreeBSD 32 | `i?[3456]86-freebsd[0-9]*` | `i686-freebsd` | +| FreeBSD 64 | `amd64-freebsd[0-9]*` | `amd64-freebsd` | +| FreeBSD Arm | `arm.*-freebsd[0-9]*` | `arm-freebsd` | The `host` value is matched with the regexp, this means that a more specific value for the `host` field is allowed (for example you may write `x86_64-apple-darwin14.1` for MacOSX instead of the suggested `x86_64-apple-darwin`), by the way, @@ -194,11 +195,12 @@ we recommend to keep it simple and stick to the suggested value in the table. Some OS allows to run different flavours: -| The OS... | ...may also run builds for | -| ------------ | -------------------------- | -| Windows 64 | Windows 32 | -| MacOSX 64 | MacOSX 32 | -| MacOSX Arm64 | MacOSX 64 or MacOSX 32 | +| The OS... | ...may also run builds for | +| ------------- | -------------------------- | +| Windows 64 | Windows 32 | +| Windows Arm64 | Windows 32 or Windows 64 | +| MacOSX 64 | MacOSX 32 | +| MacOSX Arm64 | MacOSX 64 or MacOSX 32 | This is taken into account when the tools are downloaded (for example if we are on a Windows 64 machine and the needed tool is available only for the Windows 32 flavour, then the Windows 32 flavour will be downloaded and used). @@ -213,6 +215,7 @@ For completeness, the previous example `avr-gcc` comes with builds for: - Linux 64 (`x86_64-linux-gnu`) - MacOSX Arm64 will use the MacOSX 64 flavour - Windows 64 will use the Windows 32 flavour +- Windows Arm64 will use the Windows 32 flavour Note: this information is not used to select the toolchain during compilation. If you want a specific version to be used, you should use the notation `{runtime.tools.TOOLNAME-VERSION.path}` in the platform.txt. diff --git a/internal/arduino/cores/tools.go b/internal/arduino/cores/tools.go index b858e7eab62..6b3877a8c16 100644 --- a/internal/arduino/cores/tools.go +++ b/internal/arduino/cores/tools.go @@ -134,6 +134,7 @@ var ( regexpLinux32 = regexp.MustCompile("i[3456]86-.*linux-gnu") regexpWindows32 = regexp.MustCompile("i[3456]86-.*(mingw32|cygwin)") regexpWindows64 = regexp.MustCompile("(amd64|x86_64)-.*(mingw32|cygwin)") + regexpWindowsArm64 = regexp.MustCompile("(aarch64|arm64)-.*(mingw32|cygwin)") regexpMac64 = regexp.MustCompile("x86_64-apple-darwin.*") regexpMac32 = regexp.MustCompile("i[3456]86-apple-darwin.*") regexpMacArm64 = regexp.MustCompile("arm64-apple-darwin.*") @@ -162,6 +163,8 @@ func (f *Flavor) isExactMatchWith(osName, osArch string) bool { return regexpWindows32.MatchString(f.OS) case "windows,amd64": return regexpWindows64.MatchString(f.OS) + case "windows,arm64": + return regexpWindowsArm64.MatchString(f.OS) case "darwin,arm64": return regexpMacArm64.MatchString(f.OS) case "darwin,amd64": @@ -186,6 +189,13 @@ func (f *Flavor) isCompatibleWith(osName, osArch string) (bool, int) { switch osName + "," + osArch { case "windows,amd64": return regexpWindows32.MatchString(f.OS), 10 + case "windows,arm64": + // Compatibility guaranteed through Prism emulation + if regexpWindows64.MatchString(f.OS) { + // Prefer amd64 version if available + return true, 20 + } + return regexpWindows32.MatchString(f.OS), 10 case "darwin,amd64": return regexpMac32.MatchString(f.OS), 10 case "darwin,arm64": diff --git a/internal/arduino/cores/tools_test.go b/internal/arduino/cores/tools_test.go index f4a3097a3ca..897ab8b6935 100644 --- a/internal/arduino/cores/tools_test.go +++ b/internal/arduino/cores/tools_test.go @@ -29,6 +29,7 @@ func TestFlavorCompatibility(t *testing.T) { } windows32 := &os{"windows", "386"} windows64 := &os{"windows", "amd64"} + windowsArm64 := &os{"windows", "arm64"} linux32 := &os{"linux", "386"} linux64 := &os{"linux", "amd64"} linuxArm := &os{"linux", "arm"} @@ -43,6 +44,7 @@ func TestFlavorCompatibility(t *testing.T) { oses := []*os{ windows32, windows64, + windowsArm64, linux32, linux64, linuxArm, @@ -62,8 +64,9 @@ func TestFlavorCompatibility(t *testing.T) { ExactMatch []*os } tests := []*test{ - {&Flavor{OS: "i686-mingw32"}, []*os{windows32, windows64}, []*os{windows32}}, - {&Flavor{OS: "x86_64-mingw32"}, []*os{windows64}, []*os{windows64}}, + {&Flavor{OS: "i686-mingw32"}, []*os{windows32, windows64, windowsArm64}, []*os{windows32}}, + {&Flavor{OS: "x86_64-mingw32"}, []*os{windows64, windowsArm64}, []*os{windows64}}, + {&Flavor{OS: "arm64-mingw32"}, []*os{windowsArm64}, []*os{windowsArm64}}, {&Flavor{OS: "i386-apple-darwin11"}, []*os{darwin32, darwin64, darwinArm64}, []*os{darwin32}}, {&Flavor{OS: "x86_64-apple-darwin"}, []*os{darwin64, darwinArm64}, []*os{darwin64}}, {&Flavor{OS: "arm64-apple-darwin"}, []*os{darwinArm64}, []*os{darwinArm64}}, @@ -160,6 +163,7 @@ func TestFlavorPrioritySelection(t *testing.T) { Flavors: []*Flavor{ {OS: "i686-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "1"}}, {OS: "x86_64-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "2"}}, + {OS: "arm64-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "3"}}, }, }).GetFlavourCompatibleWith("windows", "amd64") require.NotNil(t, res) @@ -167,10 +171,36 @@ func TestFlavorPrioritySelection(t *testing.T) { res = (&ToolRelease{ Flavors: []*Flavor{ + {OS: "i686-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "1"}}, {OS: "x86_64-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "2"}}, + {OS: "arm64-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "3"}}, + }, + }).GetFlavourCompatibleWith("windows", "arm64") + require.NotNil(t, res) + require.Equal(t, "3", res.ArchiveFileName) + + res = (&ToolRelease{ + Flavors: []*Flavor{ {OS: "i686-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "1"}}, }, }).GetFlavourCompatibleWith("windows", "amd64") require.NotNil(t, res) + require.Equal(t, "1", res.ArchiveFileName) + + res = (&ToolRelease{ + Flavors: []*Flavor{ + {OS: "i686-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "1"}}, + {OS: "x86_64-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "2"}}, + }, + }).GetFlavourCompatibleWith("windows", "arm64") + require.NotNil(t, res) require.Equal(t, "2", res.ArchiveFileName) + + res = (&ToolRelease{ + Flavors: []*Flavor{ + {OS: "i686-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "1"}}, + }, + }).GetFlavourCompatibleWith("windows", "arm64") + require.NotNil(t, res) + require.Equal(t, "1", res.ArchiveFileName) }