子类化探针不起作用
Subclassing Probe doesn't work
我正在尝试子类化 Probe,以便在开始构建之前从网上克隆自定义存储库。
GitProbe:
import qbs
import qbs.File
import qbs.Process
Probe {
property string gitUrl
property string wd
property string name
property string dir: wd + "/" + name
configure: {
try {
if(File.directoryEntries(dir, File.AllEntries).length > 0){
File.remove(dir)
}
var gitProcess = Process()
gitProcess.setWorkingDirectory(wd)
gitProcess.exec("git", ["clone", gitUrl], true)
found = true
} catch(err) {
console.warn("GitProbe : could not clone repository " + gitUrl)
console.error("GitProbe : " + err)
found = false
}
}
}
我确实把 GitProbe.qbs
放在 dir/imports/
中,在我的项目中我做了 qbsSearchPath: "path-to-dir"
,但是 qbs 在解析文件时告诉我 Unexpected item type 'GitProbe'
.
这是一个已知的限制:在解析当前文件时需要设置搜索路径。因此,解决方法是从另一个文件中的项目项引用您的文件,并在那里设置搜索路径。您可能想对 https://bugreports.qt.io/browse/QBS-667 投票。
我正在尝试子类化 Probe,以便在开始构建之前从网上克隆自定义存储库。
GitProbe:
import qbs
import qbs.File
import qbs.Process
Probe {
property string gitUrl
property string wd
property string name
property string dir: wd + "/" + name
configure: {
try {
if(File.directoryEntries(dir, File.AllEntries).length > 0){
File.remove(dir)
}
var gitProcess = Process()
gitProcess.setWorkingDirectory(wd)
gitProcess.exec("git", ["clone", gitUrl], true)
found = true
} catch(err) {
console.warn("GitProbe : could not clone repository " + gitUrl)
console.error("GitProbe : " + err)
found = false
}
}
}
我确实把 GitProbe.qbs
放在 dir/imports/
中,在我的项目中我做了 qbsSearchPath: "path-to-dir"
,但是 qbs 在解析文件时告诉我 Unexpected item type 'GitProbe'
.
这是一个已知的限制:在解析当前文件时需要设置搜索路径。因此,解决方法是从另一个文件中的项目项引用您的文件,并在那里设置搜索路径。您可能想对 https://bugreports.qt.io/browse/QBS-667 投票。