Skip to content

Commit 1c51bee

Browse files
committed
[TO BE SQUAHSED] address naming and conventions issues
1 parent cc60774 commit 1c51bee

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ const MSG_CANT_FIND_SKETCH_IN_PATH = "Unable to find {0} in {1}"
213213
const MSG_INVALID_QUOTING = "Invalid quoting: no closing [{0}] char found."
214214
const MSG_LIB_LEGACY = "(legacy)"
215215
const MSG_LIBRARIES_MULTIPLE_LIBS_FOUND_FOR = "Multiple libraries were found for \"{0}\""
216-
const MSG_CORES_MULTIPLE_CORES_FOUND_FOR = "Multiple versions of {0} core were found, using {1}"
216+
const MSG_CORES_MULTIPLE_VERSIONS_FOUND = "Multiple versions of {0} core were found, using {1}"
217217
const MSG_LIBRARIES_NOT_USED = " Not used: {0}"
218218
const MSG_LIBRARIES_USED = " Used: {0}"
219219
const MSG_LIBRARY_CAN_USE_SRC_AND_UTILITY_FOLDERS = "Library can't use both 'src' and 'utility' folders. Double check {0}"

src/arduino.cc/builder/hardware_loader.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,18 @@ func loadPackage(targetPackage *types.Package, folder string, logger i18n.Logger
131131

132132
_, err := os.Stat(filepath.Join(subfolderPath, constants.FILE_BOARDS_TXT))
133133
if err != nil && os.IsNotExist(err) {
134-
theOnlySubfolder, err := utils.TheBestSubfolderOf(subfolderPath)
134+
theBestSubfolder, multipleResults, err := utils.TheBestSubfolderOf(subfolderPath)
135135
if err != nil {
136-
if theOnlySubfolder != constants.EMPTY_STRING {
136+
return utils.WrapError(err)
137+
} else {
138+
if multipleResults == true {
137139
logger := context[constants.CTX_LOGGER].(i18n.Logger)
138-
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_WARN, constants.MSG_CORES_MULTIPLE_CORES_FOUND_FOR, platformId, err.Error())
139-
} else {
140-
return utils.WrapError(err)
140+
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_WARN, constants.MSG_CORES_MULTIPLE_VERSIONS_FOUND, platformId, theBestSubfolder)
141141
}
142142
}
143143

144-
if theOnlySubfolder != constants.EMPTY_STRING {
145-
subfolderPath = filepath.Join(subfolderPath, theOnlySubfolder)
144+
if theBestSubfolder != constants.EMPTY_STRING {
145+
subfolderPath = filepath.Join(subfolderPath, theBestSubfolder)
146146
}
147147
}
148148

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

+4-7
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,10 @@ func ReadFileToRows(file string) ([]string, error) {
359359
return strings.Split(txt, "\n"), nil
360360
}
361361

362-
func TheBestSubfolderOf(folder string) (string, error) {
362+
func TheBestSubfolderOf(folder string) (string, bool, error) {
363363
subfolders, err := ReadDirFiltered(folder, FilterDirs)
364364
if err != nil {
365-
return constants.EMPTY_STRING, WrapError(err)
365+
return constants.EMPTY_STRING, false, WrapError(err)
366366
}
367367

368368
if len(subfolders) > 0 {
@@ -375,12 +375,9 @@ func TheBestSubfolderOf(folder string) (string, error) {
375375
latest_index = i
376376
}
377377
}
378-
if len(subfolders) > 1 {
379-
err = errors.New(subfolders[latest_index].Name())
380-
}
381-
return subfolders[latest_index].Name(), err
378+
return subfolders[latest_index].Name(), (len(subfolders) > 1), err
382379
} else {
383-
return constants.EMPTY_STRING, nil
380+
return constants.EMPTY_STRING, false, nil
384381
}
385382
}
386383

0 commit comments

Comments
 (0)