Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qbs custom module not working.
QtWS25 Last Chance

Qbs custom module not working.

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
qbs
2 Posts 1 Posters 910 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    batcher
    wrote on 11 Jul 2017, 15:06 last edited by
    #1

    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"
    }
    
    1 Reply Last reply
    0
    • B Offline
      B Offline
      batcher
      wrote on 11 Jul 2017, 19:46 last edited by batcher
      #2

      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.

      1 Reply Last reply
      0

      2/2

      11 Jul 2017, 19:46

      • Login

      • Login or register to search.
      2 out of 2
      • First post
        2/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved