Advertisement
Guest User

Untitled

a guest
Apr 18th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 2.03 KB | None | 0 0
  1. import qbs
  2. import qbs.FileInfo
  3. import qbs.ModUtils
  4. import qbs.Environment
  5.  
  6. Module {
  7.     property stringList includes: []
  8.     property path protoc
  9.     property string prefix
  10.  
  11.     property var test
  12.  
  13.     FileTagger {
  14.         patterns: "*.proto"
  15.         fileTags: ["proto"]
  16.     }
  17.  
  18.     Rule {
  19.         id: roo
  20.         inputs: ["proto"]
  21.  
  22.         outputArtifacts: {
  23.             var artifacts = []
  24.  
  25.             var cpp = {
  26.                 fileTags: ["cpp"],
  27.                 filePath: input.baseName + ".pb.cc"
  28.             }
  29.  
  30.             var hpp = {
  31.                 fileTags: ["hpp"],
  32.                 filePath: input.baseName + ".pb.h"
  33.             }
  34.  
  35.             if(input.proto.prefix !== undefined) {
  36.                 hpp.fileTags.push("gen")
  37.                 product.proto.test = "testval" // try to push value to second rule
  38.             }
  39.  
  40.             return [cpp, hpp]
  41.         }
  42.         outputFileTags: ["hpp", "gen", "cpp"]
  43.  
  44.         prepare: {
  45.             var cppOutArg = "--cpp_out=" + product.buildDirectory
  46.             var incArgs = input.proto.includes
  47.             .map(function(path){ return "-I" + path })
  48.             .concat(cppOutArg, input.filePath)
  49.  
  50.             var proto_gen = new Command(product.proto.protoc, incArgs)
  51.             proto_gen.description = "protoc " + input.filePath + " -/- " + product.proto.test // "testval" if input.proto.prefix is not undefined
  52.             proto_gen.highlight = "codegen"
  53.  
  54.             var cmds = [proto_gen]
  55.             return cmds
  56.         }
  57.     }
  58.  
  59.     Rule {
  60.         condition: true
  61.         inputs: ["gen"]
  62.         Artifact {
  63.             fileTags: ["hpp"]
  64.             filePath: input.baseName + "..." /* product.proto.test */ + ".pb.h"
  65.         }
  66.         outputFileTags: ["hpp"]
  67.  
  68.         prepare: {
  69.             var cmd = new Command("echo", ["test"])
  70.             cmd.description = "wtf: " + input.fileName + " -/- "+ product.proto.test // undefined
  71.             cmd.highlight = "codegen"
  72.             var cmds = [cmd]
  73.  
  74.             return cmds
  75.         }
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement