Best way to edit file in library?


#1

Hi,

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: https://github.com/CWempe/SuperLEDstrip#preparation

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:


#2

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,

[env:myenv]
platform = ...
board = ..
framework = arduino
build_flags = 
  -D nexSerial=SoftwareSerial

#3

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