3

I has this simply code

import qbs

Project {
name: "simple_test"

Product {
    name: "micro"
    type: "other"
    Group {
        files: '*.q'
        fileTags: ['qfile']
    }

    Rule {
        id: check1
        inputs: ["qfile"]
        prepare: {
            var cmd = new JavaScriptCommand();
            cmd.description = "QFile passing"
            cmd.silent = false;
            cmd.highlight = "compiler";
            cmd.sourceCode = function() {
                print("Nothing to do");
            };
            return cmd;
        }
    }
    Transformer {
        inputs: ['blink.q']
        Artifact {
            filePath: "processed_qfile.txt"
            fileTags: "processed_qfile"
        }
        prepare: {
            var cmd = new JavaScriptCommand();
            cmd.description = "QFile transformer";
            cmd.highlight = "compiler";
            cmd.sourceCode = function() {
                print("Another nothing");
            };
            return cmd;
        }
    }
}
}

And put two files blink.q and blink1.q

By documentation, I must see in "compile output" windows 3 lines: Two with "QFile Passing" and one with "QFile transformer"

But I see that only Transformer block is work (no "QFile Passing" at all) ;( What is wrong with my Rule?

Viacheslav
  • 103
  • 5

1 Answers1

2

Your Rule must actually generate some Artifact(s), and the type of your product must somehow (directly or indirectly) depend on the file tags of the output artifacts of your Rule. In other words, nothing depended on the output of your Rule, so the Rule was not executed.

Probably what you want is the following:

import qbs

Project {
    name: "simple_test"

    Product {
        name: "micro"
        type: ["other", "processed_qfile"]
        Group {
            files: '*.q'
            fileTags: ['qfile']
        }

        Rule {
            id: check1
            inputs: ["qfile"]
            Artifact {
                filePath: "processed_qfile.txt"
                fileTags: "processed_qfile"
            }
            prepare: {
                var cmd = new JavaScriptCommand();
                cmd.description = "QFile passing"
                cmd.silent = false;
                cmd.highlight = "compiler";
                cmd.sourceCode = function() {
                    print("Nothing to do");
                };
                return cmd;
            }
        }
    }
}

Note the addition of:

  • An Artifact item inside the check1 Rule describing the output file that will be produced by the Rule.
  • The addition of the processed_qfile to the Product's type, creating a connection in the dependency tree and causing the Rule to be executed when the product is built
Jake Petroules
  • 23,472
  • 35
  • 144
  • 225