Re: [Qbs] run test executables outside QBS environment

2019-08-28 Thread Richard Weickelt

> I'm looking for a way to run test executables - created by QBS - outside
> of a QBS environment. To me this looks problematic since you can define
> runVars inside QBS that are not known outside of QBS.
> 
> Any idea how to handle this?

An idea, not a solution. You could generate a shell wrapper script together
with each executable where you export all relevant variables. Then you call
the wrapper script instead of the executable, or you would source the
wrapper script.

I guess you are most interested in dynamic library resolution which is
handled by the environment variables:

- LD_LIBRARY_PATH on Linux
- DYLD_LIBRARY_PATH on MacOs
- PATH on Windows

For how to find out all relevant library paths for an application product,
you can get an inspiration from
https://code.qt.io/cgit/qbs/qbs.git/tree/share/qbs/modules/cpp/setuprunenv.js
You might even use these functions as they are.
___
Qbs mailing list
Qbs@qt-project.org
https://lists.qt-project.org/listinfo/qbs


[Qbs] run test executables outside QBS environment

2019-08-28 Thread Heiko Nardmann
Hi,

I'm looking for a way to run test executables - created by QBS - outside
of a QBS environment. To me this looks problematic since you can define
runVars inside QBS that are not known outside of QBS.

Any idea how to handle this?

Thanks!

-- 
Heiko Nardmann

___
Qbs mailing list
Qbs@qt-project.org
https://lists.qt-project.org/listinfo/qbs


Re: [Qbs] Generating a c++ class with Q_OBJECT

2019-08-28 Thread Christian Kandeler
On Wed, 28 Aug 2019 12:56:56 +0200
Raphael Cotty  wrote:

> I've created a module:
> Module {
> FileTagger {
> patterns: "*.wsdl"
> fileTags: ["wsdl"]
> }
> Depends { name: "kdsoap" }
> Rule {
> multiplex: false
> inputs: ["wsdl"]
> Artifact {
> filePath: input.baseName + ".cpp";
> fileTags: "cpp"
> }
> Artifact {
> filePath: input.baseName + ".h";
> fileTags: "hpp"
> }
> 
> prepare: {
> var file = input.filePath;
> var cmd = new Command("kdwsdl2cpp", ["-both", input.baseName,
> file]);
> cmd.description = input.fileName + "->" + outputs.cpp[0];
> cmd.highlight = "kdwsdl2cpp codegen";
> cmd.workingDirectory = product.buildDirectory;
> return cmd;
> }
> }
> }
> 
> My project file:
> Project {
> minimumQbsVersion: "1.5"
> qbsSearchPaths: "qbs"
> 
> CppApplication {
> name: "Test"
> cpp.includePaths: sourceDirectory
> files: [
> "main.cpp",
> "wsdl/WsAnnuaire.wsdl"
> ]
> Depends { name: "Qt"; submodules: ["core", "xml"] }
> Depends { name: "wsdl" }
> }
> }
> 
> So my module generates the cpp/h files according to the input using the
> baseName. Perfect.
> 
> I've no found a simple way to export the output directory of the module. I
> guess I have to create a property in the module and assign to it the output
> directory.
> But the outputs variable is only available in the Rule:
> Rule {
> property path outputPath: FileInfo.path( outputs.cpp[0].filePath )
> ...
> }
> 
> Or should the module depends on cpp and export the path?

Yes: 
cpp.includePaths: product.buildDirectory
at the Module level.


Christian
___
Qbs mailing list
Qbs@qt-project.org
https://lists.qt-project.org/listinfo/qbs


Re: [Qbs] Generating a c++ class with Q_OBJECT

