Skip to content

Commit 28dbc33

Browse files
authored
Added Windows/ARM64 target host "flavor" for tools. (#3035)
* Added windows/arm64 target host for tools * Allow using Windows/32 or Windows/64 tools on Windows/ARM64 There is the Prism emulation layer that guarantees compatibility.
1 parent b1ae171 commit 28dbc33

File tree

3 files changed

+65
-22
lines changed

3 files changed

+65
-22
lines changed

docs/package_index_json-specification.md

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -172,33 +172,35 @@ Each tool version may come in different build flavours for different OS. Each fl
172172
array. The IDE will take care to install the right flavour for the user's OS by matching the `host` value with the
173173
following table or fail if a needed flavour is missing.
174174

175-
| OS flavour | `host` regexp | suggested `host` value |
176-
| --------------- | ------------------------------------- | ----------------------------------- |
177-
| Linux 32 | `i[3456]86-.*linux-gnu` | `i686-linux-gnu` |
178-
| Linux 64 | `x86_64-.*linux-gnu` | `x86_64-linux-gnu` |
179-
| Linux Arm | `arm.*-linux-gnueabihf` | `arm-linux-gnueabihf` |
180-
| Linux Arm64 | `(aarch64\|arm64)-linux-gnu` | `aarch64-linux-gnu` |
181-
| Linux RISC-V 64 | `riscv64-linux-gnu` | `riscv64-linux-gnu` |
182-
| Windows 32 | `i[3456]86-.*(mingw32\|cygwin)` | `i686-mingw32` or `i686-cygwin` |
183-
| Windows 64 | `(amd64\|x86_64)-.*(mingw32\|cygwin)` | `x86_64-mingw32` or `x86_64-cygwin` |
184-
| MacOSX 32 | `i[3456]86-apple-darwin.*` | `i686-apple-darwin` |
185-
| MacOSX 64 | `x86_64-apple-darwin.*` | `x86_64-apple-darwin` |
186-
| MacOSX Arm64 | `arm64-apple-darwin.*` | `arm64-apple-darwin` |
187-
| FreeBSD 32 | `i?[3456]86-freebsd[0-9]*` | `i686-freebsd` |
188-
| FreeBSD 64 | `amd64-freebsd[0-9]*` | `amd64-freebsd` |
189-
| FreeBSD Arm | `arm.*-freebsd[0-9]*` | `arm-freebsd` |
175+
| OS flavour | `host` regexp | suggested `host` value |
176+
| --------------- | -------------------------------------- | ----------------------------------- |
177+
| Linux 32 | `i[3456]86-.*linux-gnu` | `i686-linux-gnu` |
178+
| Linux 64 | `x86_64-.*linux-gnu` | `x86_64-linux-gnu` |
179+
| Linux Arm | `arm.*-linux-gnueabihf` | `arm-linux-gnueabihf` |
180+
| Linux Arm64 | `(aarch64\|arm64)-linux-gnu` | `aarch64-linux-gnu` |
181+
| Linux RISC-V 64 | `riscv64-linux-gnu` | `riscv64-linux-gnu` |
182+
| Windows 32 | `i[3456]86-.*(mingw32\|cygwin)` | `i686-mingw32` or `i686-cygwin` |
183+
| Windows 64 | `(amd64\|x86_64)-.*(mingw32\|cygwin)` | `x86_64-mingw32` or `x86_64-cygwin` |
184+
| Windows Arm64 | `(aarch64\|arm64)-.*(mingw32\|cygwin)` | `arm64-mingw32` or `arm64-cygwin` |
185+
| MacOSX 32 | `i[3456]86-apple-darwin.*` | `i686-apple-darwin` |
186+
| MacOSX 64 | `x86_64-apple-darwin.*` | `x86_64-apple-darwin` |
187+
| MacOSX Arm64 | `arm64-apple-darwin.*` | `arm64-apple-darwin` |
188+
| FreeBSD 32 | `i?[3456]86-freebsd[0-9]*` | `i686-freebsd` |
189+
| FreeBSD 64 | `amd64-freebsd[0-9]*` | `amd64-freebsd` |
190+
| FreeBSD Arm | `arm.*-freebsd[0-9]*` | `arm-freebsd` |
190191

191192
The `host` value is matched with the regexp, this means that a more specific value for the `host` field is allowed (for
192193
example you may write `x86_64-apple-darwin14.1` for MacOSX instead of the suggested `x86_64-apple-darwin`), by the way,
193194
we recommend to keep it simple and stick to the suggested value in the table.
194195

195196
Some OS allows to run different flavours:
196197

197-
| The OS... | ...may also run builds for |
198-
| ------------ | -------------------------- |
199-
| Windows 64 | Windows 32 |
200-
| MacOSX 64 | MacOSX 32 |
201-
| MacOSX Arm64 | MacOSX 64 or MacOSX 32 |
198+
| The OS... | ...may also run builds for |
199+
| ------------- | -------------------------- |
200+
| Windows 64 | Windows 32 |
201+
| Windows Arm64 | Windows 32 or Windows 64 |
202+
| MacOSX 64 | MacOSX 32 |
203+
| MacOSX Arm64 | MacOSX 64 or MacOSX 32 |
202204

203205
This is taken into account when the tools are downloaded (for example if we are on a Windows 64 machine and the needed
204206
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:
213215
- Linux 64 (`x86_64-linux-gnu`)
214216
- MacOSX Arm64 will use the MacOSX 64 flavour
215217
- Windows 64 will use the Windows 32 flavour
218+
- Windows Arm64 will use the Windows 32 flavour
216219

217220
Note: this information is not used to select the toolchain during compilation. If you want a specific version to be
218221
used, you should use the notation `{runtime.tools.TOOLNAME-VERSION.path}` in the platform.txt.

internal/arduino/cores/tools.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ var (
134134
regexpLinux32 = regexp.MustCompile("i[3456]86-.*linux-gnu")
135135
regexpWindows32 = regexp.MustCompile("i[3456]86-.*(mingw32|cygwin)")
136136
regexpWindows64 = regexp.MustCompile("(amd64|x86_64)-.*(mingw32|cygwin)")
137+
regexpWindowsArm64 = regexp.MustCompile("(aarch64|arm64)-.*(mingw32|cygwin)")
137138
regexpMac64 = regexp.MustCompile("x86_64-apple-darwin.*")
138139
regexpMac32 = regexp.MustCompile("i[3456]86-apple-darwin.*")
139140
regexpMacArm64 = regexp.MustCompile("arm64-apple-darwin.*")
@@ -162,6 +163,8 @@ func (f *Flavor) isExactMatchWith(osName, osArch string) bool {
162163
return regexpWindows32.MatchString(f.OS)
163164
case "windows,amd64":
164165
return regexpWindows64.MatchString(f.OS)
166+
case "windows,arm64":
167+
return regexpWindowsArm64.MatchString(f.OS)
165168
case "darwin,arm64":
166169
return regexpMacArm64.MatchString(f.OS)
167170
case "darwin,amd64":
@@ -186,6 +189,13 @@ func (f *Flavor) isCompatibleWith(osName, osArch string) (bool, int) {
186189
switch osName + "," + osArch {
187190
case "windows,amd64":
188191
return regexpWindows32.MatchString(f.OS), 10
192+
case "windows,arm64":
193+
// Compatibility guaranteed through Prism emulation
194+
if regexpWindows64.MatchString(f.OS) {
195+
// Prefer amd64 version if available
196+
return true, 20
197+
}
198+
return regexpWindows32.MatchString(f.OS), 10
189199
case "darwin,amd64":
190200
return regexpMac32.MatchString(f.OS), 10
191201
case "darwin,arm64":

internal/arduino/cores/tools_test.go

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func TestFlavorCompatibility(t *testing.T) {
2929
}
3030
windows32 := &os{"windows", "386"}
3131
windows64 := &os{"windows", "amd64"}
32+
windowsArm64 := &os{"windows", "arm64"}
3233
linux32 := &os{"linux", "386"}
3334
linux64 := &os{"linux", "amd64"}
3435
linuxArm := &os{"linux", "arm"}
@@ -43,6 +44,7 @@ func TestFlavorCompatibility(t *testing.T) {
4344
oses := []*os{
4445
windows32,
4546
windows64,
47+
windowsArm64,
4648
linux32,
4749
linux64,
4850
linuxArm,
@@ -62,8 +64,9 @@ func TestFlavorCompatibility(t *testing.T) {
6264
ExactMatch []*os
6365
}
6466
tests := []*test{
65-
{&Flavor{OS: "i686-mingw32"}, []*os{windows32, windows64}, []*os{windows32}},
66-
{&Flavor{OS: "x86_64-mingw32"}, []*os{windows64}, []*os{windows64}},
67+
{&Flavor{OS: "i686-mingw32"}, []*os{windows32, windows64, windowsArm64}, []*os{windows32}},
68+
{&Flavor{OS: "x86_64-mingw32"}, []*os{windows64, windowsArm64}, []*os{windows64}},
69+
{&Flavor{OS: "arm64-mingw32"}, []*os{windowsArm64}, []*os{windowsArm64}},
6770
{&Flavor{OS: "i386-apple-darwin11"}, []*os{darwin32, darwin64, darwinArm64}, []*os{darwin32}},
6871
{&Flavor{OS: "x86_64-apple-darwin"}, []*os{darwin64, darwinArm64}, []*os{darwin64}},
6972
{&Flavor{OS: "arm64-apple-darwin"}, []*os{darwinArm64}, []*os{darwinArm64}},
@@ -160,17 +163,44 @@ func TestFlavorPrioritySelection(t *testing.T) {
160163
Flavors: []*Flavor{
161164
{OS: "i686-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "1"}},
162165
{OS: "x86_64-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "2"}},
166+
{OS: "arm64-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "3"}},
163167
},
164168
}).GetFlavourCompatibleWith("windows", "amd64")
165169
require.NotNil(t, res)
166170
require.Equal(t, "2", res.ArchiveFileName)
167171

168172
res = (&ToolRelease{
169173
Flavors: []*Flavor{
174+
{OS: "i686-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "1"}},
170175
{OS: "x86_64-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "2"}},
176+
{OS: "arm64-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "3"}},
177+
},
178+
}).GetFlavourCompatibleWith("windows", "arm64")
179+
require.NotNil(t, res)
180+
require.Equal(t, "3", res.ArchiveFileName)
181+
182+
res = (&ToolRelease{
183+
Flavors: []*Flavor{
171184
{OS: "i686-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "1"}},
172185
},
173186
}).GetFlavourCompatibleWith("windows", "amd64")
174187
require.NotNil(t, res)
188+
require.Equal(t, "1", res.ArchiveFileName)
189+
190+
res = (&ToolRelease{
191+
Flavors: []*Flavor{
192+
{OS: "i686-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "1"}},
193+
{OS: "x86_64-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "2"}},
194+
},
195+
}).GetFlavourCompatibleWith("windows", "arm64")
196+
require.NotNil(t, res)
175197
require.Equal(t, "2", res.ArchiveFileName)
198+
199+
res = (&ToolRelease{
200+
Flavors: []*Flavor{
201+
{OS: "i686-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "1"}},
202+
},
203+
}).GetFlavourCompatibleWith("windows", "arm64")
204+
require.NotNil(t, res)
205+
require.Equal(t, "1", res.ArchiveFileName)
176206
}

0 commit comments

Comments
 (0)