arduino-cli icon indicating copy to clipboard operation
arduino-cli copied to clipboard

Add libraries super compatibility and explicit incompatibility in the spec

Open umbynos opened this issue 2 years ago • 1 comments
trafficstars

Describe the request

Add support for a field named supported in the library.properties library metadata file. This field is a comma-separated list of patterns to match against an FQBN.

This will allow library developers to define the supported boards for the library down to board-level granularity.

The result would be something like this in the library.properties file:

name=Camera
version=1.0
author=Arduino
maintainer=Arduino <[email protected]>
sentence=Camera library for Portenta H7 Vision Shield
paragraph=
category=Other
url=https://github.com/arduino/ArduinoCore-mbed/tree/master/libraries/Camera
architectures=mbed,!avr
supported=*:mbed:portenta,!*:*:nano33ble
#supported=mbed:portenta,!mbed:nano33ble <- without wildcards

This information could be used for applications such as:

Describe the current behavior

Library developers can only indicate compatibility at architecture-level granularity. A library may have dependencies on attributes that only present on a subset of boards of a given architecture.

This means it is not possible for tools to accurately determine whether a specific board is supported by a library.

For example, the "Keyboard" library specifies compatibility with the avr architecture:

https://github.com/arduino-libraries/Keyboard/blob/1.0.4/library.properties#L9

architectures=avr, samd, sam

However, not all AVR microcontrollers have the required native USB capability. This results in inaccurate information about the library's support for those boards.

The library is listed in lib list command output when the FQBN of an unsupported board (e.g., Uno) is specified via the --fqbn flag:

$ arduino-cli lib install Keyboard
Downloading [email protected]...
[email protected] [email protected] already downloaded
Installing [email protected]...
Installed [email protected]

$ arduino-cli lib list Keyboard --fqbn arduino:avr:uno
Name     Installed     Available         Location              Description
Keyboard 1.0.4         -                 LIBRARY_LOCATION_USER -

Unsupported boards are included in the automatically generated "Compatibility" list of the library's reference page:

https://www.arduino.cc/reference/en/libraries/keyboard/

Arduino CLI version

0.32.2

Operating system

N/A

Operating system version

N/A

Additional context

The newly added field should be ignored by versions of Arduino development tools that don't have support for the new field. If so, this change would not result in any backwards incompatibility of the libraries that use it.


Relevant code:

https://github.com/arduino/arduino-cli/blob/743c3e9b3c94eded62b44081a03650d571fa230c/arduino/libraries/libraries.go#L78

Related

  • https://github.com/arduino/Arduino/issues/11871
  • https://github.com/arduino/ArduinoCore-mbed/issues/529#issuecomment-1201117968
  • https://github.com/arduino/arduino-ide/issues/1304
  • https://github.com/arduino-libraries/ArduinoIoTCloud/pull/380#issuecomment-1737244158
  • https://forum.arduino.cc/t/documentation-for-keyboard-library-needs-some-correction/1126221
  • https://forum.arduino.cc/t/arduino-keyboard-not-working-on-arduino-uno-r3/1102400
  • https://forum.arduino.cc/t/sketch-funktioniert-nicht-keyboard/1099364/6
  • https://forum.arduino.cc/t/issue-on-keyboard-library/1065385
  • https://forum.arduino.cc/t/what-is-wrong-here/1080550/7
  • https://forum.arduino.cc/t/comments-on-arduino-1-5-specifications/162030/72 / https://forum.arduino.cc/t/comments-on-arduino-1-5-specifications/162030/83
  • https://forum.arduino.cc/t/comments-on-arduino-1-5-specifications/162030/84

Issue checklist

  • [X] I searched for previous requests in the issue tracker
  • [X] I verified the feature was still missing when using the nightly build
  • [X] My request contains all necessary details

umbynos avatar Apr 17 '23 14:04 umbynos

Original reporter @facchinm

umbynos avatar Apr 17 '23 14:04 umbynos