0

我的问题很简单,我想从规则中操作产品的文件 stringList。我尝试使用 product.files.push(file)、product.files.append(file),但两种解决方案都不适合我。

感谢您的帮助。

编辑: 我创建了一个调用repc的模块(QtRemoteObjects .rep 文件编译器),该编译器将 .rep 文件作为输入并生成一个 .h 文件。我需要在我的项目中包含生成的 .h 文件,以便我可以继承其中定义的类型。这是模块代码:

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

这就是为什么我想要一种方法来自动将这个 .h 生成的文件添加到 qbs 项目中。

4

1 回答 1

1

你不能,也不应该。files 属性包含源文件。根据定义,规则创建的所有内容都不是源文件。请解释您要达到的目标;然后我们可以建议正确执行此操作的方法。

于 2017-07-13T09:01:58.597 回答