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

Provide build flags options to libraries

Open Levi--G opened this issue 6 months ago • 1 comments
trafficstars

Describe the request

I suggest adding the ability to add/remove platform properties (AKA "build properties", "compiler flags") and gui options via the library.properties metadata file.

My case

I created a PlatformIO library: https://github.com/Levi--G/USBLibrarySTM32. I am regularly asked to add support for using my library with Arduino IDE, but the lack of this capability makes it impossible for me to do so.

The reason is that the library requires the USB peripheral clock of the STM32 microcontroller to be enabled. This is controlled in the STM32 boards platform source code by preprocessor conditionals. So the library requires the -D USBCON and -D HAL_PCD_MODULE_ENABLED flags to be injected into the compilation commands.

Describe the current behavior

It is not possible for libraries to configure platform properties.

Arduino CLI version

63c44a41f499c82085765fccc53e0893a9d03f2f

Operating system

N/A

Operating system version

n/a

Additional context

Allowing the end user to set platform properties on a sketch level would be another solution.

Related

  • https://github.com/arduino/arduino-cli/issues/846

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

Levi--G avatar May 03 '25 21:05 Levi--G

I don't know why someone changed my post, but the intention was to be able to ADD/REMOVE build flags and gui settings, not just SET platform properties, important difference. Also the "related" post only talks about platforms and users setting flags while this is specifically about libraries, so not in the really related other than talking about flags.

Levi--G avatar May 04 '25 07:05 Levi--G