2019-08-28 Thread Raphael Cotty
Hi,
Thanks.
I've created a module:
Module {
FileTagger {
patterns: "*.wsdl"
fileTags: ["wsdl"]
}
Depends { name: "kdsoap" }
Rule {
multiplex: false
inputs: ["wsdl"]
Artifact {
filePath: input.baseName + ".cpp";
fileTags: "cpp"
}
Artifact {
filePath: input.baseName + ".h";
fileTags: "hpp"
}

prepare: {
var file = input.filePath;
var cmd = new Command("kdwsdl2cpp", ["-both", input.baseName,
file]);
cmd.description = input.fileName + "->" + outputs.cpp[0];
cmd.highlight = "kdwsdl2cpp codegen";
cmd.workingDirectory = product.buildDirectory;
return cmd;
}
}
}

My project file:
Project {
minimumQbsVersion: "1.5"
qbsSearchPaths: "qbs"

CppApplication {
name: "Test"
cpp.includePaths: sourceDirectory
files: [
"main.cpp",
"wsdl/WsAnnuaire.wsdl"
]
Depends { name: "Qt"; submodules: ["core", "xml"] }
Depends { name: "wsdl" }
}
}

So my module generates the cpp/h files according to the input using the
baseName. Perfect.

I've no found a simple way to export the output directory of the module. I
guess I have to create a property in the module and assign to it the output
directory.
But the outputs variable is only available in the Rule:
Rule {
property path outputPath: FileInfo.path( outputs.cpp[0].filePath )
...
}

Or should the module depends on cpp and export the path?

Thanks

Raph

Le mar. 27 août 2019 à 20:43, Richard Weickelt  a
écrit :

> > CppApplication {
> > name: "test"
> > cpp.includePaths: sourceDirectory
> > files: [
> > "main.cpp",
> > ]
> > Depends { name: "Qt"; submodules: ["core", "xml"] }
> > Depends { name: "kdsoap" }
> > Rule {
> > multiplex: true
> > Artifact { filePath: "wsdl.cpp"; fileTags: "cpp" }
> > Artifact { filePath: "wsdl.h"; fileTags: "cpp" }
> > prepare: {
> > var file = product.sourceDirectory +
> > "/wsdl/WsAnnuaire.wsdl";
> > var cmd = new Command("kdwsdl2cpp", ["-both", "wsdl",
> > file]);
> > cmd.description = "generating " + outputs;
> > cmd.workingDirectory = product.buildDirectory;
> > return cmd;
> > }
> > }
> > }
> >
> > Adding the second artifact makes qbs call moc on the wsdl.h and generates
> > the qt.headers/wsdl.moc file.
> > But how can I add this file to the link?
>
> What do you mean by "link"? That the resulting .cpp file is compiled and
> linked into your application? AFAIK, this should happen automatically. But
> your rule above does not look kosher to me:
>
> 1. Your rule should specify a filetag as input. That might be "wsdl".
> Otherwise Qbs will not (re-)run the rule upon changes in the wsdl file.
>
> 2. Consider to add a FileTagger for "wsdl" files or at least, put the wsdl
> file into a group item and assign the "wsdl" filetag.
>
> 3. Why do you set multiplex true? Can the tool handle multiple wsdl input
> files and creates one single large .h and .cpp file? Otherwise, consider to
> set it to false (default) and generate one cpp+hpp file per wsdl file
> input.
>
> 4. I think you should use "hpp" as filetag for the wsdl header artifact.
>
> 5. Consider to add the output directory of the rule to cpp.includePaths if
> you want to easily include them into your source files, for instance via
> #include .
>
> 7. If you are going to use this generator in multiple products, consider to
> write a module.
> https://doc-snapshots.qt.io/qbs-master/custom-modules.html#custom-modules
>
> The documentation about writing rules has recently been updated. Have a
> look
> at:
>
> https://doc-snapshots.qt.io/qbs-master/qml-qbslanguageitems-rule.html#a-complete-example
>
> Does this maybe solve your problem?
>
> Richard
> ___
> Qbs mailing list
> Qbs@qt-project.org
> https://lists.qt-project.org/listinfo/qbs
>
___
Qbs mailing list
Qbs@qt-project.org
https://lists.qt-project.org/listinfo/qbs