为什么 qbs 无视我的规则?
Why qbs ignore my rule?
我有这个简单的代码
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
根据文档,我必须在 "compile output" windows 中看到 3 行:两行
"QFile Passing" 和一个 "QFile transformer"
但我看到只有 Transformer 块在工作(根本没有 "QFile Passing");(我的规则有什么问题?
您的规则必须实际生成一些工件,并且您的产品类型必须以某种方式(直接或间接)取决于您的规则输出工件的文件标签。换句话说,没有任何东西依赖于你的规则的输出,所以规则没有被执行。
大概你想要的是:
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
规则中的一个 Artifact 项目,描述了该规则将生成的输出文件。
- 将
processed_qfile
添加到产品类型,在依赖树中创建连接并导致在构建产品时执行规则
我有这个简单的代码
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
根据文档,我必须在 "compile output" windows 中看到 3 行:两行 "QFile Passing" 和一个 "QFile transformer"
但我看到只有 Transformer 块在工作(根本没有 "QFile Passing");(我的规则有什么问题?
您的规则必须实际生成一些工件,并且您的产品类型必须以某种方式(直接或间接)取决于您的规则输出工件的文件标签。换句话说,没有任何东西依赖于你的规则的输出,所以规则没有被执行。
大概你想要的是:
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
规则中的一个 Artifact 项目,描述了该规则将生成的输出文件。- 将
processed_qfile
添加到产品类型,在依赖树中创建连接并导致在构建产品时执行规则