PlatformIO Community

Separate build directories

Hello, I currently have 5 printers and am having an issue where i will build for one printer and when i go to find the files for my other printers they have been deleted., then i have to recompile, and then i will go to my other directory and poof. they are gone. Obviously Platformio is intelligent and is starting with a clean slate each time, but is there a way to have it start clean in each directory separately? Hopefully that made sense, if not lets say i have 3 directories for builds
1.0
2.0
3.0
I compile for 1.0
then move on to 2.0 and compile
when i go retrieve the file from 1.0 the directory only contains the idedata.json file.

PlatformIO only has the capability to set one build_dir for all environments of the project.

However, PlatformIO should not be deleting previous compiled firmwares if you not edit the platformio.ini. If you use Marlin, you don’t need to edit the platformio.ini's default_envs = ... line to change which environment it compiles, just use the project tasks panel to expand your target environment and hit ‘Build’. Or, if you’re working on the CLI, use one pio run -e <environment name> for each envrionemnt you want to build. All other environments should remain untouched.

Hi Max, as always you nailed it right on the head. I am using Marlin and am editing the platformio.ini default_envs=…Most likely due to lack of knowledge. So you are telling me the Project tasks which has been staring me in the face for almost a year is all i have to use to have separate environments built and not need 14 different directories? lol i want to kick myself… ah well, hopefully someone can benefit from my mistakes. So do i just leave default_envs = blank or set it back to mega2560 i think was default?

Thank you so much for clarifying

If you do it like this, the value of default_envs does not matter. This value only matters when you hit the Build icon in the bottom taskbar when you have the “Default” environment selected, it needs to know a default task.

1 Like

Thank you! i actually hit build under my devices board and it compiled just fine, so for my one printer i scrolled to STM32F103RET6_creality and pressed build from the drop down, now my next test is to switch projects and build for Atrillery_Ruby.

edit: That worked! just had to clear default_env =
lol not sure that is the most efficient method but far better than having to build/copy bin out/build/copy bin out…LOL
I’m sure there is a way to use one directory and it then place the new builds in their respective but i am not ready for that yet…haha, thank you!

Actually, default_envs accepts a list of default environments. Can you set it to the list of the environments that you want to build for and use the “Default” → Build button again?

well that was interesting, not sure i did it correctly but if i set the default_env to Artillery_Ruby or any board, my build directory gets wiped out, if i leave it blank like this
blank
and select build from the Project Tasks, then it leaves everything alone