Put all build folders outside .pio folder

Im a new and excited user of PlatformIO. With Arduino IDE, the builds are saved somewhere i dont know, but i save the sketches in a different folder inside cloud which is really efficient concerning space.

So, i use only space for the ino files, and the builds are somewhere locally.
Can i do the same with platformIO? (save the big “build” folder outside of the project folder?)
i see that the libraries which are used from main.cpp file are inside build folder, but why they have to be redownloaded and not all esp32 projects use the same libraries folder?

  1. Can i share the libraries between platformIO and arduinoIDE so i dont have to re-download libraries i already downloaded in arduino ide?

Refer to the documentation (for .pio\) or this doc for .pio\build.

Refer to the documentation and forum.

1 Like

Thanks for quick answer…

i can understand that if i set Windows Environment Variables “PLATFORMIO_BUILD_DIR” to my /iHaveSpace path and “PLATFORMIO_INCLUDE_DIR” to my /ArduinoIDElibrariesFolder i solved both of my problems…

Via environment variables is one way, but that’s not very portable between computers. The documentations is for options in the [platformio] section of the platformio.ini of the project.

So e.g. having

[platformio]
lib_extra_dirs = ~\Documents\Arduino\libraries
build_dir = ..\.pio_build_dir

[env:uno]
platform = atmelavr
board = uno
framework = arduino

You have an environment for a Arduino Uno plus the settings to grab extra libraries from the Arduino libraries folder and set the .pio\build folder which usually created in the project folder to one folder up into ..\.pio_build_dir.

yes i understand…
but that means i have to edit the platform.ini file in every project i create right?
what i want is to know that every project i create will use the shared arduino folder libraries, and the lets say 3 folders up for the build_dir…
isnt the environment variables the only way to make these settings global for every project?

Yes in that case it is.

1 Like

ok, i fixed the global build folder as i wanted to…
but now i try to point the Platformio to include arduinoIDE libraries…
so i create a env var PLATFORMIO_INCLUDE_DIR to
C:\Users\myUsername\Documents\Arduino\libraries\

and i get this error
055

although my C:\Users\myUsername\Documents\Arduino\libraries\ folder contains the AceButton library folder…
i read the documentation but didnt find any solution.

The docs say PLATFORMIO_LIB_EXTRA_DIRS, PLATFORMIO_INCLUDE_DIR re-points the default include folder from ${project source}/include to somewhere else, I don’t think you want that.

ok, so if i want to add already downloaded libraries from arduino IDE PLATFORMIO_INCLUDE_DIR is not a solution?
or it makes a mess so its better to redownload every library?

edit:
instead of PLATFORMIO_INCLUDE_DIR i used PLATFORMIO_LIB_EXTRA_DIRS env variable, and it worked fine…
i delete the library folder, platformio doesnt find the library…
restore the library folder, code compile successfully

I dont know why this didnt work with PLATFORMIO_INCLUDE_DIR but im happy with the result now.

1 Like