Premake¶
警告
此功能是实验性的,可能会发生重大更改。有关更多信息,请参阅Conan 稳定性部分。
Premake
构建助手是 Premake 命令行调用的封装。它将抽象项目配置命令。
该助手旨在在 conanfile.py 的 build()
方法中使用,以便在 Conan 直接构建包(create、install)时自动调用 Premake 命令。
from conan.tools.premake import Premake
from conan.tools.microsoft import MSBuild
class Pkg(ConanFile):
settings = "os", "compiler", "build_type", "arch"
# The VCVars generator might be needed in Windows-MSVC
generators = "VCVars"
def build(self):
p = Premake(self)
p.configure()
# At the moment Premake does not contain .build() method
# report in Github issues your use cases and feedback to request it
build_type = str(self.settings.build_type)
if self.settings.os == "Windows":
msbuild = MSBuild(self)
msbuild.build("HelloWorld.sln")
else:
self.run(f"make config={build_type.lower()}_x86_64")
p = os.path.join(self.build_folder, "bin", build_type, "HelloWorld")
self.run(f'"{p}"')