premake5: Generate Project and Makefiles
premake5 <action> reads premake5.lua and generates build files for the chosen toolchain, such as gmake2 Makefiles or a Visual Studio solution.
Premake is a generator, not a builder: it takes a Lua project description and emits Makefiles or IDE projects, which you then build with make or MSBuild. That keeps one source of truth across toolchains.
What it does
premake5 runs an action (the toolchain name) against premake5.lua, writing the corresponding build files. gmake2 produces GNU Makefiles; vs2022 produces a Visual Studio solution. You then invoke the native builder on the generated files.
Common usage
premake5 gmake2
make -j$(nproc) config=release
premake5 vs2022
premake5 --help # list available actionsOptions
| Action / flag | What it does |
|---|---|
| gmake2 | Generate GNU Makefiles (current Make action) |
| vs2022 / vs2019 | Generate a Visual Studio solution |
| xcode4 | Generate an Xcode project |
| --file=<lua> | Use a script other than premake5.lua |
| config=<name> | Passed to the generated Makefiles to pick a config |
| --help | List registered actions and options |
In CI
Run premake5 to generate, then build with the native tool: premake5 gmake2 && make -j$(nproc) config=release. The generated files are usually gitignored, so generate them in every CI run. Note the current Make action is gmake2, not the deprecated gmake.
Common errors in CI
"No such action 'gmake'" means you used the old action name; use gmake2. "Error: premake5.lua ... attempt to call a nil value" is a Lua error in the project script. "premake5: command not found" means the binary is not on PATH (Premake ships as a single executable you download). A generated Makefile that ignores config= means the script did not define that configuration.