premake-core icon indicating copy to clipboard operation
premake-core copied to clipboard

Running custom commands before compiling (with make -j)

Open kankaristo opened this issue 9 years ago • 7 comments

I started using Premake yesterday and I'm hoping to start using it instead of qmake. It's been great so far, thanks for an awesome tool!

I've got most things working, but I'm still having a problem running custom commands before any compiling takes place. I had similar problems with qmake, which is one of the reasons I'm switching to Premake.

One of the custom commands can take over 10 seconds to finish and it must be run before compiling, because it generates some of the code (actually, most of the code, nearly 200 000 lines).

So, I'm trying to use Premake to run SWIG to generate code before make attempts to compile it.

If I put the commands in a project's prebuildcommands:

project "MyProject"
    prebuildcommands{
        "./swig.sh";
    }

    [...]

...it works fine if I only use make -j1 (a single job). This is exactly the same as it was with qmake; they're only "prebuild" for one of the make jobs, not the whole build process.

If I put the commands in a separate project and make it a dependency:

project "MyProject"
    links "SWIG"

    [...]

project "SWIG"
    kind "Utility"

    prebuildcommands{
        "./swig.sh";
    }

This time, the command is run before anything in "MyProject" is compiled (great!), but then I get an error about g++ having no input files in the "SWIG" project. There's a warning about "Utility" being and unsupported "kind". Is it unsupported for gmake or is it completely unimplemented (no mention in the documentation)?

Is there some way to get this to work? I'd hate to resort to the same kind of hacks I had to use with qmake...

kankaristo avatar Sep 29 '15 20:09 kankaristo