Qbs 导出项目不是暂时性的

Qbs Export item not transient

本文关键字:暂时性 项目 Qbs      更新时间:2023-10-16

我有几个共享公共类的项目,因此我将更改项目布局,通过将它拆分为作为静态库实现的组件来反映这些依赖项。

现在我创建了一个模块"io",它使用导出块导出其包含路径。模块由"核心"依赖。然后,"核心"本身依赖于"应用程序",到目前为止没有什么特别的。

导出项的文档说它的属性是可传递的,但我得到几个错误从编译器编译时,找不到包含 from Core 的应用程序。看着编译器语句中,IO 导出的包含路径未在包含路径中列出。直接在应用程序中将依赖项添加到io时,一切正常。

是否错误地使用了导出/依赖对,或者我的整体布局很糟糕。

为了澄清,我更改了 Qbs 的应用和库示例以反映我的布局。

app
|- main.cpp
lib1
|- lib.cpp
lib2
|- lib.cpp
|- Test.h

=== app-and-lib.qbs
import qbs 1.0
Project {
    references: [
        "app/app.qbs",
        "lib1/lib1.qbs",
        "lib2/lib2.qbs"
    ]
}
=== app.qbs
import qbs 1.0
Product {
    type: "application"
    name : "app-and-lib-app"
    files : [ "main.cpp" ]
    Depends { name: "cpp" }
    Depends { name: "lib1" }
}
=== lib1.qbs
import qbs 1.0
Product {
    type: "staticlibrary"
    name: "lib1"
    files: [ "lib.cpp" ]
    cpp.defines: ['CRUCIAL_DEFINE']
    Depends { name: 'cpp' }
    Depends { name: "lib2" }
}
=== lib2.qbs
import qbs 1.0
Product {
    type: "staticlibrary"
    name: "lib2"
    files: [
        "Test.h",
        "lib.cpp",
    ]
    cpp.defines: ['CRUCIAL_DEFINE']
    Depends { name: 'cpp' }
    Export {
      Depends { name: "cpp" }
      cpp.includePaths: "."
    }
}
=== lib.cpp
#include <stdio.h>
#include "Test.h"

#ifndef CRUCIAL_DEFINE
#   error CRUCIAL_DEFINE not defined
#endif
int bla()
{
    puts("Hello World!");
    return 2;
}
=== main.cpp
#include <stdio.h>
#include "Test.h" // Error cannot found Test.h
int bla();
int main()
{
  Test t = new Test();
    return bla();
}

通过 IRC 到 Qbs Jira,并从开发人员那里得到答案,这是文档中的错误。要导出依赖项,必须将其导出,因此lib1.qbs需要像这样扩展

Exports { 
  Depends { name: "lib2" }
}

跟进:https://bugreports.qt.io/browse/QBS-928