Adding before build hook

In my development of some extensions, I ran into the need to run some code before building. 

I'm not sure if there's a better place to put functionality like that or not.  If not it was pretty easy to add.

please advise.