[Qbs] Writing a custom script by QBS

Ben Lau xbenlau at gmail.com
Fri Oct 20 18:31:50 CEST 2017


On 20 October 2017 at 19:25, Christian Kandeler <christian.kandeler at qt.io>
wrote:

> On Fri, 20 Oct 2017 17:44:54 +0800
> Ben Lau <xbenlau at gmail.com> wrote:
>
> > Let's summarize about how to write a custom script by QBS
> >
> > 1. Write it as a part of the "build" process, then run by `qbs -p
> > scriptName`
>
> Yes, the "script name" is a "product" in qbs lingo.
>
> > 3. Set "requiresInputs" to false if input are not needed.
>
> Note that this is essentially implied if the rule does not declare any
> inputs.
>
>
> Christian
> _______________________________________________
>

To make it more simple to use, I have written a Script.qbs

https://gist.github.com/benlau/ebbce60659f0dd17cb22064b58df7394

Usage :

    Script {

        id: ls

        name: "ls"


        command: "ls"

        arguments: ["-lh"]

    }


or


    Script {

        id: ls

        name: "ls"


        function script() {

            var process = Process();

            process.start("ls", ["-lh"]);

            console.info(process.readStdOut());

        }

    }



By the way, is there any method to list all available product within a
project by qbs itself? I am thinking about to make a script like `qbs -p
listScript` then it will search for all products and check is it a script
then return.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20171021/fce064f9/attachment.html>


More information about the Qbs mailing list