Sophie

Sophie

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

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" />
<!-- commands.qdoc -->
  <title>Command and JavaScriptCommand | 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 >Command and JavaScriptCommand</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">
<p class="naviNextPrevious headerNavi">
</p><p/>
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#command">Command</a></li>
<li class="level1"><a href="#javascriptcommand">JavaScriptCommand</a></li>
<li class="level1"><a href="#properties">Properties</a></li>
<li class="level2"><a href="#common-properties">Common Properties</a></li>
<li class="level2"><a href="#command-properties">Command Properties</a></li>
<li class="level2"><a href="#javascriptcommand-properties">JavaScriptCommand Properties</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Command and JavaScriptCommand</h1>
<span class="subtitle"></span>
<!-- $$$commands.html-description -->
<div class="descr"> <a name="details"></a>
<p>A <i>command</i> is what Qbs executes at build time. It is represented in the language by an object of type <code>Command</code>, which runs a process, or <code>JavaScriptCommand</code>, which executes arbitrary JavaScript code. A command is always created in the prepare script of a <code>Rule</code>.</p>
<a name="command"></a>
<h2 id="command">Command</h2>
<p>A <code>Command</code> represents a process that will be invoked at build time. Its constructor arguments are the binary to run and a list of command-line arguments. For instance:</p>
<pre class="cpp">

  var insaneCommand <span class="operator">=</span> <span class="keyword">new</span> Command(<span class="string">&quot;rm&quot;</span><span class="operator">,</span> <span class="operator">[</span><span class="string">&quot;-r&quot;</span><span class="operator">,</span> <span class="string">&quot;/&quot;</span><span class="operator">]</span>);

