Qt Qbs自定义模块不工作
我想制作一个模块,使用QtRO repc编译器从.rep文件生成.h文件 我对模块进行了编码,但当我尝试将其加载到应用程序产品中时,它不会加载并禁用该产品 模块位于C:\Users\User\qt\qbs中 Qbs模块副本。Qbs:Qt Qbs自定义模块不工作,qt,qbs,Qt,Qbs,我想制作一个模块,使用QtRO repc编译器从.rep文件生成.h文件 我对模块进行了编码,但当我尝试将其加载到应用程序产品中时,它不会加载并禁用该产品 模块位于C:\Users\User\qt\qbs中 Qbs模块副本。Qbs: import qbs Module { property bool source: true FileTagger { patterns: "*.rep" fileTags: ["rep"] } Ru
import qbs
Module {
property bool source: true
FileTagger {
patterns: "*.rep"
fileTags: ["rep"]
}
Rule {
inputs: ["rep"]
Artifact {
fileTags: ["txt_output"]
}
prepare: {
var cmd = new Command();
cmd.program = "repc.exe";
if source {
cmd.arguments = ["-i", "rep", "-o", "source", input.filePath];
} else {
cmd.arguments = ["-i", "rep", "-o", "replica", input.filePath];
}
console.log("repc on : ", input.filePath);
return [cmd];
}
}
}
product.qbs:
import qbs
Application {
name: "ServiceExposer"
Depends { name: "cpp" }
Depends { name: "Qt.core" }
Depends { name: "Qt.remoteobjects" }
Depends { name: "replica" }
files: [
"main.cpp",
"service_exposer.rep"
]
}
project.qbs:
import qbs
Project {
references: ["ServiceExposer/ServiceExposer.qbs"]
qbsSearchPaths: "C:\Users\User\qt\qbs"
}
我不知道我在哪里犯了错误
提前感谢您的帮助。在进一步挖掘文档和源代码后,我成功地使其工作,我将与您分享工作模块 导入此模块时,如果项目中存在任何.rep文件(QtRO(远程对象))模块远程对象定义),它将调用repc编译器并编译它们,并将生成的.h文件放入源目录中 仍然没有完成,我没有找到一种方法来操作产品项的files属性以自动向其中添加.h
import qbs
import qbs.FileInfo
Module {
FileTagger {
patterns: ["*.rep"]
fileTags: ["repc-rep"]
}
Rule {
inputs: ["repc-rep"]
Artifact {
filePath: repc_" + FileInfo.baseName(input.fileName) + "_source.h"
fileTags: ["cpp"]
}
prepare: {
var cmd = new Command();
cmd.description = "repc " + input.fileName;
cmd.program = "repc.exe"
cmd.arguments = ["-i", "rep", "-o", "source", input.filePath, output.filePath];
var cmd2 = new JavaScriptCommand();
cmd2.silent = true;
cmd2.sourceCode = function() {
File.copy(output.filePath, FileInfo.path(input.filePath) + "/" + output.fileName);
}
return [cmd, cmd2];
}
}
}
要使此模块正常工作,repc.exe必须位于您的路径中
欢迎任何建议
@Chritian Kandeler-我不知道存在hpp标记,我将其放在源目录中,以便从其他类引用它。工作版本在我对这篇文章的回答中。当它不起作用时,只需禁用项目,不要告诉我模块中出现了什么问题。@Chritian Kandeler-我不想把这篇文章放到一篇新文章中,什么是多路传输规则?这是什么意思?当QB告诉您规则中存在冲突且规则不是多路复用时,这意味着什么?我确实修复了它,这是因为moc发现扩展名为.h的文件是相同的(一个是由repc在构建目录中生成的,另一个是我在源目录中复制的),我不得不修改我的模块以删除build目录中的模块。