Path for extra script inside a library


What’s the right way to specify a script path inside a library?

Actually I have in this way but changing the ENV will brake the link.

extra_scripts = 

Thanks in advance.

Just give yor library a library.json with an extraScripst field (docs)

Thanks for your answer.

The library is not mine I’m just using it.

Also on moment the library doesn’t have a library.json file.

Well then better fork it, because that’s the cleanest way of adding the script. Or, put the project in your local project, that’s the second way. If you have to to add it to the library, you can use some environment variables to make path more dynamically correct, namely

So something like

extra_scripts = 

For some reason pre:$PROJECT_LIBDEPS_DIR\$PIOENV\esp8266-react\scripts\ doesn’t works but the path is right as you can see below.

Hm, I will have to try this out in a more minimal way… Or maybe variable expansion is not available in this option :confused:

Ok, thanks!

Adding "extraScript": "scripts/" to library.json how I can prevent the script execution inside of platformio.ini?

I’m asking because the script is needed just in the first build or after some change in the interface.


Can someone help me with the question above about library.json?

Best regards.

@maxgerhardt can you help me please?

Prevents the script being called when doing intellisense inits

Actually I could not get that working with also other variants like pre:{platformio.libdeps_dir}\uno\ArduinoJson\scripts\ It’s either not expanding variables like I thought it was or something else is missing. You could open an issue at Issues · platformio/platformio-core · GitHub

Problem is, ESP8266-React is a PlatformIO project, not a library. It has stuff in lib/. Meaning if you treat it like a library, it won’t build the sources in lib/ at all… GitHub - rjwats/esp8266-react: A framework for ESP8266 & ESP32 microcontrollers with a React UI

Hi @maxgerhardt !

Thanks for your answer!

Sorry, I was not clear enough.

The library is not mine but on moment of my first post I was using a fork where I have restructured the framework to work as a library. For this reason I was using this path: .pio\libdeps\esp32dev\esp8266-react\scripts\

In platformio.ini I have this line: lib_deps=

After your answer I have added a draft for library.json in my fork for this reason I was asking about extraScript in library.json.

extraScript parameter works fine but PIO is rebuilding the interface during each compilation of my code.

Hm then some more custom extra logic is needed with regards to checking if any of the files changed that would trigger a website rebuild. You could use the hashes of the files and store that on disk in e.g. .pio/build/<environment>/website_hash.txt and read that and compare it to the current hash of the files, and only then rebuild (or do nothing).

Thanks for your help!

The issue is open.

I will try find a solution based in the information that you gave me.

Best regards.

Hi @maxgerhardt !

@ivankravets have pushed a commit to fix the issue #4220 and now your suggestion is working.

extra_scripts = 

About extraScript in library.json, now I think the easiest way to control the build process is using extra_script in ini file and comment out after the first build.

The best solution could be PIO support the script execution control using build flags but I think it should be a feature request.

Thanks for you help!

Best regards.