</pre>
<p>The <a href="qml-qbslanguageitems-rule.html">Rule</a> item documentation shows a <code>Command</code> in context.</p>
<a name="javascriptcommand"></a>
<h2 id="javascriptcommand">JavaScriptCommand</h2>
<p>A <code>JavaScriptCommand</code> represents a chunk of JavaScript code that is run at build time. For instance:</p>
<pre class="cpp">

  var cmd <span class="operator">=</span> <span class="keyword">new</span> JavaScriptCommand();
  cmd<span class="operator">.</span>apology <span class="operator">=</span> <span class="string">&quot;Sorry.&quot;</span>;
  cmd<span class="operator">.</span>sourceCode <span class="operator">=</span> function() {
      console<span class="operator">.</span>info(<span class="string">&quot;I'm a rather pointless command.&quot;</span>);
      console<span class="operator">.</span>info(apology);
  };

</pre>
<p>Within the source code, the special identifiers <code>project</code> and <code>product</code> (giving access to project and product properties, respectively) as well as <code>inputs</code> and <code>outputs</code> are available. As the example shows, arbitrary properties can be set on the command object and then used within the source code. This technique is typically used to forward values from the prepare script to the command. The <a href="qml-qbslanguageitems-rule.html">Rule</a> item documentation shows a <code>JavaScriptCommand</code> in context.</p>
<a name="properties"></a>
<h2 id="properties">Properties</h2>
<a name="common-properties"></a>
<h3 >Common Properties</h3>
<p>The following properties are available in both <code>Command</code> and <code>JavaScriptCommand</code>.</p>
<div class="table"><table class="generic">
 <thead><tr class="qt-style"><th >Property</th><th >Type</th><th >Default</th><th >Description</th></tr></thead>
<tr valign="top" class="odd"><td ><code>description</code></td><td >string</td><td >empty</td><td >A message that is displayed when the command is executed.</td></tr>
<tr valign="top" class="even"><td ><code>extendedDescription</code></td><td >string</td><td >empty</td><td >A detailed description that is displayed when the command is executed.</td></tr>
<tr valign="top" class="odd"><td ><code>highlight</code></td><td >string</td><td >empty</td><td >A tag that can be used to influence how the <code>description</code> is displayed. In principle, the values are arbitrary. The Qbs command-line tool understands the following values and maps them to different colors if the output device is a terminal:<ul>
<li>&quot;compiler&quot; indicates that the command processes source code</li>
<li>&quot;linker&quot; indicates that the command links objects</li>
<li>&quot;codegen&quot; indicates that the command generates source code</li>
<li>&quot;filegen&quot; indicates that the command creates arbitrary files</li>
</ul>
<p>All other values are mapped to the default color.</p>
</td></tr>
<tr valign="top" class="even"><td ><code>silent</code></td><td >bool</td><td >false</td><td >A flag that controls whether the <code>description</code> is printed. Set it to <code>true</code> for commands that users need not know about.<p><b>Note: </b>If this property is <code>false</code>, then <code>description</code> must not be empty.</p></td></tr>
</table></div>
<a name="command-properties"></a>
<h3 >Command Properties</h3>
<div class="table"><table class="generic">
 <thead><tr class="qt-style"><th >Property</th><th >Type</th><th >Default</th><th >Description</th></tr></thead>
<tr valign="top" class="odd"><td ><code>arguments</code></td><td >stringList</td><td >empty</td><td >The list of arguments to invoke the command with. Explicitly setting this property overrides an argument list provided when instantiating the object.</td></tr>
<tr valign="top" class="even"><td ><code>environment</code></td><td >stringList</td><td >empty</td><td >A list of environment variables that are added to the common build environment. They are provided as a list of strings in the form &quot;varName=value&quot;.</td></tr>
<tr valign="top" class="odd"><td ><code>maxExitCode</code></td><td >int</td><td >0</td><td >The maximum exit code from the process to interpret as success. Setting this should rarely be necessary, as all well-behaved applications use values other than zero to indicate failure.</td></tr>
<tr valign="top" class="even"><td ><code>program</code></td><td >string</td><td >undefined</td><td >The binary to invoke. Explicitly setting this property overrides a path provided when instantiating the object.</td></tr>
<tr valign="top" class="odd"><td ><code>relevantEnvironmentVariables</code></td><td >stringList</td><td >undefined</td><td >Names of environment variables that the invoked binary considers. If one of these variables changes in the build environment, the command will be re-run even if the input files are still up to date.</td></tr>
<tr valign="top" class="even"><td ><code>responseFileThreshold</code></td><td >int</td><td >32000 on Windows, -1 elsewhere</td><td >If this value is greater than zero and less than the length of the full command line, and if <code>responseFileUsagePrefix</code> is not empty, the contents of the command line are moved to a temporary file, whose path becomes the entire contents of the argument list. The program is then supposed to read the full argument list from that file. This mechanism is mainly useful to work around Windows limitations regarding the maximum length of the command line and will only work with programs that explicitly support it.</td></tr>
<tr valign="top" class="odd"><td ><code>responseFileArgumentIndex</code></td><td >int</td><td >0</td><td >Index of the first argument to include in the response file. For example this may be used in conjunction with a compiler wrapper where the first argument (the path to the compiler) must be included on the raw command line.</td></tr>
<tr valign="top" class="even"><td ><code>responseFileUsagePrefix</code></td><td >string</td><td >empty</td><td >The prefix that informs <code>program</code> that the rest of the argument is a path to a file containing the actual command line.</td></tr>
<tr valign="top" class="odd"><td ><code>stderrFilterFunction</code></td><td >function</td><td >undefined</td><td >A function that takes as input the command's actual standard error output and returns a string that is presented to the user as the command's standard error output. If it is not set, the output is shown unfiltered.</td></tr>
<tr valign="top" class="even"><td ><code>stdoutFilterFunction</code></td><td >function</td><td >undefined</td><td >A function that takes as input the command's actual standard output and returns a string that is presented to the user as the command's standard output. If it is not set, the output is shown unfiltered.</td></tr>
<tr valign="top" class="odd"><td ><code>workingDirectory</code></td><td >string</td><td >empty</td><td >The program's working directory.</td></tr>
<tr valign="top" class="even"><td ><code>stdoutFilePath</code></td><td >string</td><td >undefined</td><td >Redirects the filtered standard output content to <code>stdoutFilePath</code>. If <code>stdoutFilePath</code> is undefined, the filtered standard output is forwarded to Qbs, possibly to be printed to the console.</td></tr>
<tr valign="top" class="odd"><td ><code>stderrFilePath</code></td><td >string</td><td >undefined</td><td >Redirects the filtered standard error output content to <code>stderrFilePath</code>. If <code>stderrFilePath</code> is undefined, the filtered standard error output is forwarded to Qbs, possibly to be printed to the console.</td></tr>
</table></div>
<a name="javascriptcommand-properties"></a>
<h3 >JavaScriptCommand Properties</h3>
<div class="table"><table class="generic">
 <thead><tr class="qt-style"><th >Property</th><th >Type</th><th >Default</th><th >Description</th></tr></thead>
<tr valign="top" class="odd"><td ><code>sourceCode</code></td><td >function</td><td >undefined</td><td >The JavaScript function to execute.</td></tr>
</table></div>
</div>
<!-- @@@commands.html -->
<p class="naviNextPrevious footerNavi">
</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>