如何在 qbs 中安装通用二进制工件?

问题描述

这是我的 qbs 项目:

Project {
    StaticLibrary {
        name: "targetLib"
        files: "main.cpp"

        bundle.isBundle: false

        multiplexByQbsProperties: "architectures"
        aggregate: true

        Group {
            fileTagsFilter: "bundle.content"
            qbs.install: true
            qbs.installSourceBase: buildDirectory
        }

        Depends { name: "nawesome" }
        Depends { name: "cpp" }
    }
}

在构建时,我通过设置属性 cpp.architectures: ["arm64","x86_64"] 的配置文件

据我所知,多路复用以这种方式工作:每个架构一个构建,另一个聚合构建通用二进制。聚合设置为其工件标记“bundle.content”,但未安装。

我不需要安装非通用二进制文件,所以我需要一些方法来消除它们。现在我找到的唯一方法是:

        Group {
            condition: type.contains("bundle.content")
            fileTagsFilter: "staticlibrary"
            qbs.install: true
            qbs.installSourceBase: buildDirectory
        }

但我不认为这是一个方法

解决方法

从 qbs 1.19 开始,只需在 StaticLibrary 项上设置“install: true”就可以透明地工作(因为它已经对非多路复用产品这样做了)。请参阅 https://codereview.qt-project.org/c/qbs/qbs/+/339928 了解在那里如何处理多路复用。 但是,如果您的解决方法奏效,那么您也可以继续使用它直到那时。