[Qbs] Generating a c++ class with Q_OBJECT
Christian Kandeler
Christian.Kandeler at qt.io
Wed Aug 28 13:10:08 CEST 2019
On Wed, 28 Aug 2019 12:56:56 +0200
Raphael Cotty <raphael.cotty at gmail.com> wrote:
> I've created a module:
> Module {
> FileTagger {
> patterns: "*.wsdl"
> fileTags: ["wsdl"]
> }
> Depends { name: "kdsoap" }
> Rule {
> multiplex: false
> inputs: ["wsdl"]
> Artifact {
> filePath: input.baseName + ".cpp";
> fileTags: "cpp"
> }
> Artifact {
> filePath: input.baseName + ".h";
> fileTags: "hpp"
> }
>
> prepare: {
> var file = input.filePath;
> var cmd = new Command("kdwsdl2cpp", ["-both", input.baseName,
> file]);
> cmd.description = input.fileName + "->" + outputs.cpp[0];
> cmd.highlight = "kdwsdl2cpp codegen";
> cmd.workingDirectory = product.buildDirectory;
> return cmd;
> }
> }
> }
>
> My project file:
> Project {
> minimumQbsVersion: "1.5"
> qbsSearchPaths: "qbs"
>
> CppApplication {
> name: "Test"
> cpp.includePaths: sourceDirectory
> files: [
> "main.cpp",
> "wsdl/WsAnnuaire.wsdl"
> ]
> Depends { name: "Qt"; submodules: ["core", "xml"] }
> Depends { name: "wsdl" }
> }
> }
>
> So my module generates the cpp/h files according to the input using the
> baseName. Perfect.
>
> I've no found a simple way to export the output directory of the module. I
> guess I have to create a property in the module and assign to it the output
> directory.
> But the outputs variable is only available in the Rule:
> Rule {
> property path outputPath: FileInfo.path( outputs.cpp[0].filePath )
> ...
> }
>
> Or should the module depends on cpp and export the path?
Yes:
cpp.includePaths: product.buildDirectory
at the Module level.
Christian
More information about the Qbs
mailing list