[Qbs] Qbs: how to use a pre-build script

NIkolai Marchenko enmarantispam at gmail.com
Sat May 27 13:58:57 CEST 2017


http://codepad.org/u11XS6PM
http://codepad.org/Y1EciQoP (and uncommented pair module for grpc files.
mostly works the same)
This is what I use to generate .cc files from protobuf files.
I have injected comments but if something is still too vague, feel free to
ask.

@JakePetroules, @Ckandeler : sorry, I 've been meaning to push it to gerrit
since forever but the site just won't agree with me and I gave up each time

On Sat, May 27, 2017 at 9:21 AM, Timur Kristóf <timur.kristof at gmail.com>
wrote:

> Hi Nikolai,
>
> This does look very cool, I might use it in my project.
>
> However, while it does solve the specific (and simplified) problem at
> hand, it still doesn't really address the more general problem that I
> was asking about.
>
> Okay, for some git info, I can use a Probe and probably get away with
> it.
>
> But how can I do other pre-build stuff, like running a code generator
> (flex, bison, etc. come to mind)?
>
> Thanks,
> Timur
>
> On Fri, 2017-05-26 at 19:46 +0300, NIkolai Marchenko wrote:
> > This is what you really need:
> >
> > http://codepad.org/LVxUvSaF a probe
> > http://codepad.org/14TUDCor utilitary javascript functions that probe
> > references. Sorry for code quality ;)
> >
> > This probe attaches to a HEAD file to make sure params are
> > regenerated each time it changes.
> > used in actual project as:
> > import "../../GitProbe.qbs" as GitProbe
> > .... later in product....
> > GitProbe {
> >     id: gitProbe
> >     sourceDirectory: project.sourceDirectory
> > }
> >
> > cpp.defines:{
> >     var result =base.concat([
> >                        "GIT_VERSION=" + "\"" + gitProbe.hash + "\"",
> >                        "GIT_TAG=" + "\"" + gitProbe.tag + "\"",
> >                        "GIT_COMMIT_DATE=" + "\"" +
> > gitProbe.commitdate + "\"",
> >                   ])
> >
> >     return result
> > }
> >
> > and then use these defines directly in code without any generated
> > header.
> >
> >
> >
> > On Fri, May 26, 2017 at 7:17 PM, Timur Kristóf <timur.kristof at gmail.c
> > om> wrote:
> > > Hi,
> > >
> > > What is the correct way to execute a pre-build script with Qbs
> > > whose
> > > output is a dependency to the product being built?
> > >
> > > For example, I have a script that generates a C++ header file
> > > containing the current git revision and the date of the build. This
> > > header is then included into one of the C++ source files of the
> > > product. How do I execute this script before compiling the product?
> > >
> > > I could try to create a Rule item, but I'm not sure how to make
> > > sure
> > > that the rule is executed before the project is compiled. Or should
> > > I
> > > create a separate Product and make the main Product depend on that?
> > >
> > > Thanks in advance!
> > > Cheers,
> > > Timur
> > > _______________________________________________
> > > Qbs mailing list
> > > Qbs at qt-project.org
> > > http://lists.qt-project.org/mailman/listinfo/qbs
> > >
> >
> >
> _______________________________________________
> Qbs mailing list
> Qbs at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qbs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20170527/0aafb36e/attachment.html>


More information about the Qbs mailing list