Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-release > by-pkgid > 9cb465b43d7d9d0502376cd911c5ab45 > files > 28

qbs-doc-1.12.2-2.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qbs.qdoc -->
  <title>Custom Modules and Items | Qbs Manual</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="index.html">Qbs Manual</a></td><td >Custom Modules and Items</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qbs 1.12.2</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
  <link rel="prev" href="multiplexing.html" />
  <link rel="next" href="howtos.html" />
<p class="naviNextPrevious headerNavi">
<a class="prevPage" href="multiplexing.html">Multiplexing</a>
<span class="naviSeparator">  &#9702;  </span>
<a class="nextPage" href="howtos.html">How-tos</a>
</p><p/>
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#file-system-layout">File System Layout</a></li>
<li class="level1"><a href="#custom-modules">Custom Modules</a></li>
<li class="level1"><a href="#custom-items">Custom Items</a></li>
<li class="level1"><a href="#making-qbs-aware-of-custom-modules-and-items">Making Qbs Aware of Custom Modules and Items</a></li>
<li class="level2"><a href="#project-specific-modules-and-items">Project-specific Modules and Items</a></li>
<li class="level2"><a href="#making-custom-modules-and-items-available-across-projects">Making Custom Modules and Items Available Across Projects</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Custom Modules and Items</h1>
<span class="subtitle"></span>
<!-- $$$custom-modules.html-description -->
<div class="descr"> <a name="details"></a>
<p>Users of Qbs are not limited to the pre-defined <a href="qbsmodules-qmlmodule.html">modules</a> and <a href="qbslanguageitems-qmlmodule.html">items</a>, they can also create their own. Here we describe how to set up custom modules and items so that Qbs will find them.</p>
<a name="file-system-layout"></a>
<h2 id="file-system-layout">File System Layout</h2>
<p>Items and modules are located under a common base directory, whose name and location is completely arbitrary. We will refer to it as <code>search-path</code> here. This directory has two subdirectories <code>modules</code> and <code>imports</code>, which contain Qbs modules and items, respectively.</p>
<a name="custom-modules"></a>
<h2 id="custom-modules">Custom Modules</h2>
<p>To introduce a custom module <code>mymodule</code>, create a directory <code>search-path/modules/mymodule/</code>.</p>
<p><b>Note: </b>Module names are case-sensitive, and this also goes for the corresponding directory name.</p><p>Then, put a file containing an instance of the <a href="qml-qbslanguageitems-module.html">Module</a> in there and give it the <code>.qbs</code> extension. This module will be pulled in if a <a href="qml-qbslanguageitems-product.html">product</a> declares a <a href="qml-qbslanguageitems-depends.html">dependency</a> on <code>mymodule</code>.</p>
<a name="custom-items"></a>
<h2 id="custom-items">Custom Items</h2>
<p>To introduce a custom item <code>MyItem</code>, create the file <code>search-path/imports/MyItem.qbs</code>.</p>
<a name="making-qbs-aware-of-custom-modules-and-items"></a>
<h2 id="making-qbs-aware-of-custom-modules-and-items">Making Qbs Aware of Custom Modules and Items</h2>
<p>To be able to use your custom modules and items, you need to make them known to Qbs. You can do this per project or globally.</p>
<a name="project-specific-modules-and-items"></a>
<h3 >Project-specific Modules and Items</h3>
<p>Let's assume you have a project that is located in <code>project_dir</code> and you have created some modules in <code>project_dir/custom-stuff/modules/</code> as well as some items in <code>project_dir/custom-stuff/imports/</code> that you want to use in the project. To achieve this, your top-level project file should look like this:</p>
<pre class="cpp">

  <span class="comment">// ...</span>
  Project {
      <span class="comment">// ..</span>
      qbsSearchPaths: <span class="string">&quot;custom-stuff&quot;</span>
      <span class="comment">// ..</span>
  }

</pre>
<p><b>Note: </b>For technical reasons, the custom modules and items will not be available in the file that contains the <a href="qml-qbslanguageitems-project.html#qbsSearchPaths-prop">Project.qbsSearchPaths</a> property. Any product that wants to make use of them needs to be in a different file that is pulled in via the <a href="qml-qbslanguageitems-project.html#references-prop">Project.references</a> property, for example. This is not a serious limitation, since every well-structured project will be split up in this manner.</p><a name="making-custom-modules-and-items-available-across-projects"></a>
<h3 >Making Custom Modules and Items Available Across Projects</h3>
<p>What if your modules and items are generally useful and you want to access them in several projects? In this case, it is best to add the location to your preferences. For example:</p>
<pre class="cpp">

  qbs config preferences<span class="operator">.</span>qbsSearchPaths <span class="operator">/</span>usr<span class="operator">/</span>local<span class="operator">/</span>share<span class="operator">/</span>custom<span class="operator">-</span>qbs<span class="operator">-</span>extensions

</pre>
</div>
<!-- @@@custom-modules.html -->
<p class="naviNextPrevious footerNavi">
<a class="prevPage" href="multiplexing.html">Multiplexing</a>
<span class="naviSeparator">  &#9702;  </span>
<a class="nextPage" href="howtos.html">How-tos</a>
</p>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>