My question is simple, I want to manipulate the files stringList of a product from a Rule. I tried to use product.files.push(file), product.files.append(file), but neither solution worked for me.
thank you for your help.
EDIT: I created a module which invoke repc (QtRemoteObjects .rep files compiler), this compiler take as input a .rep file and generate a .h file. I need to include the generated .h file in my project so I can inherit from the types defined in it. here is the module code :
import qbs
import qbs.FileInfo
import qbs.File
Module {
property bool source: true
FileTagger {
patterns: ["*.rep"]
fileTags: ["repc-rep"]
}
Rule {
inputs: ["repc-rep"]
Artifact {
filePath: {
if (product.repc.source) {
return "repc_" + FileInfo.baseName(input.fileName) + "_source.h";
} else {
return "repc_" + FileInfo.baseName(input.fileName) + "_replica.h";
}
}
fileTags: ["hpp"]
}
prepare: {
var cmd = new Command();
cmd.description = "repc " + input.fileName;
cmd.program = "repc.exe"
if (product.repc.source) {
cmd.arguments = ["-i", "rep", "-o", "source", input.filePath, output.filePath];
} else {
cmd.arguments = ["-i", "rep", "-o", "replica", input.filePath, output.filePath];
}
var cmd2 = new JavaScriptCommand();
cmd2.silent = true;
cmd2.sourceCode = function() {
File.copy(output.filePath, FileInfo.path(input.filePath) + "/" + output.fileName);
}
return [cmd, cmd2];
}
}
}
this is why I want a way to automatically add this .h generated file to the qbs project.