Best way to edit file in library?


I am using PlatformIO with VSCode since a few weeks ago.

Now I want to convert a Arduino project from Arduino IDE to PlatformIO.
The last thing that is in the way is that I need to exit the NexConfig.hin the Nextion library.
Like explained here: GitHub - CWempe/SuperLEDstrip

What is the best way to add this changes to the project?

Yes, I could just edit .piolibdeps\Nextion_ID37\NexConfig.h like I did when I used Arduino IDE.
But the changes would be gone if I clean .piolibdeps.
What if I just add .piolibdeps\Nextion_ID37\NexConfig.h to my git?
Would it be overwritten once the libraries are downloaded?

I hope there is a smarter way with PlatformIO. :slight_smile:

If you need to do any manipulation on your source in dynamic mode, you can use Advanced Scripting or even Dynamic Build Flags.

In the last case with dynamic build flags you can use any programming language. The scenario could be the next:

  1. PlatformIO call your script every time before each build
  2. You check if source code need modifications
  3. If yes, read file and replace such lines

P.S: In any case, I don’t like these modifications. It’s better to make PR to this library where you can override behaviour using build_flags.

For example,

platform = ...
board = ..
framework = arduino
build_flags = 
  -D nexSerial=SoftwareSerial

That sounds like the best solution. I might end up doing that. :slight_smile: