The hooks (if present in the platform.txt) must be executed just before and just after copying the build output. Ref: https://github.com/arduino/Arduino/blob/42336ace32a55ffab800847b678ac2547bc10beb/arduino-core/src/cc/arduino/Compiler.java#L185-L191