【问题标题】:Why qbs ignore my rule?为什么qbs忽略我的规则?
【发布时间】:2015-05-20 06:39:22
【问题描述】:

我有这个简单的代码

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”

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

【问题讨论】:

    标签: qt qbs


    【解决方案1】:

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

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

    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,在依赖树中创建连接,并在构建产品时执行规则

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-19
      • 1970-01-01
      • 2018-11-28
      • 1970-01-01
      • 2012-02-08
      • 2016-02-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多