0

I'm using Visual Studio Code and PlatformIO. I added some libraries to my project using platformio.ini:

lib_deps = 
    olikraus/U8g2@^2.34.4
    crankyoldgit/IRremoteESP8266@^2.8.4
    plerup/EspSoftwareSerial@^6.16.1
    rlogiacco/CircularBuffer@^1.3.3
    https://github.com/me-no-dev/ESPAsyncWebServer.git
    makuna/NeoPixelBus@^2.7.0
    adafruit/Adafruit BusIO@^1.13.2
    bblanchon/ArduinoJson@^6.19.4
    adafruit/Adafruit PN532@^1.2.2
    khoih-prog/ESPAsync_WiFiManager@^1.15.1
    https://github.com/guestisp/ESP32AsyncDNSServer.git

Now, let's say I have to "hack" few lines of code inside a library to fit my needs. Since it's a very specific change (not something that can be useful to others) I can easily change directly the source code without forking it on github.

The downside is every time I download again the libraries (or set up another dev machine) I lose all my changes.

I can also move the downloaded library to the lib/ subfolder in the project tree, removing the dependency from lib_deps.

I wonder if there is a more reliable way to do this, i.e. applying a patch after downloading the code (yocto-like).

1 Answer 1

2

Use a local source control and repository of your choice. Obtain the latest published rev of the library and make your changes to it (I assume you have already done this, probably a number of times). Check in your changed revision of the library to your local repository. When a new rev becomes available, obtain it and merge it into your local repository.

Update:

One problem of this approach is I will end up with nested repositories.

I'm coming from old-school source control - file management. rcs, in my case (don't laugh). I'm guessing your local modifications affect only one or a few of the library files. Mightn't something that simple - a file-level merge - solve your issue (regardless of which tool you choose to do it)?

3
  • One problem of this approach is I will end up with nested repositories. My project directory is already a git repository. If I clone the library repository inside, say, the lib folder it won't pushed inside mine since it's nested. At least, I was not able to do this.
    – Mark
    Commented Nov 21, 2022 at 17:55
  • 1
    @Mark: You may clone the library outside of your project's directory, commit your changes there in a dedicated branch, and then include it into your project as a git submodule. Alternatively, you may consider using a git subtree. Commented Nov 21, 2022 at 19:35
  • @EdgarBonet yep, git subtree did the trick (and for me is the actual solution to my question). I only knew git submodules that are tricky for this kind of scenario.
    – Mark
    Commented Nov 22, 2022 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.