From 1c51bee2dcf866b388bc9bc90eb6db738053c837 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Wed, 16 Dec 2015 15:37:55 +0100 Subject: [PATCH] [TO BE SQUAHSED] address naming and conventions issues --- src/arduino.cc/builder/constants/constants.go | 2 +- src/arduino.cc/builder/hardware_loader.go | 14 +++++++------- src/arduino.cc/builder/utils/utils.go | 11 ++++------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/arduino.cc/builder/constants/constants.go b/src/arduino.cc/builder/constants/constants.go index f25fd477..b289ee58 100644 --- a/src/arduino.cc/builder/constants/constants.go +++ b/src/arduino.cc/builder/constants/constants.go @@ -213,7 +213,7 @@ const MSG_CANT_FIND_SKETCH_IN_PATH = "Unable to find {0} in {1}" const MSG_INVALID_QUOTING = "Invalid quoting: no closing [{0}] char found." const MSG_LIB_LEGACY = "(legacy)" const MSG_LIBRARIES_MULTIPLE_LIBS_FOUND_FOR = "Multiple libraries were found for \"{0}\"" -const MSG_CORES_MULTIPLE_CORES_FOUND_FOR = "Multiple versions of {0} core were found, using {1}" +const MSG_CORES_MULTIPLE_VERSIONS_FOUND = "Multiple versions of {0} core were found, using {1}" const MSG_LIBRARIES_NOT_USED = " Not used: {0}" const MSG_LIBRARIES_USED = " Used: {0}" const MSG_LIBRARY_CAN_USE_SRC_AND_UTILITY_FOLDERS = "Library can't use both 'src' and 'utility' folders. Double check {0}" diff --git a/src/arduino.cc/builder/hardware_loader.go b/src/arduino.cc/builder/hardware_loader.go index f6bd8125..391a37ca 100644 --- a/src/arduino.cc/builder/hardware_loader.go +++ b/src/arduino.cc/builder/hardware_loader.go @@ -131,18 +131,18 @@ func loadPackage(targetPackage *types.Package, folder string, logger i18n.Logger _, err := os.Stat(filepath.Join(subfolderPath, constants.FILE_BOARDS_TXT)) if err != nil && os.IsNotExist(err) { - theOnlySubfolder, err := utils.TheBestSubfolderOf(subfolderPath) + theBestSubfolder, multipleResults, err := utils.TheBestSubfolderOf(subfolderPath) if err != nil { - if theOnlySubfolder != constants.EMPTY_STRING { + return utils.WrapError(err) + } else { + if multipleResults == true { logger := context[constants.CTX_LOGGER].(i18n.Logger) - logger.Fprintln(os.Stdout, constants.LOG_LEVEL_WARN, constants.MSG_CORES_MULTIPLE_CORES_FOUND_FOR, platformId, err.Error()) - } else { - return utils.WrapError(err) + logger.Fprintln(os.Stdout, constants.LOG_LEVEL_WARN, constants.MSG_CORES_MULTIPLE_VERSIONS_FOUND, platformId, theBestSubfolder) } } - if theOnlySubfolder != constants.EMPTY_STRING { - subfolderPath = filepath.Join(subfolderPath, theOnlySubfolder) + if theBestSubfolder != constants.EMPTY_STRING { + subfolderPath = filepath.Join(subfolderPath, theBestSubfolder) } } diff --git a/src/arduino.cc/builder/utils/utils.go b/src/arduino.cc/builder/utils/utils.go index 31940eba..dd657639 100644 --- a/src/arduino.cc/builder/utils/utils.go +++ b/src/arduino.cc/builder/utils/utils.go @@ -359,10 +359,10 @@ func ReadFileToRows(file string) ([]string, error) { return strings.Split(txt, "\n"), nil } -func TheBestSubfolderOf(folder string) (string, error) { +func TheBestSubfolderOf(folder string) (string, bool, error) { subfolders, err := ReadDirFiltered(folder, FilterDirs) if err != nil { - return constants.EMPTY_STRING, WrapError(err) + return constants.EMPTY_STRING, false, WrapError(err) } if len(subfolders) > 0 { @@ -375,12 +375,9 @@ func TheBestSubfolderOf(folder string) (string, error) { latest_index = i } } - if len(subfolders) > 1 { - err = errors.New(subfolders[latest_index].Name()) - } - return subfolders[latest_index].Name(), err + return subfolders[latest_index].Name(), (len(subfolders) > 1), err } else { - return constants.EMPTY_STRING, nil + return constants.EMPTY_STRING, false, nil } }