Skip to content

Commit

Permalink
[TO BE SQUAHSED] address naming and conventions issues
Browse files Browse the repository at this point in the history
  • Loading branch information
facchinm committed Dec 16, 2015
1 parent cc60774 commit 1c51bee
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/arduino.cc/builder/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
14 changes: 7 additions & 7 deletions src/arduino.cc/builder/hardware_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
11 changes: 4 additions & 7 deletions src/arduino.cc/builder/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
}

Expand Down

0 comments on commit 1c51bee

Please sign in to comment.