Open Wiz-IO opened 1 year ago
You can override the run method and catch the "clean" target.
We also extended PlatformIO Build API and it is possible to catch "clean" target in the PRE script. See https://github.com/platformio/platformio-core/commit/7e6cb84c879a3d5080bd53183f80575d10a45cd5
PRE script will work in next version ?
Yes, you can test it with pio upgrade --dev
.
nice ! Thanks
Ivan, am i doing something wrong? pre-script is executed with Build, but not with Clean
Import("env")
def on_clean_pre(source, target, env):
print('ON CLEAN PRE')
def on_clean_post(source, target, env):
print('ON CLEAN POST')
env.AddPreAction("clean", on_clean_pre)
env.AddPostAction("clean", on_clean_post)
print('--------SCRIPT-----------')
PlatformIO has been successfully upgraded to 6.1.6a3
Hey @ivankravets, I'm new to open source and would like to make a contribution on this issue. Could I possibly give it a try?
This seems to remain unavailable. There are generated files in my project that I would like to delete when I run the clean
or fullclean
action, but as far as I can tell these actions still don't trigger pre/post hooks. This seems like it should be a pretty common need - cleaning up additional stuff that PIO doesn't normally know about.
It seems that adding
env.AddPreAction("clean", on_clean_pre)
env.AddPostAction("clean", on_clean_post)
has no effect despite looking ok. The workaround I found is to create custom target that does the clean and remembering not to use the default one, although it's not ideal.
I use BUILD_DIR to compile boot2_stage boot loader of Raspberry Pi Pico but Clean clear only board folder...
I didn't find a solution for hook Clean (after) and I can offer you a small patch:
PlatformBase / base.py
builder / tools / piotarget.py
builder / main.py
platform.py