[QBS] Generating rc file

olivier musse olivier.musse at sfr.fr
Fri May 16 12:59:50 CEST 2014


Hi everybody,

Since QBS is not yet managing automatic generation of rc file from 
properties (version, name...) of a CppApplication, I would like to 
create a generic qbs file so that I can call it from any project and do 
the job.

This should :
- generating a rc file from an input rc file (product.rc.in) where I 
replace some part with properties (version, name, copyright...) of the 
calling product
- add the generated RC file to the calling product so that it is compiled

The transformer I created looks like the one at theend of this mail. In 
order to the generated.rc to be compiled I add an associated Group item

1) The rc file is well generated but is not compiled, did I made a 
mistake anywhere in the Transformer Artifact or Group
2) What is the best solution (Module, Product...)  to put this 
transformer and group in a separate file I can use from any project with 
a simple Depends{ name : "generated.qbs"} call  or something equivalent. 
I have tried using another product, but in this case the properties 
(product.version) are not the one of the calling product and it is 
impossible to automatically add the file to the calling product. 
(Export{files:["generatedRC"}} does not work

Many thanks in advance for help.

Regards



                 version:"1.3.4"

         Transformer  {

             inputs:  "product.rc.in"

             Artifact  {

                 fileName:  "generated.rc"

                 fileTags:  "generatedRC"

             }

             prepare:  {

                 var  cmd  =  new  JavaScriptCommand();

                 cmd.description  =  "Processing  '"  +  input.fileName  +  "'";

                 cmd.highlight  =  "codegen";

                 cmd.sourceCode  =  function()  {

                     var  file  =  new  TextFile(input.fileName);

                     var  content  =  file.readAll();

                     file.close()

                     content  =  content.replace(/##VERSION_STR##/g,  product.version);

                     file  =  new  TextFile(output.fileName,  TextFile.WriteOnly);

                     file.truncate();

                     file.write(content);

                     file.close();

                 }

                 return  cmd;

             }

         }

         Group{

             name:"RCFile"

             fileTagsFilter:"generatedRC"

         }




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20140516/4eefcac1/attachment.html>


More information about the Qbs mailing list