3

我有这个简单的代码

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;
        }
    }
}
}

并放两个文件blink.q 和blink1.q

通过文档,我必须在“编译输出”窗口中看到 3 行:两行带有“QFile Passing”,另一行带有“QFile 转换器”

但我看到只有 Transformer 块有效(根本没有“QFile Passing”);(我的规则有什么问题?

4

1 回答 1

2

您的规则必须实际生成一些工件,并且您的产品类型必须以某种方式(直接或间接)取决于您的规则输出工件的文件标签。换句话说,没有任何东西依赖于您的规则的输出,因此该规则没有被执行。

可能你想要的是以下内容:

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;
            }
        }
    }
}

注意添加:

  • 规则内的工件项,check1描述将由规则生成的输出文件。
  • 添加processed_qfile到产品的类型中,在依赖树中创建连接并在构建产品时执行规则
于 2015-05-21T02:49:24.747 回答