Details
-
Suggestion
-
Resolution: Done
-
P2: Important
-
1.2.0
-
1dd00091f99e62d8c10677de98e753fe332565a9
Description
not all dependencies need to be actually linked into the Product:
- a module may be needed at runtime only
- applications/tools
- generic libraries (in qt: opengl, openssl, ...)
- plugins (including qml modules)
- such dependencies would be forwarded to Exports (see QBS-584), to make sure exported Rules (see
QBS-583) are not executed too early - such dependencies would be also used for deployment
- as a special variation, a library may be loaded only at runtime, but its include path needs to be added to the compiler call
a dependency can be principally parametrized from four locations:
- the hard-coded default behavior of the Rules
- said behavior may depend on a Parameter. that parameter may be set in several places:
- in Products which Export Modules, and by extension in Modules themselves. i.e., the imported Module requests how it shall be used (by default).
- in Depends items which import Modules. i.e., the importing Product explicitly specifies how the imported Module shall be used (overrides default)
- in DefaultParameters items which override the imported Modules' defaults in the importing Products' scope, and can be still overridden by the Depends items.
- these items shall have an optional productTypes property which limits to which imported Modules these parameters should apply, e.g. only plugins.
first declare the parameter itself:
Module { name: "cpp" // parameters are just specially scoped property declarations. // the syntax is consistent with Constraints (see QBS-995), and shares the namespace with them. Parameter { // no default value, because it is different for each product type. // so let the Rules decide themselves. property bool link } Parameter { property bool wholeArchive: false } Parameter { property bool useHeaders: true } }
then create a Module which sets a default for a parameter:
Product { productTypes: [ "plugin", cpp.static ? "staticLibrary" : "dynamicLibrary" ] Depends { name: "cpp" } cpp.static: false Export { Parameters { cpp.link: cpp.static } } }
Plugin { name: "myPlugin1" // inherits the default parameter value from Plugin }
this results in an exported Module:
Module { name: "myPlugin1" Parameters { cpp.link: false } ... }
Plugin { name: "myPlugin2" Export { Parameters { cpp.link: true // i'm a funny plugin, i want to be linked always } } }
then use the parameter in different ways:
Product { Depends { // not linked name: "myPlugin1" } Depends { // linked name: "myPlugin2" } Depends { name: "OpenSSL" // we don't want to link it, and we have our own function prototypes // (openssl is unable to keep binary compat anyway) cpp.useHeaders: false cpp.link: false } Depends { name: "OpenGL" // we don't want to link it, but we want to use its headers for compilation cpp.link: false } }
Product { DefaultParameters { productTypes: ["plugin"] cpp.link: true } Depends { // linked name: "myPlugin1" } }
also, static plugins need to be actually linked. this will typically also require auto-generating static initializers for the plugins' factory methods. this is framework-dependent, so it would end up in a QtPlugin item.
Attachments
Issue Links
- is required for
-
QBS-295 Provide a way to declare dependencies as system-provided
- Open
-
QBS-200 Provide the ability to weak-link frameworks on macOS
- Closed
-
QBS-874 qbs needs a means to weakly-link dynamic libraries on Apple platforms
- Closed
-
QBS-290 running a product in Qt Creator should build only that product and its dependents
- Closed
-
QBS-701 Add option to link to a whole archive
- Closed
- relates to
-
QBS-584 properly support private dependencies
- Open
-
QBS-247 Transformer item needs a way to add fine-grained file dependencies
- Closed
-
QBS-451 Add support for copying resources to Darwin application and framework bundles
- Open
-
QBS-643 Add a better way of dealing with Darwin bundles
- Closed
-
QBS-599 Products should be able to explicitly export their artifacts to dependent products
- Closed
-
QBS-741 Add "useAsInput" property to Depends item
- Closed
-
QBS-995 add a generic way to constrain dependencies
- Reported
For Gerrit Dashboard: QBS-585 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
193094,18 | Make it possible to parametrize dependencies | master | qbs/qbs | Status: MERGED | -2 | 0 |