Qbs 导出项目不是瞬态的
Qbs Export item not transient
我有几个项目共享 类 因此我要更改项目
布局以通过将其拆分为作为静态库实现的组件来反映这些依赖关系。
现在我创建了一个模块 'io',它使用导出块导出其包含路径。 'core' 依赖该模块。 'Core' 本身然后由 'app' 依赖,到目前为止没有什么特别的。
Export 项目的文档说它的属性是可传递的,但我遇到了几个错误
在编译包含 from core 的应用程序时无法从编译器中找到。看着
编译器声明,io 导出的包含路径未列在包含路径中。
直接在app中的io中添加依赖,一切正常
我使用的 Export/Depends 对是错误的还是我的整体布局不好。
我更改了 Qbs 的 app-and-lib 示例以反映我的布局以进行澄清。
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" }
}
我有几个项目共享 类 因此我要更改项目 布局以通过将其拆分为作为静态库实现的组件来反映这些依赖关系。
现在我创建了一个模块 'io',它使用导出块导出其包含路径。 'core' 依赖该模块。 'Core' 本身然后由 'app' 依赖,到目前为止没有什么特别的。
Export 项目的文档说它的属性是可传递的,但我遇到了几个错误 在编译包含 from core 的应用程序时无法从编译器中找到。看着 编译器声明,io 导出的包含路径未列在包含路径中。 直接在app中的io中添加依赖,一切正常
我使用的 Export/Depends 对是错误的还是我的整体布局不好。
我更改了 Qbs 的 app-and-lib 示例以反映我的布局以进行澄清。
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" }
}