@@ -846,6 +846,57 @@ func LibraryPropertiesArchitecturesFieldLTMinLength() (result checkresult.Type,
846846 return checkresult .Pass , ""
847847}
848848
849+ // LibraryPropertiesArchitecturesFieldAlias checks whether an alias architecture name is present, but not its true Arduino architecture name.
850+ func LibraryPropertiesArchitecturesFieldSoloAlias () (result checkresult.Type , output string ) {
851+ if checkdata .LibraryPropertiesLoadError () != nil {
852+ return checkresult .NotRun , "Couldn't load library.properties"
853+ }
854+
855+ architectures , ok := checkdata .LibraryProperties ().GetOk ("architectures" )
856+ if ! ok {
857+ return checkresult .Skip , "Field not present"
858+ }
859+
860+ architecturesList := commaSeparatedToList (strings .ToLower (architectures ))
861+
862+ // Must be all lowercase (there is a separate check for incorrect architecture case).
863+ var aliases = map [string ][]string {
864+ "atmelavr" : {"avr" },
865+ "atmelmegaavr" : {"megaavr" },
866+ "atmelsam" : {"sam" , "samd" },
867+ "espressif32" : {"esp32" },
868+ "espressif8266" : {"esp8266" },
869+ "intel_arc32" : {"arc32" },
870+ "nordicnrf52" : {"nRF5" , "nrf52" , "mbed" },
871+ }
872+
873+ trueArchitecturePresent := func (trueArchitecturesQuery []string ) bool {
874+ for _ , trueArchitectureQuery := range trueArchitecturesQuery {
875+ for _ , architecture := range architecturesList {
876+ if architecture == trueArchitectureQuery {
877+ return true
878+ }
879+ }
880+ }
881+
882+ return false
883+ }
884+
885+ soloAliases := []string {}
886+ for _ , architecture := range architecturesList {
887+ trueEquivalents , isAlias := aliases [architecture ]
888+ if isAlias && ! trueArchitecturePresent (trueEquivalents ) {
889+ soloAliases = append (soloAliases , architecture )
890+ }
891+ }
892+
893+ if len (soloAliases ) > 0 {
894+ return checkresult .Fail , strings .Join (soloAliases , ", " )
895+ }
896+
897+ return checkresult .Pass , ""
898+ }
899+
849900// LibraryPropertiesDependsFieldDisallowedCharacters checks for disallowed characters in the library.properties "depends" field.
850901func LibraryPropertiesDependsFieldDisallowedCharacters () (result checkresult.Type , output string ) {
851902 if checkdata .LibraryPropertiesLoadError () != nil {
@@ -875,11 +926,10 @@ func LibraryPropertiesDependsFieldNotInIndex() (result checkresult.Type, output
875926 return checkresult .Skip , "Field not present"
876927 }
877928
878- dependencies := strings . Split (depends , "," )
929+ dependencies := commaSeparatedToList (depends )
879930
880931 dependenciesNotInIndex := []string {}
881932 for _ , dependency := range dependencies {
882- dependency = strings .TrimSpace (dependency )
883933 if dependency == "" {
884934 continue
885935 }
@@ -959,10 +1009,9 @@ func LibraryPropertiesIncludesFieldItemNotFound() (result checkresult.Type, outp
9591009 return checkresult .Skip , "Field not present"
9601010 }
9611011
962- includesList := strings . Split (includes , "," )
1012+ includesList := commaSeparatedToList (includes )
9631013
9641014 findInclude := func (include string ) bool {
965- include = strings .TrimSpace (include )
9661015 if include == "" {
9671016 return true
9681017 }
@@ -1357,3 +1406,13 @@ func nameInLibraryManagerIndex(name string) bool {
13571406
13581407 return false
13591408}
1409+
1410+ // commaSeparatedToList returns the list equivalent of a comma-separated string.
1411+ func commaSeparatedToList (commaSeparated string ) []string {
1412+ list := []string {}
1413+ for _ , item := range strings .Split (commaSeparated , "," ) {
1414+ list = append (list , strings .TrimSpace (item ))
1415+ }
1416+
1417+ return list
1418+ }
0 commit comments