[Qbs] Writing a custom script by QBS

Ben Lau xbenlau at gmail.com
Fri Oct 20 11:44:54 CEST 2017


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

> On Fri, 20 Oct 2017 16:41:33 +0800
> Ben Lau <xbenlau at gmail.com> wrote:
>
> > From my first email, I have raised few examples
> >
> > deployment = depends on a product's output , but no output file
> > starting a mock server = no dependence, just run a command, never stop,
> no
> > output file
>
> The "never stop" part is of course not so well-suited for a build process.
> You'd probably just run a script there that starts the real process in the
> background and then returns.
>
>
At least that is quite a common use-case for gulp / grunt, they may use it
to start a web server and even perform a hot-reload if any files was
changed.

If the objective of QBS is not a Qt only build system, I think that should
be an use-case worth to consider.


> > To simulate the condition of `code analysis`, I made this script and just
> > run `ls` command (in real case, it should be replaced by another tools)
>
> [ ... ]
>
> > That works for the first time, but if I run `qbs -p ls` again. That will
> > just report:
> >
> > $ qbs -p ls
> >
> > Restoring build graph from disk
> > Building for configuration default
> > Build done for configuration default.
> >
> > Any solution for this problem?
>
> By default, rules only run if they have to, that is, if an input file was
> updated or a property that was used in the script has changed. If you don't
> want that, you can set the "alwaysRun" property to true.
> You might want to take a look at the documentation, by the way:
> https://doc.qt.io/qbs/rule-item.html
>
>
I see. Thx.

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`
2. Set  "alwaysRun" and "builtByDefault" to true
3. Set "requiresInputs" to false if input are not needed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20171020/037c72b3/attachment.html>


More information about the Qbs mailing list