组项目:无法将文件安装到同一位置

Group Item: cannot install file to same location

在我的项目中,我有几个依赖于单个模块的插件,包含一个 Group 项目类似于:

Group {
    name: "group"
    qbs.install: true
    qbs.installDir: "../"
    files: <filename>
}

但是编译失败 "error: Cannot install files 'filename' and 'filename' to the same location 'location'"。基本上,qbs 不能将同一个文件复制到同一个位置两次(对我来说似乎不合逻辑)

如何解决这个错误或有什么优雅的解决方法?

这是 qbs.installSourceBase 属性 的工作。基本上,您将其设置为包含您组中文件的基本目录,Qbs 将根据它们相对于上述基本目录的路径,将列出的文件分层安装到 qbs.installDir 中。

例如,给定以下组:

// defined in /source/myproject/myproject.qbs
Group {
    qbs.install: true
    qbs.installDir: "share/stuff"
    qbs.installSourceBase: "." // relative to /source/myproject
    files: [
        "fileA.txt",
        "fileB.txt",
        "subdir/fileB.txt",
    ]
}

和以下命令行调用:

$ qbs [...] --install-root /sample/some-root

将产生以下文件系统层次结构:

/sample/some-root/share/stuff/fileA.txt
/sample/some-root/share/stuff/fileB.txt
/sample/some-root/share/stuff/subdir/fileB.txt

有关详细信息,请参阅 Qbs Installation Properties 文档。

有一个解决方法,可能需要对项目进行一些重组:

而不是:

Module {
    name: "somemodule"

    // module properties set to dependant products

    Group {
        // files to install
        qbs.install: true
    }
}

我们可以使用:

Product {
    name: "somemodule"

    Group {
        // files to install
        qbs.install: true
    }

    Export { 
        // module properties set to dependant products
    }
}

这样,当mymodule的步骤为运行时,文件只安装一次,从而消除了冲突。模块属性,通过 Export 项导出,与通过 Module.

导出的一样

限制:

  1. Product 必须添加到 Project 项的 references
  2. Modules不能依赖Product项,这可能需要将所有依赖模块重组为Project/Export