Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcc60774

Browse files
committed
Don't fail if multiple core version are found
use the latest one based on semvera dependency was added (github.com/blang/semver), hopefully we'll use it somwhere else since it's really usefulSigned-off-by: Martino Facchin <m.facchin@arduino.cc>
1 parentdb653b2 commitcc60774

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ const MSG_CANT_FIND_SKETCH_IN_PATH = "Unable to find {0} in {1}"
213213
constMSG_INVALID_QUOTING="Invalid quoting: no closing [{0}] char found."
214214
constMSG_LIB_LEGACY="(legacy)"
215215
constMSG_LIBRARIES_MULTIPLE_LIBS_FOUND_FOR="Multiple libraries were found for\"{0}\""
216+
constMSG_CORES_MULTIPLE_CORES_FOUND_FOR="Multiple versions of {0} core were found, using {1}"
216217
constMSG_LIBRARIES_NOT_USED=" Not used: {0}"
217218
constMSG_LIBRARIES_USED=" Used: {0}"
218219
constMSG_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‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func (s *HardwareLoader) Run(context map[string]interface{}) error {
8484
}
8585

8686
targetPackage:=getOrCreatePackage(packages,packageId)
87-
err=loadPackage(targetPackage,subfolderPath,logger)
87+
err=loadPackage(targetPackage,subfolderPath,logger,context)
8888
iferr!=nil {
8989
returnutils.WrapError(err)
9090
}
@@ -110,7 +110,7 @@ func getOrCreatePackage(packages *types.Packages, packageId string) *types.Packa
110110
return&targetPackage
111111
}
112112

113-
funcloadPackage(targetPackage*types.Package,folderstring,logger i18n.Logger)error {
113+
funcloadPackage(targetPackage*types.Package,folderstring,logger i18n.Logger,contextmap[string]interface{})error {
114114
packagePlatformTxt,err:=props.SafeLoad(filepath.Join(folder,constants.FILE_PLATFORM_TXT),logger)
115115
iferr!=nil {
116116
returnutils.WrapError(err)
@@ -131,9 +131,14 @@ func loadPackage(targetPackage *types.Package, folder string, logger i18n.Logger
131131

132132
_,err:=os.Stat(filepath.Join(subfolderPath,constants.FILE_BOARDS_TXT))
133133
iferr!=nil&&os.IsNotExist(err) {
134-
theOnlySubfolder,err:=utils.TheOnlySubfolderOf(subfolderPath)
134+
theOnlySubfolder,err:=utils.TheBestSubfolderOf(subfolderPath)
135135
iferr!=nil {
136-
returnutils.WrapError(err)
136+
iftheOnlySubfolder!=constants.EMPTY_STRING {
137+
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+
returnutils.WrapError(err)
141+
}
137142
}
138143

139144
iftheOnlySubfolder!=constants.EMPTY_STRING {

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"arduino.cc/builder/types"
3737
"crypto/md5"
3838
"encoding/hex"
39+
"github.com/blang/semver"
3940
"github.com/go-errors/errors"
4041
"io/ioutil"
4142
"os"
@@ -358,17 +359,29 @@ func ReadFileToRows(file string) ([]string, error) {
358359
returnstrings.Split(txt,"\n"),nil
359360
}
360361

361-
funcTheOnlySubfolderOf(folderstring) (string,error) {
362+
funcTheBestSubfolderOf(folderstring) (string,error) {
362363
subfolders,err:=ReadDirFiltered(folder,FilterDirs)
363364
iferr!=nil {
364365
returnconstants.EMPTY_STRING,WrapError(err)
365366
}
366367

367-
iflen(subfolders)!=1 {
368+
iflen(subfolders)>0 {
369+
latest,_:=semver.Make(subfolders[0].Name())
370+
latest_index:=0
371+
fori,_:=rangesubfolders {
372+
test,_:=semver.Make(subfolders[i].Name())
373+
iftest.GT(latest) {
374+
latest=test
375+
latest_index=i
376+
}
377+
}
378+
iflen(subfolders)>1 {
379+
err=errors.New(subfolders[latest_index].Name())
380+
}
381+
returnsubfolders[latest_index].Name(),err
382+
}else {
368383
returnconstants.EMPTY_STRING,nil
369384
}
370-
371-
returnsubfolders[0].Name(),nil
372385
}
373386

374387
funcFilterOutFoldersByNames(folders []os.FileInfo,names...string) []os.FileInfo {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp