<div dir="ltr">Is there no way to do this in two files instead of three? It doesn't seem like I can put the `import YourFunctions` before the `Project`, so I need a separate file for the Project and Product, and then a third for the javascript. Is that right?<div>

<br></div><div>Cheers,</div><div><br></div><div>Tim</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 15 May 2014 10:37, Denis Shienkov <span dir="ltr"><<a href="mailto:denis.shienkov@gmail.com" target="_blank">denis.shienkov@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Hi,<br><br></div>1. Your function shall be in the functions.js file , e.g. in: /yourproject/qbs/imports/YourFunctions/functions.js<br>

</div>2. Also your Project should have an option:<br>
<br></div>Project {<br>...<br>qbsSearchPaths: "qbs"<br>...<br>}<br><br></div>3. Your Product's file should contains:<br><br>...<br>import YourFunctions<br>...<br>...<br>property string gnuToolsDir: YourFunctions.findGnuToolsDir();<br>


...<br><br>I would make it so. Also you can look how this done by analogy, e.g. in QtCreator's sources.<br><br><br></div>BR,<br>Denis<br><div><div><div><div><br><br></div></div></div></div></div><div class="gmail_extra">


<br><br><div class="gmail_quote">2014-05-15 12:30 GMT+04:00 Tim Hutt <span dir="ltr"><<a href="mailto:tdhutt@gmail.com" target="_blank">tdhutt@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><div class="h5">
<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">Hi,</span><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">I have a QBS script that depends on using the GNU Arm toolchain, and I want it to automatically find them (on Windows for now). In my QBS I have this line:</div>




<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(128,128,0)">property</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">string</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">gnuToolsDir</span>:<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">"C:/Program</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">Files/GNU</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">Tools</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">ARM</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">Embedded/4.8</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">2014q1"</span></pre>




<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><br></pre>And then I use that elsewhere. I want to set it to be a function, like this:</div><div style="font-family:arial,sans-serif;font-size:13px"><br>



</div>
<div style="font-family:arial,sans-serif;font-size:13px"><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">       </span><span style="color:rgb(128,128,0)">function</span><span style="color:rgb(192,192,192)"> </span>findGnuToolsDir()</pre>




<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span>{</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">              </span><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">TODO:</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">Fancy</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">searching</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">function.</span></pre>




<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">                </span><span style="color:rgb(128,128,0)">return</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">"C:/Program</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">Files/GNU</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">Tools</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">ARM</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">Embedded/4.8</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">2014q1"</span>;</pre>




<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span>}</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">      </span></pre>




<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(128,128,0)">property</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">string</span><span style="color:rgb(192,192,192)"> </span>gnuToolsDir:<span style="color:rgb(192,192,192)"> </span>findGnuToolsDir();</pre>




<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><br></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="font-family:arial">But that doesn't work (says it can't find the function). </span><span style="font-family:arial">Additionally, I can't seem to access the property in my Rules - it says the variable doesn't exist.</span></pre>




<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="font-family:arial"><br></span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">


<span style="color:rgb(192,192,192)">   </span>Rule<span style="color:rgb(192,192,192)"> </span>{</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">               </span><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">...</span></pre>




<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">                </span>prepare:<span style="color:rgb(192,192,192)"> </span>{</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">


<span style="color:rgb(192,192,192)">                   </span><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">None</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">of</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">these</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">work:</span></pre>




<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">                        </span><span style="color:rgb(128,128,0)">var</span><span style="color:rgb(192,192,192)"> </span>objCopyPath<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span>gnuToolsDir<span style="color:rgb(192,192,192)"> </span>+<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">"/bin/arm-none-eabi-objcopy.exe"</span>;</pre>




<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">                        </span><span style="color:rgb(128,128,0)">var</span><span style="color:rgb(192,192,192)"> </span>objCopyPath<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span>parent.gnuToolsDir<span style="color:rgb(192,192,192)"> </span>+<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">"/bin/arm-none-eabi-objcopy.exe"</span>;</pre>




<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">                        </span><span style="color:rgb(128,128,0)">var</span><span style="color:rgb(192,192,192)"> </span>objCopyPath<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span>product.gnuToolsDir<span style="color:rgb(192,192,192)"> </span>+<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">"/bin/arm-none-eabi-objcopy.exe"</span>;</pre>





<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">                        </span><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">...</span></pre>




<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">                </span>}</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">      </span>}</pre>




<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><br></pre></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="font-family:arial">Any ideas? I've seen the Probe item but it doesn't seem suitable - as far as I can tell it just determines the existence of a library or tool rather than its location.</span></pre>




<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="font-family:arial"><br></span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="font-family:arial">Cheers,</span></pre>




<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="font-family:arial"><br></span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="font-family:arial">Tim</span></pre>




</div></div>
<br></div></div><div class="">_______________________________________________<br>
QBS mailing list<br>
<a href="mailto:QBS@qt-project.org" target="_blank">QBS@qt-project.org</a><br>
<a href="http://lists.qt-project.org/mailman/listinfo/qbs" target="_blank">http://lists.qt-project.org/mailman/listinfo/qbs</a><br>
<br></div></blockquote></div><br></div>
</blockquote></div><br></div>