You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -117,6 +117,10 @@ Check sketches to ensure they have the correct structure.
117
117
Check a library to ensure they have the correct structure. This will also run `check_sketch_structure` on all sketches bundled with the library.
118
118
- Parameter: **libraryPath** - Path containing a library.
119
119
120
+
##### `check_library_properties searchPath'
121
+
Check [library.properties](https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#libraryproperties-file-format) metadata files for errors.
122
+
- Parameter: **searchPath** - Path containing library.properties files. The path will be searched recursively and all library.properties files found under it will be checked.
# find all folders that contain a library.properties file
1410
+
find "$normalizedSearchPath" -type f -regex '.*/[lL][iI][bB][rR][aA][rR][yY]\.[pP][rR][oO][pP][eE][rR][tT][iI][eE][sS]'|whileread -r libraryPropertiesPath;do
1411
+
1412
+
# Check for incorrect filename case
1413
+
if [[ "${libraryPropertiesPath: -18}"!='library.properties' ]];then
1414
+
echo"ERROR: $libraryPropertiesPath has incorrect filename case, which causes it to not be recognized on a filename case-sensitive OS such as Linux. It must be library.properties"
if grep --quiet --regexp='^[[:space:]]*email[[:space:]]*='<<<"$libraryProperties";then
1437
+
echo"WARNING: Use of undocumented email field in $libraryPropertiesPath. It's recommended to use the maintainer field instead, per the Arduino Library Specification."
1438
+
else
1439
+
echo"ERROR: $libraryPropertiesPath is missing required maintainer field."
local validNameRegex='^[[:space:]]*name[[:space:]]*=[[:space:]]*[a-zA-Z0-9._ -]+[[:space:]]*$'
1470
+
if! [[ "$nameLine"=~$validNameRegex ]];then
1471
+
echo"ERROR: ${libraryPropertiesPath}\'s name value uses characters not allowed by the Arduino Library Manager indexer. See: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#libraryproperties-file-format"
local paragraphLineFrontStripped="${paragraphLine#"${paragraphLine%%[![:space:]]*}"}"
1499
+
local paragraphValueEquals=${paragraphLineFrontStripped#sentence}
1500
+
local paragraphValueEqualsFrontStripped="${paragraphValueEquals#"${paragraphValueEquals%%[![:space:]]*}"}"
1501
+
local paragraphValue=${paragraphValueEqualsFrontStripped#=}
1502
+
if [[ "$paragraphValue"==*"$sentenceValueStrippedNoPunctuation"* ]];then
1503
+
echo"ERROR: ${libraryPropertiesPath}\'s paragraph value repeats the sentence. These strings are displayed one after the other in Library Manager so there is no point in redundancy."
if grep --quiet --regexp='^[[:space:]]*category[[:space:]]*=[[:space:]]*Uncategorized[[:space:]]*$'<<<"$libraryProperties";then
1517
+
echo"WARNING: category \'Uncategorized\' used in $libraryPropertiesPath is not recommended. Please chose an appropriate category from https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#libraryproperties-file-format"
1518
+
else
1519
+
echo"ERROR: $libraryPropertiesPath has an invalid category value. Please chose a valid category from https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#libraryproperties-file-format"
echo"ERROR: ${libraryPropertiesPath}\'s url value is missing the scheme (e.g. https://). URL scheme must be specified for Library Manager's \"More info\" link to be clickable."
local architecturesLineWithoutSpaces=${architecturesLine//[[:space:]]/}
1551
+
local architecturesValue=${architecturesLineWithoutSpaces//architectures=/}
1552
+
local validArchitecturesRegex='^((\*)|(avr)|(sam)|(samd)|(stm32f4)|(nrf52)|(i586)|(i686)|(arc32)|(win10)|(esp8266)|(esp32)|(ameba)|(arm)|(efm32)|(iot2000)|(msp430)|(navspark)|(nRF5)|(pic)|(pic32)|(RFduino)|(solox)|(stm32)|(stm)|(STM32)|(STM32F1)|(STM32F3)|(STM32F4)|(STM32F2)|(STM32L1)|(STM32L4))$'
1553
+
# Split string on ,
1554
+
IFS=','
1555
+
# Disable globbing, otherwise it fails when one of the architecture values is *
echo"ERROR: ${libraryPropertiesPath}\'s architectures field contains an invalid architecture ${architecture}. Note: architecture values are case-sensitive."
1560
+
return 1
1561
+
fi
1562
+
done
1563
+
# Re-enable globbing
1564
+
set +o noglob
1565
+
# Set IFS back to default
1566
+
unset IFS
1567
+
done
1568
+
then
1569
+
return 18
1570
+
fi
1571
+
1572
+
# Check for empty includes value
1573
+
if grep --quiet --regexp='^[[:space:]]*includes[[:space:]]*=[[:space:]]*$'<<<"$libraryProperties";then
1574
+
echo"ERROR: ${libraryPropertiesPath}\'s includes value is empty. Either define the field or remove it."
1575
+
return 19
1576
+
fi
1577
+
1578
+
done
1579
+
}
1580
+
1581
+
1393
1582
# Set default verbosity (must be called after the function definitions
0 commit comments