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

  1. from conan.tools.premake import Premake
  2. from conan.tools.microsoft import MSBuild
  3. class Pkg(ConanFile):
  4. settings = "os", "compiler", "build_type", "arch"
  5. # The VCVars generator might be needed in Windows-MSVC
  6. generators = "VCVars"
  7. def build(self):
  8. p = Premake(self)
  9. p.configure()
  10. # At the moment Premake does not contain .build() method
  11. # report in Github issues your use cases and feedback to request it
  12. build_type = str(self.settings.build_type)
  13. if self.settings.os == "Windows":
  14. msbuild = MSBuild(self)
  15. msbuild.build("HelloWorld.sln")
  16. else:
  17. self.run(f"make config={build_type.lower()}_x86_64")
  18. p = os.path.join(self.build_folder, "bin", build_type, "HelloWorld")
  19. self.run(f'"{p}"')