2015-05-20 27 views
3

我有這個簡單的代碼爲什麼qbs不理會我的規則?

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傳「和一個用‘一個QFile變壓器’

但我看到只有變壓器塊是工作(沒有‘QFile時路過’的話);?(什麼是錯我的規則

回答

2

你的規則必須真正產生一些神器( s),並且產品的類型必須以某種方式(直接或間接)依賴於規則輸出工件的文件標籤。換句話說,什麼都不依賴於你的規則的輸出,所以規則沒有被執行。

也許你想要的是以下幾點:

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商品的類型,從而在依賴關係樹的連接,並導致規則時,該產品內置
被執行
相關問題