Skip to content

Commit d9c9973

Browse files
committed
Allow using Windows/32 or Windows/64 tools on Windows/ARM64
There is the Prism emulation layer that guarantees compatibility.
1 parent e8a71d0 commit d9c9973

File tree

3 files changed

+43
-7
lines changed

3 files changed

+43
-7
lines changed

docs/package_index_json-specification.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,12 @@ we recommend to keep it simple and stick to the suggested value in the table.
195195

196196
Some OS allows to run different flavours:
197197

198-
| The OS... | ...may also run builds for |
199-
| ------------ | -------------------------- |
200-
| Windows 64 | Windows 32 |
201-
| MacOSX 64 | MacOSX 32 |
202-
| 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 |
203204

204205
This is taken into account when the tools are downloaded (for example if we are on a Windows 64 machine and the needed
205206
tool is available only for the Windows 32 flavour, then the Windows 32 flavour will be downloaded and used).
@@ -214,6 +215,7 @@ For completeness, the previous example `avr-gcc` comes with builds for:
214215
- Linux 64 (`x86_64-linux-gnu`)
215216
- MacOSX Arm64 will use the MacOSX 64 flavour
216217
- Windows 64 will use the Windows 32 flavour
218+
- Windows Arm64 will use the Windows 32 flavour
217219

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

internal/arduino/cores/tools.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,13 @@ func (f *Flavor) isCompatibleWith(osName, osArch string) (bool, int) {
189189
switch osName + "," + osArch {
190190
case "windows,amd64":
191191
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
192199
case "darwin,amd64":
193200
return regexpMac32.MatchString(f.OS), 10
194201
case "darwin,arm64":

internal/arduino/cores/tools_test.go

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ func TestFlavorCompatibility(t *testing.T) {
6464
ExactMatch []*os
6565
}
6666
tests := []*test{
67-
{&Flavor{OS: "i686-mingw32"}, []*os{windows32, windows64}, []*os{windows32}},
68-
{&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}},
6969
{&Flavor{OS: "arm64-mingw32"}, []*os{windowsArm64}, []*os{windowsArm64}},
7070
{&Flavor{OS: "i386-apple-darwin11"}, []*os{darwin32, darwin64, darwinArm64}, []*os{darwin32}},
7171
{&Flavor{OS: "x86_64-apple-darwin"}, []*os{darwin64, darwinArm64}, []*os{darwin64}},
@@ -163,17 +163,44 @@ func TestFlavorPrioritySelection(t *testing.T) {
163163
Flavors: []*Flavor{
164164
{OS: "i686-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "1"}},
165165
{OS: "x86_64-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "2"}},
166+
{OS: "arm64-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "3"}},
166167
},
167168
}).GetFlavourCompatibleWith("windows", "amd64")
168169
require.NotNil(t, res)
169170
require.Equal(t, "2", res.ArchiveFileName)
170171

171172
res = (&ToolRelease{
172173
Flavors: []*Flavor{
174+
{OS: "i686-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "1"}},
173175
{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{
174184
{OS: "i686-mingw32", Resource: &resources.DownloadResource{ArchiveFileName: "1"}},
175185
},
176186
}).GetFlavourCompatibleWith("windows", "amd64")
177187
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)
178197
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)
179206
}

0 commit comments

Comments
 (0)