<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Hi,<br>
    <br>
    What is the best way to share source files and functionality among
    different projects. <br>
    1) imaging I have some source files I want to share among multiple
    projects. What is the best way to include these files using QBS? <br>
    With Qmake we use to do something like that<br>
    common_source.pri : <br>
    HEADERS+=$${PWD}/commonsource.h<br>
    SOURCES+=$${PWD}/commonsource.cpp<br>
    INCLUDEPATH+=$${PWD}<br>
    and in the main projet<br>
    mainproject.pri:<br>
    .....<br>
    include(Common/common_source.pri)<br>
    .....<br>
    <br>
    So that in one line in all projects we share the same source code<br>
    <br>
    In QBS I succeed to do that but using static library<br>
    common_source.qbs<br>
    Product {<br>
        type: "staticlibrary"<br>
        name:"common_source"<br>
        files:["commonsource.h","commonsource.cpp"]<br>
        Depends { name: "Qt" ; submodules: ["core"] }<br>
        Depends { name: "cpp" }<br>
        Export{<br>
            cpp.includePaths: "."<br>
        }<br>
    }<br>
    mainproject.qbs:<br>
    Project{<br>
        references:[Common/common_source.qbs]<br>
    <br>
        Application {<br>
            ......<br>
            Depends { name : "common_source"}<br>
    ....<br>
    }<br>
    My questions : <br>
    - does what I have done is a good solution ?<br>
    - is there any other solution by just including source file (like
    with qmake) and not creating a static library?<br>
    <br>
    <br>
    2) How to share functionality between projects.<br>
     As an example, imagine I want to automatically generate a file
    according to project properties <br>
                    Project {<br>
                    <span style=" color:#808000;">property</span><span
      style=" color:#c0c0c0;"> </span><span style=" color:#808000;">string</span><span
      style=" color:#c0c0c0;"> </span><span style=" color:#800000;">version</span>:<span
      style=" color:#008000;">"1.3.5"<br>
                      ......<br>
    </span><span style=" color:#c0c0c0;"> </span>
    <meta name="qrichtext" content="1">
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span>Transformer<span style=" color:#c0c0c0;"> </span>{</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">            </span>Artifact<span style=" color:#c0c0c0;"> </span>{</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">                </span><span style=" color:#800000;">fileName</span>:<span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"output_file.txt"</span></pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">            </span>}</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">            </span><span style=" color:#800000;">prepare</span>:<span style=" color:#c0c0c0;"> </span>{</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">                </span><span style=" color:#808000;">var</span><span style=" color:#c0c0c0;"> </span><span style=" font-style:italic; color:#2985c7;">cmd</span><span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">new</span><span style=" color:#c0c0c0;"> </span>JavaScriptCommand();</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">                </span><span style=" font-style:italic; color:#2985c7;">cmd</span>.description<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"Generating</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">file</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">'"</span><span style=" color:#c0c0c0;"> </span>+<span style=" color:#c0c0c0;"> </span>output.fileName<span style=" color:#c0c0c0;"> </span>+<span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"'"</span>;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">                </span><span style=" font-style:italic; color:#2985c7;">cmd</span>.sourceCode<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">function</span>()<span style=" color:#c0c0c0;"> </span>{</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">                    </span><span style=" color:#808000;">var</span><span style=" color:#c0c0c0;"> </span><span style=" font-style:italic; color:#2985c7;">content</span><span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"product</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">version</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"</span>+project.version;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">                    </span><span style=" color:#808000;">var</span><span style=" color:#c0c0c0;"> </span><span style=" font-style:italic; color:#2985c7;">file</span><span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">new</span><span style=" color:#c0c0c0;"> </span>TextFile(output.fileName,<span style=" color:#c0c0c0;"> </span>TextFile.WriteOnly);</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">                    </span><span style=" font-style:italic; color:#2985c7;">file</span>.write(<span style=" font-style:italic; color:#2985c7;">content</span>);</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">                    </span><span style=" font-style:italic; color:#2985c7;">file</span>.close();</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">                </span>}</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">                </span><span style=" color:#808000;">return</span><span style=" color:#c0c0c0;"> </span><span style=" font-style:italic; color:#2985c7;">cmd</span>;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">            </span>}</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span>}
        .....
        }

</pre>
    <style type="text/css">
p, li { white-space: pre-wrap; }
</style>I would like the transformer to be share among many projects so
    that I only need to include in the project file a qbs file only
    containing this transformer. <br>
    What is the best solution to do that ?<br>
    <br>
    <br>
    <br>
    Many thanks in advance for help.<br>
    <br>
    Regards<br>
    <br>
    <br>
    <br>
    <br>
    <br>
  </body>
</html>