QbsProfile

The QbsProfile generator 会生成包含工具链信息的设置文件。此文件可以被 Qbs 导入。QbsProfile generator 的用法如下:

from conan import ConanFile

class App(ConanFile):
    settings = "os", "arch", "compiler", "build_type"
    requires = "hello/0.1"
    generators = "QbsProfile"

也可以在 generate() 方法中手动使用 QbsProfile

from conan import ConanFile
from conan.tools.qbs import QbsProfile

class App(ConanFile):
    settings = "os", "arch", "compiler", "build_type"
    requires = "hello/0.1"

    def generate(self):
        profile = QbsProfile(self)
        profile.generate()

现在,我们可以使用 conan install 命令生成文件。

$ conan install . --output-folder=build --build missing

并将其导入 Qbs

$ qbs config import qbs_settings.txt --settings-dir qbs

请注意,要实际使用导入的文件,Qbs 应使用 --settings-dir 调用。

$ qbs resolve --settings-dir qbs

使用 Qbs 辅助类时,这些命令会自动调用。 .. seealso

- Check the :ref:`Qbs helper <_conan_tools_qbs_helper>` for details.

参考

class QbsProfile(conanfile, profile='conan', default_profile='conan')

Qbs profiles generator。

此类会生成包含 Qbs 可以导入的工具链信息的文件的类。

参数:
  • conanfile – 当前的配方对象。始终使用 self

  • profile – 设置中配置文件的名称。默认为 "conan"

  • default_profile – 默认配置文件的名称。默认为 "conan"

property filename

生成文件的名称。返回 qbs_settings.txt

property content

以 Qbs 属性字典的形式返回设置文件的内容。

render()

以字符串形式返回设置文件的内容。

generate()

此方法会将生成的文件保存到 conanfile.generators_folder。

生成 “qbs_settings.txt” 文件。该文件包含 Qbs 设置,例如工具链属性,可以使用 qbs config --import 进行导入。