Premake¶
Warning
This feature is experimental and subject to breaking changes. See the Conan stability section for more information.
The Premake
build helper is a wrapper around the command line invocation of Premake. It will abstract the
project configuration and build command.
The helper is intended to be used in the conanfile.py build()
method, to call Premake commands automatically
when a package is being built directly by Conan (create, install)
Usage Example:
from conan.tools.premake import Premake
class Pkg(ConanFile):
settings = "os", "compiler", "build_type", "arch"
# The PremakeToolchain generator is always needed to use premake helper
generators = "PremakeToolchain"
def build(self):
p = Premake(self)
# Set the main Lua configuration file (default: premake5.lua)
p.luafile = "myproject.lua"
# Pass custom arguments to Premake (translates to --{key}={value})
p.arguments["myarg"] = "myvalue"
# Automatically determines the correct action:
# - For MSVC, selects vs<version> based on the compiler version
# - Defaults to "gmake" for other compilers
# p.configure() will run: premake5 --file=myproject.lua <action> --{key}={value} ...
p.configure()
# p.build() will invoke proper compiler depending on action (automatically detected by profile)
p.build("HelloWorld.sln")
Reference¶
- class Premake(conanfile)¶
This class calls Premake commands when a package is being built. Notice that this one should be used together with the
PremakeToolchain
generator.This premake generator is only compatible with
premake5
.- Parameters:
conanfile –
< ConanFile object >
The current recipe object. Always useself
.
- luafile¶
Path to the root premake5 lua file (default is
premake5.lua
)
- arguments¶
Key value pairs. Will translate to “–{key}={value}”
- configure()¶
Runs
premake5 <action> [FILE]
which will generate respective build scripts depending on theaction
.
- build(workspace, targets=None)¶
Depending on the action, this method will run either
msbuild
ormake
withN_JOBS
. You can specifyN_JOBS
through the configuration linetools.build:jobs=N_JOBS
in your profile[conf]
section.- Parameters:
workspace –
str
Specifies the solution to be compiled (only used byMSBuild
).targets –
List[str]
Declare the projects to be built (None to build all projects).
conf¶
The Premake
build helper is affected by these [conf]
variables:
tools.build:verbosity
which accepts one ofquiet
orverbose
and sets the--quiet
flag inPremake.configure()
tools.compilation:verbosity
which accepts one ofquiet
orverbose
and sets the--verbose
flag inPremake.build()