Skip to content

Commit 70099c8

Browse files
author
Federico Fissore
committed
Updating AVR, SAM and SAMD cores to the latest; updating related tests as well
Signed-off-by: Federico Fissore <[email protected]>
1 parent 5246463 commit 70099c8

File tree

5 files changed

+99
-36
lines changed

5 files changed

+99
-36
lines changed

src/arduino.cc/builder/test/builder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func TestBuilderBridgeSAM(t *testing.T) {
201201

202202
_, err = os.Stat(filepath.Join(buildPath, constants.FOLDER_CORE, "syscalls_sam3.c.o"))
203203
NoError(t, err)
204-
_, err = os.Stat(filepath.Join(buildPath, constants.FOLDER_CORE, "USB", "HID.cpp.o"))
204+
_, err = os.Stat(filepath.Join(buildPath, constants.FOLDER_CORE, "USB", "PluggableUSB.cpp.o"))
205205
NoError(t, err)
206206
_, err = os.Stat(filepath.Join(buildPath, constants.FOLDER_CORE, "avr", "dtostrf.c.d"))
207207
NoError(t, err)

src/arduino.cc/builder/test/helper_tools_downloader.go

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,25 @@ type Core struct {
8484

8585
func DownloadCoresAndToolsAndLibraries(t *testing.T) {
8686
cores := []Core{
87-
Core{Maintainer: "arduino", Arch: "avr", Version: "1.6.8"},
88-
Core{Maintainer: "arduino", Arch: "sam", Version: "1.6.4"},
87+
Core{Maintainer: "arduino", Arch: "avr", Version: "1.6.9"},
88+
Core{Maintainer: "arduino", Arch: "sam", Version: "1.6.5"},
8989
}
9090

9191
boardsManagerCores := []Core{
92-
Core{Maintainer: "arduino", Arch: "samd", Version: "1.6.1"},
92+
Core{Maintainer: "arduino", Arch: "samd", Version: "1.6.2"},
9393
}
9494

9595
boardsManagerRedBearCores := []Core{
9696
Core{Maintainer: "RedBearLab", Arch: "avr", Version: "1.0.0", Url: "https://redbearlab.github.io/arduino/Blend/blend_boards.zip"},
9797
}
9898

99+
toolsMultipleVersions := []Tool{
100+
Tool{Name: "bossac", Version: "1.6.1-arduino"},
101+
Tool{Name: "bossac", Version: "1.5-arduino"},
102+
}
103+
99104
tools := []Tool{
100105
Tool{Name: "avrdude", Version: "6.0.1-arduino5"},
101-
Tool{Name: "bossac", Version: "1.3a-arduino"},
102-
Tool{Name: "bossac", Version: "1.5-arduino"},
103106
Tool{Name: "avr-gcc", Version: "4.8.1-arduino5"},
104107
Tool{Name: "arm-none-eabi-gcc", Version: "4.8.3-2014q1"},
105108
Tool{Name: "coan", Version: "5.2", OsUrls: []OsUrl{
@@ -133,7 +136,7 @@ func DownloadCoresAndToolsAndLibraries(t *testing.T) {
133136
Library{Name: "Robot IR Remote", Version: "1.0.2"},
134137
}
135138

136-
download(t, cores, boardsManagerCores, boardsManagerRedBearCores, tools, boardsManagerTools, boardsManagerRFduinoTools, libraries)
139+
download(t, cores, boardsManagerCores, boardsManagerRedBearCores, tools, toolsMultipleVersions, boardsManagerTools, boardsManagerRFduinoTools, libraries)
137140

138141
patchFiles(t)
139142
}
@@ -157,7 +160,7 @@ func patchFiles(t *testing.T) {
157160
}
158161
}
159162

160-
func download(t *testing.T, cores, boardsManagerCores, boardsManagerRedBearCores []Core, tools, boardsManagerTools, boardsManagerRFduinoTools []Tool, libraries []Library) {
163+
func download(t *testing.T, cores, boardsManagerCores, boardsManagerRedBearCores []Core, tools, toolsMultipleVersions, boardsManagerTools, boardsManagerRFduinoTools []Tool, libraries []Library) {
161164
allCoresDownloaded, err := allCoresAlreadyDownloadedAndUnpacked(HARDWARE_FOLDER, cores)
162165
NoError(t, err)
163166
if allCoresDownloaded &&
@@ -166,6 +169,7 @@ func download(t *testing.T, cores, boardsManagerCores, boardsManagerRedBearCores
166169
allBoardsManagerToolsAlreadyDownloadedAndUnpacked(BOARD_MANAGER_FOLDER, boardsManagerTools) &&
167170
allBoardsManagerToolsAlreadyDownloadedAndUnpacked(BOARD_MANAGER_FOLDER, boardsManagerRFduinoTools) &&
168171
allToolsAlreadyDownloadedAndUnpacked(TOOLS_FOLDER, tools) &&
172+
allToolsAlreadyDownloadedAndUnpacked(TOOLS_FOLDER, toolsMultipleVersions) &&
169173
allLibrariesAlreadyDownloadedAndUnpacked(LIBRARIES_FOLDER, libraries) {
170174
return
171175
}
@@ -182,6 +186,9 @@ func download(t *testing.T, cores, boardsManagerCores, boardsManagerRedBearCores
182186
err = downloadTools(tools, index)
183187
NoError(t, err)
184188

189+
err = downloadToolsMultipleVersions(toolsMultipleVersions, index)
190+
NoError(t, err)
191+
185192
err = downloadBoardsManagerTools(boardsManagerTools, index)
186193
NoError(t, err)
187194

@@ -279,7 +286,36 @@ func downloadTools(tools []Tool, index map[string]interface{}) error {
279286
if err != nil {
280287
return utils.WrapError(err)
281288
}
282-
err = downloadAndUnpackTool(tool, url, TOOLS_FOLDER)
289+
err = downloadAndUnpackTool(tool, url, TOOLS_FOLDER, true)
290+
if err != nil {
291+
return utils.WrapError(err)
292+
}
293+
}
294+
295+
return nil
296+
}
297+
298+
func downloadToolsMultipleVersions(tools []Tool, index map[string]interface{}) error {
299+
host := translateGOOSGOARCHToPackageIndexValue()
300+
301+
for _, tool := range tools {
302+
if !toolAlreadyDownloadedAndUnpacked(TOOLS_FOLDER, tool) {
303+
_, err := os.Stat(filepath.Join(TOOLS_FOLDER, tool.Name))
304+
if err == nil {
305+
err = os.RemoveAll(filepath.Join(TOOLS_FOLDER, tool.Name))
306+
if err != nil {
307+
return utils.WrapError(err)
308+
}
309+
}
310+
}
311+
}
312+
313+
for _, tool := range tools {
314+
url, err := findToolUrl(index, tool, host)
315+
if err != nil {
316+
return utils.WrapError(err)
317+
}
318+
err = downloadAndUnpackTool(tool, url, TOOLS_FOLDER, false)
283319
if err != nil {
284320
return utils.WrapError(err)
285321
}
@@ -422,6 +458,14 @@ func downloadAndUnpackCore(core Core, url string, targetPath string) error {
422458
}
423459
defer os.RemoveAll(unpackFolder)
424460

461+
_, err = os.Stat(filepath.Join(targetPath, core.Maintainer, core.Arch))
462+
if err == nil {
463+
err = os.RemoveAll(filepath.Join(targetPath, core.Maintainer, core.Arch))
464+
if err != nil {
465+
return utils.WrapError(err)
466+
}
467+
}
468+
425469
if len(files) == 1 && files[0].IsDir() {
426470
err = os.MkdirAll(filepath.Join(targetPath, core.Maintainer), os.FileMode(0755))
427471
if err != nil {
@@ -463,6 +507,14 @@ func downloadAndUnpackBoardManagerCore(core Core, url string, targetPath string)
463507
}
464508
defer os.RemoveAll(unpackFolder)
465509

510+
_, err = os.Stat(filepath.Join(targetPath, core.Maintainer, "hardware", core.Arch))
511+
if err == nil {
512+
err = os.RemoveAll(filepath.Join(targetPath, core.Maintainer, "hardware", core.Arch))
513+
if err != nil {
514+
return utils.WrapError(err)
515+
}
516+
}
517+
466518
if len(files) == 1 && files[0].IsDir() {
467519
err = os.MkdirAll(filepath.Join(targetPath, core.Maintainer, "hardware", core.Arch), os.FileMode(0755))
468520
if err != nil {
@@ -529,7 +581,7 @@ func downloadAndUnpackBoardsManagerTool(tool Tool, url string, targetPath string
529581
return nil
530582
}
531583

532-
func downloadAndUnpackTool(tool Tool, url string, targetPath string) error {
584+
func downloadAndUnpackTool(tool Tool, url string, targetPath string, deleteIfMissing bool) error {
533585
if toolAlreadyDownloadedAndUnpacked(targetPath, tool) {
534586
return nil
535587
}
@@ -545,11 +597,13 @@ func downloadAndUnpackTool(tool Tool, url string, targetPath string) error {
545597
}
546598
defer os.RemoveAll(unpackFolder)
547599

548-
_, err = os.Stat(filepath.Join(targetPath, tool.Name))
549-
if err == nil {
550-
err = os.RemoveAll(filepath.Join(targetPath, tool.Name))
551-
if err != nil {
552-
return utils.WrapError(err)
600+
if deleteIfMissing {
601+
_, err = os.Stat(filepath.Join(targetPath, tool.Name))
602+
if err == nil {
603+
err = os.RemoveAll(filepath.Join(targetPath, tool.Name))
604+
if err != nil {
605+
return utils.WrapError(err)
606+
}
553607
}
554608
}
555609

src/arduino.cc/builder/test/libraries_loader_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func TestLoadLibrariesAVR(t *testing.T) {
6969
require.Equal(t, Abs(t, filepath.Join("libraries")), librariesFolders[2])
7070

7171
libraries := context[constants.CTX_LIBRARIES].([]*types.Library)
72-
require.Equal(t, 16, len(libraries))
72+
require.Equal(t, 17, len(libraries))
7373

7474
sort.Sort(ByLibraryName(libraries))
7575

@@ -109,6 +109,8 @@ func TestLoadLibrariesAVR(t *testing.T) {
109109
idx++
110110
require.Equal(t, "FakeAudio", libraries[idx].Name)
111111
idx++
112+
require.Equal(t, "HID", libraries[idx].Name)
113+
idx++
112114
require.Equal(t, "IRremote", libraries[idx].Name)
113115
idx++
114116
require.Equal(t, "Robot_IR_Remote", libraries[idx].Name)
@@ -173,7 +175,7 @@ func TestLoadLibrariesSAM(t *testing.T) {
173175
require.Equal(t, Abs(t, filepath.Join("libraries")), librariesFolders[2])
174176

175177
libraries := context[constants.CTX_LIBRARIES].([]*types.Library)
176-
require.Equal(t, 14, len(libraries))
178+
require.Equal(t, 15, len(libraries))
177179

178180
sort.Sort(ByLibraryName(libraries))
179181

@@ -192,6 +194,8 @@ func TestLoadLibrariesSAM(t *testing.T) {
192194
idx++
193195
require.Equal(t, "FakeAudio", libraries[idx].Name)
194196
idx++
197+
require.Equal(t, "HID", libraries[idx].Name)
198+
idx++
195199
require.Equal(t, "IRremote", libraries[idx].Name)
196200
idx++
197201
require.Equal(t, "Robot_IR_Remote", libraries[idx].Name)

src/arduino.cc/builder/test/setup_build_properties_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ func TestSetupBuildProperties(t *testing.T) {
8787

8888
require.Equal(t, Abs(t, "./downloaded_tools/arm-none-eabi-gcc/4.8.3-2014q1"), buildProperties["runtime.tools.arm-none-eabi-gcc.path"])
8989
require.Equal(t, Abs(t, "./downloaded_tools/arm-none-eabi-gcc/4.8.3-2014q1"), buildProperties["runtime.tools.arm-none-eabi-gcc-4.8.3-2014q1.path"])
90-
require.Equal(t, Abs(t, "./downloaded_tools/bossac/1.3a-arduino"), buildProperties["runtime.tools.bossac-1.3a-arduino.path"])
90+
require.Equal(t, Abs(t, "./downloaded_tools/bossac/1.6.1-arduino"), buildProperties["runtime.tools.bossac-1.6.1-arduino.path"])
9191
require.Equal(t, Abs(t, "./downloaded_tools/bossac/1.5-arduino"), buildProperties["runtime.tools.bossac-1.5-arduino.path"])
92-
require.True(t, buildProperties["runtime.tools.bossac.path"] == Abs(t, "./downloaded_tools/bossac/1.3a-arduino") || buildProperties["runtime.tools.bossac.path"] == Abs(t, "./downloaded_tools/bossac/1.5-arduino"))
92+
require.True(t, buildProperties["runtime.tools.bossac.path"] == Abs(t, "./downloaded_tools/bossac/1.6.1-arduino") || buildProperties["runtime.tools.bossac.path"] == Abs(t, "./downloaded_tools/bossac/1.5-arduino"))
9393
require.Equal(t, Abs(t, "./downloaded_tools/avrdude/6.0.1-arduino5"), buildProperties["runtime.tools.avrdude.path"])
9494
require.Equal(t, Abs(t, "./downloaded_tools/avrdude/6.0.1-arduino5"), buildProperties["runtime.tools.avrdude-6.0.1-arduino5.path"])
9595
require.Equal(t, Abs(t, "./downloaded_tools/avr-gcc/4.8.1-arduino5"), buildProperties["runtime.tools.avr-gcc.path"])
@@ -228,9 +228,9 @@ func TestSetupBuildPropertiesWithMissingPropsFromParentPlatformTxtFiles(t *testi
228228

229229
require.Equal(t, Abs(t, "./downloaded_tools/arm-none-eabi-gcc/4.8.3-2014q1"), buildProperties["runtime.tools.arm-none-eabi-gcc.path"])
230230
require.Equal(t, Abs(t, "./downloaded_tools/arm-none-eabi-gcc/4.8.3-2014q1"), buildProperties["runtime.tools.arm-none-eabi-gcc-4.8.3-2014q1.path"])
231-
require.Equal(t, Abs(t, "./downloaded_tools/bossac/1.3a-arduino"), buildProperties["runtime.tools.bossac-1.3a-arduino.path"])
231+
require.Equal(t, Abs(t, "./downloaded_tools/bossac/1.6.1-arduino"), buildProperties["runtime.tools.bossac-1.6.1-arduino.path"])
232232
require.Equal(t, Abs(t, "./downloaded_tools/bossac/1.5-arduino"), buildProperties["runtime.tools.bossac-1.5-arduino.path"])
233-
require.True(t, buildProperties["runtime.tools.bossac.path"] == Abs(t, "./downloaded_tools/bossac/1.3a-arduino") || buildProperties["runtime.tools.bossac.path"] == Abs(t, "./downloaded_tools/bossac/1.5-arduino"))
233+
require.True(t, buildProperties["runtime.tools.bossac.path"] == Abs(t, "./downloaded_tools/bossac/1.6.1-arduino") || buildProperties["runtime.tools.bossac.path"] == Abs(t, "./downloaded_tools/bossac/1.5-arduino"))
234234
require.Equal(t, Abs(t, "./downloaded_tools/avrdude/6.0.1-arduino5"), buildProperties["runtime.tools.avrdude.path"])
235235
require.Equal(t, Abs(t, "./downloaded_tools/avrdude/6.0.1-arduino5"), buildProperties["runtime.tools.avrdude-6.0.1-arduino5.path"])
236236
require.Equal(t, Abs(t, "./downloaded_tools/avr-gcc/4.8.1-arduino5"), buildProperties["runtime.tools.avr-gcc.path"])

src/arduino.cc/builder/test/tools_loader_test.go

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,26 @@ func TestLoadTools(t *testing.T) {
6868

6969
sort.Sort(ByToolIDAndVersion(tools))
7070

71-
require.Equal(t, "arm-none-eabi-gcc", tools[0].Name)
72-
require.Equal(t, "4.8.3-2014q1", tools[0].Version)
73-
require.Equal(t, Abs(t, "./downloaded_tools/arm-none-eabi-gcc/4.8.3-2014q1"), tools[0].Folder)
74-
require.Equal(t, "avr-gcc", tools[1].Name)
75-
require.Equal(t, "4.8.1-arduino5", tools[1].Version)
76-
require.Equal(t, Abs(t, "./downloaded_tools/avr-gcc/4.8.1-arduino5"), tools[1].Folder)
77-
require.Equal(t, "avrdude", tools[2].Name)
78-
require.Equal(t, "6.0.1-arduino5", tools[2].Version)
79-
require.Equal(t, Abs(t, "./downloaded_tools/avrdude/6.0.1-arduino5"), tools[2].Folder)
80-
require.Equal(t, "bossac", tools[3].Name)
81-
require.Equal(t, "1.3a-arduino", tools[3].Version)
82-
require.Equal(t, Abs(t, "./downloaded_tools/bossac/1.3a-arduino"), tools[3].Folder)
83-
require.Equal(t, "bossac", tools[4].Name)
84-
require.Equal(t, "1.5-arduino", tools[4].Version)
85-
require.Equal(t, Abs(t, "./downloaded_tools/bossac/1.5-arduino"), tools[4].Folder)
71+
idx := 0
72+
require.Equal(t, "arm-none-eabi-gcc", tools[idx].Name)
73+
require.Equal(t, "4.8.3-2014q1", tools[idx].Version)
74+
require.Equal(t, Abs(t, "./downloaded_tools/arm-none-eabi-gcc/4.8.3-2014q1"), tools[idx].Folder)
75+
idx++
76+
require.Equal(t, "avr-gcc", tools[idx].Name)
77+
require.Equal(t, "4.8.1-arduino5", tools[idx].Version)
78+
require.Equal(t, Abs(t, "./downloaded_tools/avr-gcc/4.8.1-arduino5"), tools[idx].Folder)
79+
idx++
80+
require.Equal(t, "avrdude", tools[idx].Name)
81+
require.Equal(t, "6.0.1-arduino5", tools[idx].Version)
82+
require.Equal(t, Abs(t, "./downloaded_tools/avrdude/6.0.1-arduino5"), tools[idx].Folder)
83+
idx++
84+
require.Equal(t, "bossac", tools[idx].Name)
85+
require.Equal(t, "1.5-arduino", tools[idx].Version)
86+
require.Equal(t, Abs(t, "./downloaded_tools/bossac/1.5-arduino"), tools[idx].Folder)
87+
idx++
88+
require.Equal(t, "bossac", tools[idx].Name)
89+
require.Equal(t, "1.6.1-arduino", tools[idx].Version)
90+
require.Equal(t, Abs(t, "./downloaded_tools/bossac/1.6.1-arduino"), tools[idx].Folder)
8691
}
8792

8893
func TestLoadToolsWithBoardManagerFolderStructure(t *testing.T) {

0 commit comments

Comments
 (0)