Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions docs/package_index_json-specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,33 +172,35 @@ 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,
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).
Expand All @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions internal/arduino/cores/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.*")
Expand Down Expand Up @@ -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":
Expand All @@ -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":
Expand Down
34 changes: 32 additions & 2 deletions internal/arduino/cores/tools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand All @@ -43,6 +44,7 @@ func TestFlavorCompatibility(t *testing.T) {
oses := []*os{
windows32,
windows64,
windowsArm64,
linux32,
linux64,
linuxArm,
Expand All @@ -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}},
Expand Down Expand Up @@ -160,17 +163,44 @@ 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)
require.Equal(t, "2", res.ArchiveFileName)

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)
}