How to run custom tools from premake script assembly?

I use protocol buffers to serialize data in my C ++ application. I would like to add the invocation of the protoc code protoc to the premake build script (thus the creation date of the generated classes and avoid the need to store the generated source in accordance with version control).

Even they have a FAQ and a question about it, but the answer is very incomplete for me. The ability to call any lua function is great, but where exactly did I make this call? I need to run the protoc compiler before creating either an application or unit tests.

+4
source share
2 answers

You can, of course, call external code from Premake scripts. But remember: Premake scripts are used to create build files: Make files, C ++ projects, etc. Before creating the project, a Premake script is executed.

If you want this preprocess to run outside of the actual build files (rather than make, VC ++, Code :: Blocks, etc.), then this is easy. Lua os.execute will execute the command line.

Premake scripts are still Lua scripts. All Premake commands are just Lua calls for the functions that Premake defines. Premake runs the scripts and then uses the data from them to generate assembly files. This way, all of your Lua code is run at runtime. If you put this command in your script, it does not matter; wherever it is, it will run until build files are created.

+4
source

And if you want to run the protoc step during build (from VC ++, makefile, etc.), you can configure the prebuild command. See http://industriousone.com/prebuildcommands for more information and an example.

+2
source

All Articles