How to move binary from build folder after building project automatically

Hello!

I’m currently working on an nRF52832 board based on adafruit-arduino framework. Recently I have decided to automate specific tasks after build process such as moving the binary from the “.pio/build” folder in the project to a folder called “release” in the project’s root folder. I wrote a custom script to accomplish this but facing errors. I have added the post build script here in the platformIO.ini


And the post_build_script_right.py looks like this:

The AddPostAction function runs in the beginning of the Build process rather than after the zip package is created.

I’m not sure if that was the intended use case for env.AddPostAction function. If so, I would like to implement it the correct way. Basically, wait for PlatformIO to generate zip package and run the post script

Any help regarding this implementation is appreciated!

The second last line is wrong, with afterBuild() you directly execute the function, which is not what you want, you just want to give the function (object) to the AddPostAction. So just remove ().

1 Like

That worked! Thank you so much!! I also had to update the afterBuild function definition from:
def afterBuild(): to def afterBuild(source, target, env), because env.AddPostAction function sends arguments to the afterBuild function by default