Support for prebuild, postbuild, and prelink commands have been added for upcoming version 3.3 by Takeshi Miya (many thanks!). What follows are his comments on this new feature.
Usage is as expected:
package.postbuildcommands = { "upx.exe --best myfile.exe", "calc.exe" }
package.prebuildcommands = { "pbrush.exe", "notepad" }
package.prelinkcommands = { "sol" }
Here is the level of per target support:
For the gnu target, I’ve used makefile “phony rules” for pre-build/link commands and “canned command sequences” for post-build commands. I’m not a makefile guru so it might be achieved by another way =P
For the vs2002~2005 targets, I’m separating multiple commands with hard-coded xml entities for CR-LF. This could be done better. See my bug report related to it.
For the monodev target, I didn’t tested it, but I think it doesn’t supports multiple commands, ie you can have only one prebuild command and one postbuild command. I used “&&” for separating commands as it might work in the shell, didn’t tested it.
For the sharpdevelop target, happens the same as monodev, it doesn’t supports multiple commands, but it’s worse, for SharpDevelop v1.x, it haves a separated “arguments” tag, and I didn’t account for that, I don’t think it’s worth the effort. The SharpDevelop 2.x doesn’t haves a separated “arguments” tag fortunately, so it might be better to add support for 2.x first =P
The gnu and cb-gcc targets works as expected.
A workaround for supporting multiple commands in monodev/sharpdevelop
might be to output package_prebuild.bat and package_postbuild.bat
files containing the commands.
In conclusion, post-build commands are supported in all targets, pre-build in all except vs6, and pre-link in gnu and vs200* only.
3.3-rc2 is available now on SourceForge. I'm giving it another day or two for comments, and then I plan to release the final version.
This comes in very handy for the next release of our software. Actually, after having started to use premake this is the single feature that I've been missing!
So the next question is probably not totally unexpected: When will there be a 3.3 release? :)