Skip to content

Commit 315f22f

Browse files
committed
Emit a warning if found multiple core for same arch
Also try to avoid failure by choosing one randomly (from a user POW this is perfectly acceptable since the erratic behaviour is due to a bug in Board Manager core). The warning reports the full path of the folder for easy copy/paste operations
1 parent d3c3646 commit 315f22f

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/arduino.cc/builder/constants/constants.go

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ const LOG_LEVEL_INFO = "info"
146146
const LOG_LEVEL_WARN = "warn"
147147
const MSG_ARCH_FOLDER_NOT_SUPPORTED = "'arch' folder is no longer supported! See http://goo.gl/gfFJzU for more information"
148148
const MSG_BOARD_UNKNOWN = "Board {0} (platform {1}, package {2}) is unknown"
149+
const MSG_BOARD_MULTIPLE_CORES = "Folder {0} contains {1} packages for {2} architecture, please manually remove the unwanted ones"
149150
const MSG_BOOTLOADER_FILE_MISSING = "Bootloader file specified but missing: {0}"
150151
const MSG_BUILD_OPTIONS_CHANGED = "Build options changed, rebuilding all"
151152
const MSG_CANT_FIND_SKETCH_IN_PATH = "Unable to find {0} in {1}"

src/arduino.cc/builder/hardware_loader.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ package builder
3232
import (
3333
"os"
3434
"path/filepath"
35+
"strconv"
3536

3637
"arduino.cc/builder/constants"
3738
"arduino.cc/builder/i18n"
@@ -132,11 +133,16 @@ func loadPackage(targetPackage *types.Package, folder string, logger i18n.Logger
132133

133134
_, err := os.Stat(filepath.Join(subfolderPath, constants.FILE_BOARDS_TXT))
134135
if err != nil && os.IsNotExist(err) {
135-
theOnlySubfolder, err := utils.TheOnlySubfolderOf(subfolderPath)
136+
theOnlySubfolder, numSubfolders, err := utils.TheOnlySubfolderOf(subfolderPath)
136137
if err != nil {
137138
return i18n.WrapError(err)
138139
}
139140

141+
if numSubfolders > 1 {
142+
i18n.ErrorfWithLogger(logger, constants.MSG_BOARD_MULTIPLE_CORES,
143+
subfolderPath, strconv.Itoa(numSubfolders), platformId)
144+
}
145+
140146
if theOnlySubfolder != constants.EMPTY_STRING {
141147
subfolderPath = filepath.Join(subfolderPath, theOnlySubfolder)
142148
}

src/arduino.cc/builder/utils/utils.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -279,17 +279,17 @@ func ReadFileToRows(file string) ([]string, error) {
279279
return strings.Split(txt, "\n"), nil
280280
}
281281

282-
func TheOnlySubfolderOf(folder string) (string, error) {
282+
func TheOnlySubfolderOf(folder string) (string, int, error) {
283283
subfolders, err := ReadDirFiltered(folder, FilterDirs)
284284
if err != nil {
285-
return constants.EMPTY_STRING, i18n.WrapError(err)
285+
return constants.EMPTY_STRING, 0, i18n.WrapError(err)
286286
}
287287

288-
if len(subfolders) != 1 {
289-
return constants.EMPTY_STRING, nil
288+
if len(subfolders) == 0 {
289+
return constants.EMPTY_STRING, 0, nil
290290
}
291291

292-
return subfolders[0].Name(), nil
292+
return subfolders[0].Name(), len(subfolders), nil
293293
}
294294

295295
func FilterOutFoldersByNames(folders []os.FileInfo, names ...string) []os.FileInfo {

0 commit comments

Comments
 (0)