[Qbs] Writing a custom script by QBS
Ben Lau
xbenlau at gmail.com
Thu Oct 19 18:08:27 CEST 2017
Hi Christian,
Thanks for your reply. I have tried to run your example (by removing the
dependence). It will complain:
*ERROR: *Cannot run: Product 'remote deployer' is not an application.
On 19 October 2017 at 16:19, Christian Kandeler <christian.kandeler at qt.io>
wrote:
> On Thu, 19 Oct 2017 03:04:15 +0800
> Ben Lau <xbenlau at gmail.com> wrote:
>
> > I am still new to QBS. I am looking for a suggestion about how to write
> and
> > run a custom script by QBS.
> >
> > Besides building the binary, developers may need additional custom
> scripts
> > for deployment, code analysis, starting a mock server for testing etc.
> This
> > kind of task may not have a file output locally.
> >
> > Can I write this kind of script by QBS? I usually write this kind of
> > script as a shell script, but it is not a cross-platform solution which
> > does not work with Windows.
>
> You should be able to use the normal mechanisms that are also used for
> building. Here's a sketch for for remote deployment (untested):
>
> Product {
> name: "remote deployer"
>
> type: ["mydeploytarget"]
>
> // You typically don't want to do uploads after every build, so this
> product's rules are not
> // executed unless you specifically request it.
> builtByDefault: false
>
> // Assuming you want to upload e.g. some tar archive you've created
> from your build.
> Depends { name: "mypackage" }
>
> // These as well as the rule below would typically be moved into a
> dedicated module
> // for better re-usability, but it's easier to demonstrate with a
> self-contained
> // product.
> property string remoteUser
> property string serverName
> property string targetDir
>
> Rule {
> // The target type(s) of your dependency/dependencies.
> inputsFromDependencies: ["archiver.archive"]
>
> Artifact {
> // Just a dummy. Does not have to get created. We should
> probably
> // have syntactic sugar for this.
> filePath: "deploydummy"
>
> fileTags: ["mydeploytarget"]
> }
>
> prepare: {
> var targetString = product.remoteUser + '@' +
> product.serverName + '/' + product.targetDir;
> var cmd = new Command("scp", [input.filePath, targetString]);
> cmd.description = "uploading " + input.fileName;
> return [cmd];
> }
> }
> }
>
> Now this should upload your archive (possibly rebuilding if necessary):
> $ qbs -p "remote deployer"
>
>
> Christian
> _______________________________________________
> 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/20171020/c3868648/attachment.html>
More information about the Qbs
mailing list