premake / premake/premake-core

Running custom commands before compiling (with make -j)

Open
#286 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement gmake
Dominant language
C
Stars
3.6k
Forks
654
Avg merge
1d 1h
Merged PRs (30d)
13

Description

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...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two configurations in the issue with the gmake generator and make -j: project-level prebuildcommands versus the dependent Utility project. Inspect how the generator handles Utility projects and prebuild commands. Done means the SWIG command completes before compilation and the Utility project no longer invokes g++ without input files.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, lua
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.