Skip to content

add library detection and version macros #3124

@pillo79

Description

@pillo79

Describe the request

It would be extremely useful if the CLI could automatically generate, after the library discovery phase, a set of macros that describe the presence in the build of each detected library and its version.

There are several reasons:

  • libraries could auto-configure depending on the presence of other libs in the project
  • versions would not need to be manually defined in code for each library
  • it would be possible to test for any library version in the same way

Describe the current behavior

The CLI does not currently provide this information. Only the {includes} variable in the sketch/libraries compilation step may offer any clue.

Arduino CLI version

new ones

Operating system

N/A

Operating system version

OS independent

Additional context

A suitable solution would provide, when for example Bridge 1.2.3 is included, something like a -DFOUND_BRIDGE_LIB=0x010203 in a specific {lib_detect_macros} variable for expansion in build commands. It may also be as a @file if this would generate too many macros.

The identifiers would be generated with unequivocal rules (for example by converting the library name to a valid uppercase C slug) and the versions would need to be easily sortable.

Notes:

  • it would be desirable to have this at core compile time as well, if possible. Not a deal breaker if the core can refer to libraries (Allow platforms to specify library dependencies #3110); in that case the library dependent changes may be moved to a core-supplied lib.
  • libs whose version can't be identified could have 1 as their version, which translates to the lowest possible non-zero version 0.0.1
  • multiple #defines can be added for the same lib, for example:
    • longer ones, including the author name, to remove potential ambiguities;
    • more info on discovery (e.g. suffixes _IN_SKETCHBOOK, _IN_CORE, _IN_PROFILE, _SCORE etc)

Issue checklist

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions