Skip to content

Commit e3104f5

Browse files
author
Federico Fissore
committed
Switched to AVR core 1.6.8
Added mechanism for upgrading cores used for testing Signed-off-by: Federico Fissore <[email protected]>
1 parent bbe848a commit e3104f5

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

Diff for: src/arduino.cc/builder/test/helper_tools_downloader.go

+37-11
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ package test
3232
import (
3333
"arduino.cc/builder/constants"
3434
"arduino.cc/builder/gohasissues"
35+
"arduino.cc/builder/props"
3536
"arduino.cc/builder/utils"
3637
"encoding/json"
3738
"fmt"
@@ -80,7 +81,7 @@ type Core struct {
8081

8182
func DownloadCoresAndToolsAndLibraries(t *testing.T) {
8283
cores := []Core{
83-
Core{Maintainer: "arduino", Arch: "avr", Version: "1.6.7"},
84+
Core{Maintainer: "arduino", Arch: "avr", Version: "1.6.8"},
8485
Core{Maintainer: "arduino", Arch: "sam", Version: "1.6.4"},
8586
}
8687

@@ -151,7 +152,9 @@ func patch(t *testing.T) {
151152
}
152153

153154
func download(t *testing.T, cores, boardsManagerCores, boardsManagerRedBearCores []Core, tools, boardsManagerTools, boardsManagerRFduinoTools []Tool, libraries []Library) {
154-
if allCoresAlreadyDownloadedAndUnpacked(HARDWARE_FOLDER, cores) &&
155+
allCoresDownloaded, err := allCoresAlreadyDownloadedAndUnpacked(HARDWARE_FOLDER, cores)
156+
NoError(t, err)
157+
if allCoresDownloaded &&
155158
allBoardsManagerCoresAlreadyDownloadedAndUnpacked(BOARD_MANAGER_FOLDER, boardsManagerCores) &&
156159
allBoardsManagerCoresAlreadyDownloadedAndUnpacked(BOARD_MANAGER_FOLDER, boardsManagerRedBearCores) &&
157160
allBoardsManagerToolsAlreadyDownloadedAndUnpacked(BOARD_MANAGER_FOLDER, boardsManagerTools) &&
@@ -310,18 +313,37 @@ func boardManagerCoreAlreadyDownloadedAndUnpacked(targetPath string, core Core)
310313
return !os.IsNotExist(err)
311314
}
312315

313-
func allCoresAlreadyDownloadedAndUnpacked(targetPath string, cores []Core) bool {
316+
func allCoresAlreadyDownloadedAndUnpacked(targetPath string, cores []Core) (bool, error) {
314317
for _, core := range cores {
315-
if !coreAlreadyDownloadedAndUnpacked(targetPath, core) {
316-
return false
318+
alreadyDownloaded, err := coreAlreadyDownloadedAndUnpacked(targetPath, core)
319+
if err != nil {
320+
return false, utils.WrapError(err)
321+
}
322+
if !alreadyDownloaded {
323+
return false, nil
317324
}
318325
}
319-
return true
326+
return true, nil
320327
}
321328

322-
func coreAlreadyDownloadedAndUnpacked(targetPath string, core Core) bool {
323-
_, err := os.Stat(filepath.Join(targetPath, core.Maintainer, core.Arch))
324-
return !os.IsNotExist(err)
329+
func coreAlreadyDownloadedAndUnpacked(targetPath string, core Core) (bool, error) {
330+
corePath := filepath.Join(targetPath, core.Maintainer, core.Arch)
331+
332+
_, err := os.Stat(corePath)
333+
if os.IsNotExist(err) {
334+
return false, nil
335+
}
336+
platform, err := props.Load(filepath.Join(corePath, "platform.txt"))
337+
if err != nil {
338+
return false, utils.WrapError(err)
339+
}
340+
341+
if core.Version != platform["version"] {
342+
err := os.RemoveAll(corePath)
343+
return false, utils.WrapError(err)
344+
}
345+
346+
return true, nil
325347
}
326348

327349
func allBoardsManagerToolsAlreadyDownloadedAndUnpacked(targetPath string, tools []Tool) bool {
@@ -367,11 +389,15 @@ func libraryAlreadyDownloadedAndUnpacked(targetPath string, library Library) boo
367389
}
368390

369391
func downloadAndUnpackCore(core Core, url string, targetPath string) error {
370-
if coreAlreadyDownloadedAndUnpacked(targetPath, core) {
392+
alreadyDownloaded, err := coreAlreadyDownloadedAndUnpacked(targetPath, core)
393+
if err != nil {
394+
return utils.WrapError(err)
395+
}
396+
if alreadyDownloaded {
371397
return nil
372398
}
373399

374-
targetPath, err := filepath.Abs(targetPath)
400+
targetPath, err = filepath.Abs(targetPath)
375401
if err != nil {
376402
return utils.WrapError(err)
377403
}

Diff for: src/arduino.cc/builder/test/setup_build_properties_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func TestSetupBuildProperties(t *testing.T) {
7575
require.Equal(t, "ARDUINO", buildProperties[constants.BUILD_PROPERTIES_SOFTWARE])
7676

7777
require.Equal(t, "uno", buildProperties[constants.ID])
78-
require.Equal(t, "Arduino Uno", buildProperties["name"])
78+
require.Equal(t, "Arduino/Genuino Uno", buildProperties["name"])
7979
require.Equal(t, "0x2341", buildProperties["vid.0"])
8080
require.Equal(t, "\"{compiler.path}{compiler.c.cmd}\" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} \"{source_file}\" -o \"{object_file}\"", buildProperties["recipe.c.o.pattern"])
8181
require.Equal(t, "{path}/etc/avrdude.conf", buildProperties["tools.avrdude.config.path"])

0 commit comments

Comments
 (0)