本页内容

Qbs 构建配置

要为所选套件指定构建设置,请转至“Projects ” > “Build Settings ”。

Qbs 构建设置

Qbs 会在您在“Build directory ”中指定的目录中构建项目。

在“Tooltip in target selector ”中,输入文本,当您将鼠标悬停在套件选择器中的构建配置上时,该文本将作为工具提示显示。

您可以在“Configuration name ”中为构建配置输入名称。

有关配置 Qbs 的更多信息,请参阅“设置 Qbs 配置文件目录”

分离调试信息

如果正在生成调试信息,您可以通过在“Separate debug info ”中选择“Enable ”,将其放置在单独的文件中,而不是嵌入到二进制文件中。有关更多信息,请参阅“分析 CPU 使用情况”。要使用默认设置,请选择“Default ”。

编译 QML

您可以将 QML 源代码编译为最终二进制文件,以缩短应用程序的启动时间,并避免需要将 QML 文件与应用程序一同部署。有关更多信息,请参阅“预编译(Ahead-of-Time Compilation)”。

Qt Creator Enable 项目向导模板生成的 项目支持编译,因为它们已配置为使用Qt资源系统。要编译QML代码,请在Qt Quick Qt Quick Compiler中选择“ ”。若要使用默认设置,请选择“Default ”。

Qbs 构建步骤

“构建设置”中的 Qbs 构建步骤

要为 Qbs 指定构建步骤:

  1. Build variant 中,选择:
    • Debug 在构建中包含调试符号,以便调试应用程序。
    • Profile 生成优化后的发布版本,该版本随附独立的调试信息。此选项最适合用于分析应用程序。
    • Release 以创建最终的安装二进制包。
  2. 在“Parallel jobs ”中,指定构建时使用的并行任务数量。
  3. 在“Properties ”中,指定要传递给项目的属性。使用冒号 (:) 分隔键和值。有关更多信息,请参阅Qbs:模块
  4. Flags 中,选择:
    • Keep going 在发生错误时,如果可能,继续构建。
    • Show command lines 将实际命令行打印到“编译输出”中,而非高级描述。
    • Force probes 强制重新执行Qbs Probes 的 configure 脚本。
  5. 在“Installation flags ”中:
    • 选择“Install ”以在构建完成后将构建产物复制到其安装位置。此选项默认启用。

      注意:在 Windows系统上 ,如果应用程序正在运行,构建将失败,因为无法覆盖可执行文件。为避免此问题,您可以取消选中此复选框,并在运行设置中添加一个“Qbs Install ”部署步骤,该步骤将在运行应用程序之前执行。

    • 选择“Clean install root ”可在构建开始前清除安装根目录中的内容。
    • 选中“Use default location ”以将构建产物安装到默认位置。取消选中该复选框,则可在“Installation directory ”中指定其他位置。

Equivalent command line 显示根据所选选项生成的构建命令。

Qbs 清理步骤

使用 Qbs 进行构建时,您可以在“Clean Steps ”中指定参数:

Qbs 清洁步骤

  • 选择“Dry run ”可在不执行命令或对构建图进行永久更改的情况下测试清理操作。
  • 选择“Keep going ”可在发生错误时,在可能的情况下继续清理。

Equivalent command line 显示根据所选选项生成的清理命令。

另请参阅 “设置 Qbs 配置文件目录”、“Qbs”以及“设置 QML 调试”

Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.