@@ -820,6 +820,57 @@ func LibraryPropertiesArchitecturesFieldLTMinLength() (result checkresult.Type,
820
820
return checkresult .Pass , ""
821
821
}
822
822
823
+ // LibraryPropertiesArchitecturesFieldAlias checks whether an alias architecture name is present, but not its true Arduino architecture name.
824
+ func LibraryPropertiesArchitecturesFieldSoloAlias () (result checkresult.Type , output string ) {
825
+ if checkdata .LibraryPropertiesLoadError () != nil {
826
+ return checkresult .NotRun , "Couldn't load library.properties"
827
+ }
828
+
829
+ architectures , ok := checkdata .LibraryProperties ().GetOk ("architectures" )
830
+ if ! ok {
831
+ return checkresult .Skip , "Field not present"
832
+ }
833
+
834
+ architecturesList := commaSeparatedToList (strings .ToLower (architectures ))
835
+
836
+ // Must be all lowercase (there is a separate check for incorrect architecture case).
837
+ var aliases = map [string ][]string {
838
+ "atmelavr" : {"avr" },
839
+ "atmelmegaavr" : {"megaavr" },
840
+ "atmelsam" : {"sam" , "samd" },
841
+ "espressif32" : {"esp32" },
842
+ "espressif8266" : {"esp8266" },
843
+ "intel_arc32" : {"arc32" },
844
+ "nordicnrf52" : {"nRF5" , "nrf52" , "mbed" },
845
+ }
846
+
847
+ trueArchitecturePresent := func (trueArchitecturesQuery []string ) bool {
848
+ for _ , trueArchitectureQuery := range trueArchitecturesQuery {
849
+ for _ , architecture := range architecturesList {
850
+ if architecture == trueArchitectureQuery {
851
+ return true
852
+ }
853
+ }
854
+ }
855
+
856
+ return false
857
+ }
858
+
859
+ soloAliases := []string {}
860
+ for _ , architecture := range architecturesList {
861
+ trueEquivalents , isAlias := aliases [architecture ]
862
+ if isAlias && ! trueArchitecturePresent (trueEquivalents ) {
863
+ soloAliases = append (soloAliases , architecture )
864
+ }
865
+ }
866
+
867
+ if len (soloAliases ) > 0 {
868
+ return checkresult .Fail , strings .Join (soloAliases , ", " )
869
+ }
870
+
871
+ return checkresult .Pass , ""
872
+ }
873
+
823
874
// LibraryPropertiesDependsFieldDisallowedCharacters checks for disallowed characters in the library.properties "depends" field.
824
875
func LibraryPropertiesDependsFieldDisallowedCharacters () (result checkresult.Type , output string ) {
825
876
if checkdata .LibraryPropertiesLoadError () != nil {
@@ -849,11 +900,10 @@ func LibraryPropertiesDependsFieldNotInIndex() (result checkresult.Type, output
849
900
return checkresult .NotRun , "Field not present"
850
901
}
851
902
852
- dependencies := strings . Split (depends , "," )
903
+ dependencies := commaSeparatedToList (depends )
853
904
854
905
dependenciesNotInIndex := []string {}
855
906
for _ , dependency := range dependencies {
856
- dependency = strings .TrimSpace (dependency )
857
907
if dependency == "" {
858
908
continue
859
909
}
@@ -933,10 +983,9 @@ func LibraryPropertiesIncludesFieldItemNotFound() (result checkresult.Type, outp
933
983
return checkresult .NotRun , "Field not present"
934
984
}
935
985
936
- includesList := strings . Split (includes , "," )
986
+ includesList := commaSeparatedToList (includes )
937
987
938
988
findInclude := func (include string ) bool {
939
- include = strings .TrimSpace (include )
940
989
if include == "" {
941
990
return true
942
991
}
@@ -1339,3 +1388,12 @@ func runRequiredLibraryPropertiesFieldCheck() (bool, string) {
1339
1388
1340
1389
return true , ""
1341
1390
}
1391
+
1392
+ func commaSeparatedToList (commaSeparated string ) []string {
1393
+ list := []string {}
1394
+ for _ , item := range strings .Split (commaSeparated , "," ) {
1395
+ list = append (list , strings .TrimSpace (item ))
1396
+ }
1397
+
1398
+ return list
1399
+ }
0 commit comments