Qbs:Module可以安装文件吗?
Qbs: Can Module install files?
我想要一个模块,它将导出所有需要的依赖项,如包含路径、库路径,并将安装需要的运行时库。
Module {
Depends { name: "cpp" }
property path libLocation: ""
cpp.dynamicLibraries: [
"mylib"
]
cpp.staticLibraries: [
"mylib"
]
cpp.includePaths: [
libLocation + "include/",
]
cpp.libraryPaths: [
libLocation + "lib/",
]
Group {
name: "runtime libraries"
qbs.install: true
prefix: 'lib_location/'
files: ["*.dll"]
}
}
一切正常,但未安装文件。可以吗?
更新 1:
文件已正确安装:
- 如果直接指定完整路径或相对路径(作为文字)
- 通过使用项目的属性。
工作解决方案:
Module {
...
Group {
name: "runtime libraries"
prefix: "D:/Projects/MyProject/Dependencies/SDL2pp/mingw/bin/" // works!
//prefix: project.dependenciesPath + "SDL2pp/mingw/bin/" // also works!
files: "*.dll"
qbs.install: true
}
}
但是当我尝试使用 Module 的 属性 时,它说:"Reference Error: Can't find variable: ..."
Module {
...
property bool installDlls: true
property string libPath: ""
Group {
name: "runtime libraries"
prefix: libPath // Can't find variable
files: "*.dll"
qbs.install: installDlls // Can't find variable
}
}
另外,用FileInfo模块建路径是不行的。正确解决了组外路径。
import qbs
import qbs.FileInfo
Module {
...
Group {
name: "runtime libraries"
prefix: FileInfo.joinPaths(project.dependenciesPaths, './SDL2pp/mingw/bin/') // silently not works
files: "*.dll"
qbs.install: true
}
}
结论
我找到了 2 个解决方案:
- 已将路径编码为文字。不可移植的解决方案
- 使用项目的 属性。便携,但取决于项目项目。
我不知道为什么模块的属性不能在组内使用。是否有一些限制或它是一个错误?
晚了,但发现这个 post 试图做同样的事情,也许它可以帮助其他人。
发现在组内使用模块的 属性 可以通过给模块一个 ID 并使用像这样的 ID 引用 属性 来完成
Module {
id: mymodule
...
property bool installDlls: true
property string libPath: ""
Group {
name: "runtime libraries"
prefix: mymodule.libPath
files: "*.dll"
qbs.install: mymodule.installDlls
}
}
我正在使用 Qbs 1.12.1
我想要一个模块,它将导出所有需要的依赖项,如包含路径、库路径,并将安装需要的运行时库。
Module {
Depends { name: "cpp" }
property path libLocation: ""
cpp.dynamicLibraries: [
"mylib"
]
cpp.staticLibraries: [
"mylib"
]
cpp.includePaths: [
libLocation + "include/",
]
cpp.libraryPaths: [
libLocation + "lib/",
]
Group {
name: "runtime libraries"
qbs.install: true
prefix: 'lib_location/'
files: ["*.dll"]
}
}
一切正常,但未安装文件。可以吗?
更新 1:
文件已正确安装:
- 如果直接指定完整路径或相对路径(作为文字)
- 通过使用项目的属性。
工作解决方案:
Module {
...
Group {
name: "runtime libraries"
prefix: "D:/Projects/MyProject/Dependencies/SDL2pp/mingw/bin/" // works!
//prefix: project.dependenciesPath + "SDL2pp/mingw/bin/" // also works!
files: "*.dll"
qbs.install: true
}
}
但是当我尝试使用 Module 的 属性 时,它说:"Reference Error: Can't find variable: ..."
Module {
...
property bool installDlls: true
property string libPath: ""
Group {
name: "runtime libraries"
prefix: libPath // Can't find variable
files: "*.dll"
qbs.install: installDlls // Can't find variable
}
}
另外,用FileInfo模块建路径是不行的。正确解决了组外路径。
import qbs
import qbs.FileInfo
Module {
...
Group {
name: "runtime libraries"
prefix: FileInfo.joinPaths(project.dependenciesPaths, './SDL2pp/mingw/bin/') // silently not works
files: "*.dll"
qbs.install: true
}
}
结论
我找到了 2 个解决方案:
- 已将路径编码为文字。不可移植的解决方案
- 使用项目的 属性。便携,但取决于项目项目。
我不知道为什么模块的属性不能在组内使用。是否有一些限制或它是一个错误?
晚了,但发现这个 post 试图做同样的事情,也许它可以帮助其他人。 发现在组内使用模块的 属性 可以通过给模块一个 ID 并使用像这样的 ID 引用 属性 来完成
Module {
id: mymodule
...
property bool installDlls: true
property string libPath: ""
Group {
name: "runtime libraries"
prefix: mymodule.libPath
files: "*.dll"
qbs.install: mymodule.installDlls
}
}
我正在使用 Qbs 1.12.1