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
PremakeToolchaingenerator.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, msbuild_platform=None)¶
Depending on the action, this method will run either
msbuildormakewithN_JOBS. You can specifyN_JOBSthrough the configuration linetools.build:jobs=N_JOBSin your profile[conf]section.- Parameters:
workspace –
strSpecifies the solution to be compiled (only used byMSBuild).targets –
List[str]Declare the projects to be built (None to build all projects).msbuild_platform –
strSpecify the platform for the internal MSBuild generator (only used byMSBuild).
conf¶
The Premake build helper is affected by these [conf] variables:
tools.build:verbositywhich accepts one ofquietorverboseand sets the--quietflag inPremake.configure()tools.compilation:verbositywhich accepts one ofquietorverboseand sets the--verboseflag inPremake.build()