Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import qbs
- import qbs.FileInfo
- import qbs.ModUtils
- import qbs.Environment
- Module {
- property stringList includes: []
- property path protoc
- property string prefix
- property var test
- FileTagger {
- patterns: "*.proto"
- fileTags: ["proto"]
- }
- Rule {
- id: roo
- inputs: ["proto"]
- outputArtifacts: {
- var artifacts = []
- var cpp = {
- fileTags: ["cpp"],
- filePath: input.baseName + ".pb.cc"
- }
- var hpp = {
- fileTags: ["hpp"],
- filePath: input.baseName + ".pb.h"
- }
- if(input.proto.prefix !== undefined) {
- hpp.fileTags.push("gen")
- product.proto.test = "testval" // try to push value to second rule
- }
- return [cpp, hpp]
- }
- outputFileTags: ["hpp", "gen", "cpp"]
- prepare: {
- var cppOutArg = "--cpp_out=" + product.buildDirectory
- var incArgs = input.proto.includes
- .map(function(path){ return "-I" + path })
- .concat(cppOutArg, input.filePath)
- var proto_gen = new Command(product.proto.protoc, incArgs)
- proto_gen.description = "protoc " + input.filePath + " -/- " + product.proto.test // "testval" if input.proto.prefix is not undefined
- proto_gen.highlight = "codegen"
- var cmds = [proto_gen]
- return cmds
- }
- }
- Rule {
- condition: true
- inputs: ["gen"]
- Artifact {
- fileTags: ["hpp"]
- filePath: input.baseName + "..." /* product.proto.test */ + ".pb.h"
- }
- outputFileTags: ["hpp"]
- prepare: {
- var cmd = new Command("echo", ["test"])
- cmd.description = "wtf: " + input.fileName + " -/- "+ product.proto.test // undefined
- cmd.highlight = "codegen"
- var cmds = [cmd]
- return cmds
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement