0

我习惯使用 Makefiles,但我当前的项目使用.qbs文件。如何在不创建或不需要文件的情况下通过 qbs 运行简单的终端命令?类似于 make 中的虚假规则。

以下工作并在我的终端中显示“很棒”。

import qbs 1.0

Project {
    name: "cli"

    Product {
        name: "helloworld"
        type: "application"
        files: "TEST.c"
        Depends { name: "cpp" }
    }

    Product {

        type: ["custom-image"]
        Depends { name: "helloworld" }

        Rule {
            inputsFromDependencies: ["application"]
            Artifact {
                fileTags: ["custom-image"]
            }
            prepare: {
                var cmd = new Command("echo", "awesome")
                return cmd
            }
        }
    }
}

但是,我必须TEST.c在每次运行之前触摸我的虚拟文件。如果没有helloworld依赖关系,则规则不会运行。

有任何想法吗?非常感谢!

4

2 回答 2

0

它被埋在文档中一个非常不明显的地方,并被命令进一步模糊(这不是正确的方法,哈哈)。我也遇到过你的问题。

你需要的是这个: http ://doc.qt.io/qbs/jsextension-process.html

于 2015-08-25T16:44:17.923 回答
0

我不确定您的最终目标是什么,但您可以使用Transformer{}而不是Rule{}. Rule{}a和 a之间的最大区别Transformer{}是运行不需要任何输入Transformer{}

另见Transformer.alwaysRun属性。

https://doc.qt.io/qbs/transformer-item.html

于 2016-05-13T19:46:37.857 回答