aboutsummaryrefslogtreecommitdiffstats
path: root/doc/reference/items/language/moduleprovider.qdoc
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2017-02-23 16:42:37 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2019-01-23 14:35:02 +0000
commitc2833b1a009bc7c382b30d94109b9b7a25a404a6 (patch)
tree5b960940919310f8867e503234ca6d4f4295bfbe /doc/reference/items/language/moduleprovider.qdoc
parent1bfc30065371a3d28421e2e7af5653e1e78259f3 (diff)
Introduce module providers
If a dependency is not found, we now search for a matching module provider that can generate one for us. We also provide a generic fall-back provider which uses pkg-config to locate the dependency (but could be extended to incorporate other methods in the future). This is the most important part of this change for practical purposes, as it makes hundreds of popular libraries available for use in qbs projects without users having to write any boilerplate code. In a future patch, a module provider could also be used to implement the functionality of the qtprofilesetup library, relieving users of the need to create a profile for building Qt applications. [ChangeLog] The Depends item now falls back to pkg-config to locate dependencies whose names do not correspond to a qbs module. Fixes: QBS-1107 Change-Id: Ifd4f05c237cf58cd9fe707c3da648d3dbb33e82b Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'doc/reference/items/language/moduleprovider.qdoc')
-rw-r--r--doc/reference/items/language/moduleprovider.qdoc108
1 files changed, 108 insertions, 0 deletions
diff --git a/doc/reference/items/language/moduleprovider.qdoc b/doc/reference/items/language/moduleprovider.qdoc
new file mode 100644
index 000000000..ddbc25959
--- /dev/null
+++ b/doc/reference/items/language/moduleprovider.qdoc
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qbs.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/*!
+ \contentspage list-of-language-items.html
+ \previouspage Module
+ \nextpage Parameter
+ \qmltype ModuleProvider
+ \inqmlmodule QbsLanguageItems
+ \ingroup list-of-items
+ \keyword QML.ModuleProvider
+
+ \brief Creates modules on demand.
+
+ The \c ModuleProvider item implements the module creation part of the procedure described
+ in the \l {Module Providers} overview. It is always located in a file called \c provider.qbs.
+
+ The actual module creation is done on the right-hand side of the
+ \l{ModuleProvider::relativeSearchPaths}{relativeSearchPaths} property.
+
+ Here is a complete minimal example of a module provider. It just creates an empty module.
+ If you put this item into the file \c {module-providers/mymodule/provider.qbs}
+ in your project source directory, you will be able to successfully build a product which
+ contains a dependency on the module \c mymodule.
+ \code
+ import qbs.File
+ import qbs.FileInfo
+ import qbs.TextFile
+
+ ModuleProvider {
+ relativeSearchPaths: {
+ var moduleDir = FileInfo.joinPaths(outputBaseDir, "modules", name);
+ File.makePath(moduleDir);
+ var moduleFilePath = FileInfo.joinPaths(moduleDir, name + ".qbs");
+ var moduleFile = new TextFile(moduleFilePath, TextFile.WriteOnly);
+ moduleFile.writeLine("Module {");
+ moduleFile.writeLine("}");
+ moduleFile.close();
+ return "";
+ }
+ }
+ \endcode
+*/
+
+/*!
+ \qmlproperty string ModuleProvider::name
+
+ The name of the module provider.
+
+ This property is set by \QBS. For simple dependency names, it is the name of the dependency
+ as specified in the \l Depends item. If the dependency name consists of multiple components,
+ the value is the name up until (and including) the component that corresponds to the directory
+ the provider was found in. For instance, if the dependency is \c {x.m1} and the provider was
+ found in \c {module-providers/x/m1/provider.qbs}, then \c name is \c {x.m1}.
+ If the provider was found in \c {module-providers/x/provider.qbs}, then \c name is \c x.
+*/
+
+/*!
+ \qmlproperty string ModuleProvider::outputBaseDir
+
+ The path under which the new modules should be created when \l relativeSearchPaths
+ is evaluated. The path is unique for the current provider in the given configuration.
+
+ This property is set by \QBS.
+*/
+
+/*!
+ \qmlproperty stringList ModuleProvider::relativeSearchPaths
+
+ This property gets evaluated by \QBS to retrieve new search paths with which
+ to re-attempt the module look-up.
+
+ It is here where you need to put the code that creates the new module files.
+ Use the directory structure explained in \l {Custom Modules and Items}.
+ That is, the file for a module called \c m will be located in a directory \c {modules/m/},
+ anchored at \l outputBaseDir.
+
+ The return value is the list of search paths required to find the new module,
+ relative to \l outputBaseDir. In most cases, only a single search path will be required,
+ in which case a single-element list containing an empty string should be returned
+ (or just the empty string, because of \QBS' auto-conversion feature).
+
+ The returned list can also be empty, which means that the module provider was not able
+ to generate any modules in this environment.
+*/