[QBS] RFC pkgconfig support
Ruslan Nigmatullin
EuroElessar at qutim.org
Mon Aug 20 19:18:10 CEST 2012
23.02.2012, 23:30, "Joerg Bornemann" <joerg.bornemann at nokia.com>:
> On 23/02/2012 17:19, ext Ruslan Nigmatullin wrote:
>
>> May be we should use more declarative way? So the rules won't be a problem anyway
>
> Yeah a more delarative approach would save us from having two ways to
> specify modules. :)
> How about the following? Scripting part and declarative part is
> separated and the context of the "module template" is clearly defined.
>
> ---pkg-config-module-factory.qbs---
> ModuleFactory {
> name: 'pkg-config'
> property var binary: 'pkg-config'
>
> ModuleTemplate {
> name: context.name
> Depends { name: "cpp" }
> cpp.cflags: context.cflags
>
> Rule {
> // transform this to that
> }
> }
>
> createModuleContext: {
> // Script that creates a module context object,
> // which is used in the ModuleTemplate above.
> // Returns a valid context object, if the module can
> // be created; undefined otherwise.
>
> var p = new Process();
> if (p.start(binary, ['--exists', module.name]) != 0)
> return undefined;
>
> if (p.start(binary, ['-cflags']) != 0)
> return undefined;
>
> var context = {};
> context.name = module.name;
> context.cflags = p.readAll();
> // or even split the cflags into includePaths, libs etc.
> return context;
> }
> }
As we have Probes now, why don't simplify syntax to this one:
---pkg-config-module-factory.qbs---
ModuleFactory {
name: 'pkg-config'
ModuleTemplate {
Depends { name: "cpp" }
Probes.PkgConfigProbe {
id: probe
// The only issue - where should we modify names? (i.e. qca -> qca2)
name: module.name
}
// condition is false? Don't be sad - just try another one ModuleFactory!
condition: probe.found
cpp.cFlags: probe.cFlags
cpp.cxxFlags: probe.cFlags
cpp.linkerFlags: probe.linkerFlags
Rule {
// transform this to that
}
}
}
I suppose Probes to be the only place with imperative lookup code. And the only variable we now from outside world is module.name, so why can't we already assign it? Or may be, it's enough just to place such modules to "factories" directory and simplify them just to ModuleTemplate without ModuleFactory? It looks to be as feature-rich as previous syntax
Ruslan
More information about the Qbs
mailing list