[QBS] RFC pkgconfig support
Oswald Buddenhagen
oswald.buddenhagen at nokia.com
Thu Feb 23 18:10:38 CET 2012
On Thu, Feb 23, 2012 at 10:19:08PM +0600, ext Ruslan Nigmatullin wrote:
> 23.02.2012, 21:38, "Joerg Bornemann" <joerg.bornemann at nokia.com>:
> > Allright. The user writes Depends { name: "foo" } into his project.
> > The module "foo" cannot be found in any search path.
>
no, just trigger the factories. see below.
> > What about rules that can be part of a module?
>
that's sort of irrelevant. remember that this about locating 3rd party
modules we know nothing about.
> May be we should use more declarative way? So the rules won't be a problem anyway
>
good idea.
> ---pkg-config-module-factory.qbs---
> ModuleFactory {
> name: 'pkgconfig'
> property var binary: 'pkg-config'
>
> Component {
>
better name that ModuleTemplate.
> name: "pkgconfigModule"
>
that's pointless.
but give it an id so you can refer to it.
> Module {
> property string packageName
> Depends { name: "cpp" }
> function packageProperty (property) {
> var p = new Process();
> p.start(binary, [ '--cflags', packageName ]
> return p.readAll();
> }
> cpp.cflags: packageProperty("--cflags");
> cpp.libs: packageProperty("--libs");
>
i wouldn't put any code here. you need to inject some properties anyway,
so you can inject all of them just as well.
> }
> }
>
> createModule: {
> // Script that gets a module name.
> // The script creates module object on success,
> // returns undefined otherwise.
>
nope. return true/false only. the module itself already comes from
instantiating the ModuleTemplate. then you also don't need to invoke magic
function to construct it.
> var p = new Process();
> var packageName = convertToPackage(moduleName);
> if (p.start(binary, ['--exists', packageName]) != 0)
> return undefined;
>
> return pkgconfigModule.create({ "name": moduleName, "packageName": packageName });
>
theid.name = ...
...
> }
> }
>
> > What happens if more than one module factory can generate a module
> > "foo"? Who wins? Do we add dependencies between module factories or
> > priorities?
>
> Because all factories should provide similar module's data (If we want
> to build with system library usually there exists only one system
> library), simple priorities should be enough.
>
yes. see https://bugreports.qt-project.org/browse/QBS-61
> More interesting is the situation when interested library is not found
> at all. Would be there any way to write workarounds around it if user
> wants to make application still be possible to build?
>
of course. i wouldn't call different configurations workarounds, even.
> Depends { name: "gstreamer"; relaxed: true }
>
the plan says that there should be Recommends and Suggests in addition
to Depends, so "relaxed" is not necessary.
> Group {
> condition: gstreamer.found
> files: [ "gstreamerbasedimpl.h", "gstreamerbasedimpl.cpp" ]
> cpp.defines: [ "HAVE_GSTREAMER" ]
> }
>
something like that.
More information about the Qbs
mailing list