Qbs custom module not working.
-
Hello guys,
I want to make a module to use the QtRO repc compiler to produce .h files from .rep files.
I coded the module but when I try to load it in an application product it does not load and disable the product.
the modules are in C:\Users\User\qt\qbs
Qbs Module replica.qbs:
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" }
-
I managed to make it work after digging a little more in the doc and source code, I share with you the working module.
This module when imported if there are any .rep files (QtRO (remote objects)) module remote object definition) in your project, it will invoke the repc compiler and compile them and put the resulting .h file in your source directory.
Still not complete, I didn't find a way to manipulate the files property of the Product Item to add the .h to it automatically.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: ["hpp"] } prepare: { var cmd = new Command(); cmd.description = "repc " + input.fileName; cmd.program = "repc.exe" cmd.arguments = ["-i", "rep", "-o", "source", input.filePath, output.filePath]; return cmd; } } }
In order to this module to work, the repc.exe must be in your path.
Any suggestion are welcomed.