Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt Qbs构建规则如何使用产品_Qt_Build System_Qbs - Fatal编程技术网

Qt Qbs构建规则如何使用产品

Qt Qbs构建规则如何使用产品,qt,build-system,qbs,Qt,Build System,Qbs,我想使用Qbs来编译一个现有的项目。这个项目已经包含了一个代码转换工具(my_工具),它在这个项目中被大量使用 到目前为止,我已经(简化): 我怎样才能获得我的命令工具的引用?这个答案基于Qbs作者Joerg Bornemann的一封电子邮件,他允许我在这里引用它 规则的属性usings允许将产品依赖项中的工件添加到输入中。 在本例中,我们对“应用程序”工件感兴趣 然后可以通过input.application访问应用程序列表 Application { name: "my_app"

我想使用Qbs来编译一个现有的项目。这个项目已经包含了一个代码转换工具(my_工具),它在这个项目中被大量使用

到目前为止,我已经(简化):


我怎样才能获得我的命令工具的引用?

这个答案基于Qbs作者Joerg Bornemann的一封电子邮件,他允许我在这里引用它

规则的属性
usings
允许将产品依赖项中的工件添加到输入中。 在本例中,我们对“应用程序”工件感兴趣

然后可以通过
input.application
访问应用程序列表

Application {
    name: "my_app"
    Group {
        files: 'main.cpp.in'
        fileTags: ['cpp_in']
    }
    Depends { name: "cpp" }

    // we need this dependency to make sure that my_tool exists before building my_app
    Depends { name: "my_tool" }

    Rule {
        inputs: ["cpp_in"]
        usings: ["application"] // dependent "application" products appear in inputs
        Artifact {
            fileName: input.completeBaseName
            fileTags: "cpp"
        }
        prepare: {
            // inputs["application"] is a list of "application" products
            var mytool = inputs["application"][0].fileName;
            var cmd = new Command(mytool, [inputs["cpp_in"][0].fileName, output.fileName]);
            cmd.description = "Generate\t" + input.baseName;
            cmd.highlight = "codegen";
            return cmd;
        }
    }
}

不幸的是,自QBS 1.5.0以来,
规则中的
usings
属性已被弃用。目前我也有同样的要求。在多路传输
规则
中使用产品工件


多路传输
规则的问题是,如果输入集中的单个文件发生更改,所有输入工件都将重新处理。就我而言,这相当耗时。

还没有“qbs”标签。。。
Application {
    name: "my_app"
    Group {
        files: 'main.cpp.in'
        fileTags: ['cpp_in']
    }
    Depends { name: "cpp" }

    // we need this dependency to make sure that my_tool exists before building my_app
    Depends { name: "my_tool" }

    Rule {
        inputs: ["cpp_in"]
        usings: ["application"] // dependent "application" products appear in inputs
        Artifact {
            fileName: input.completeBaseName
            fileTags: "cpp"
        }
        prepare: {
            // inputs["application"] is a list of "application" products
            var mytool = inputs["application"][0].fileName;
            var cmd = new Command(mytool, [inputs["cpp_in"][0].fileName, output.fileName]);
            cmd.description = "Generate\t" + input.baseName;
            cmd.highlight = "codegen";
            return cmd;
        }
    }
}