[QBS] How to change build directory of a Product?

Jake Petroules jake.petroules at petroules.com
Sat May 3 22:40:51 CEST 2014


Hi Santanu,

First, please ensure you're using the latest available version(s) of Qt Creator and Qbs to be certain you have the latest features and bug fixes.

On 2014-05-03, at 12:20 PM, .Santanu Chakrabarti <santanu.chakrabarti at gmail.com> wrote:
> Hi,
> 
> I am Santanu from India, a software developer with more than 12yrs of application development in Java. I am very much fond of the Gradle build tool for Java due to the flexibility and ease of use that it provides. So when recently I thought of making my hands dirty in developing application in C language I started looking for a similar build tool. Then I come to know about QBS, and at first sight it looked really promising.
> 
> But when I started using QBS with qtcreator I started facing the real challenge. Its very simple to build and run a multi-file C/C++ project with QBS with the default configuration. But when one goes to configure the product/project according to one's desire there starts the frustration. So here are some queries I am struggling with at present.
> 1. How to change the name of default build directory? I found in documentation that there is a buildDirectory property for Product item. But when I set the value of this property for CppApplication in QBS build script, qtcreator throws error that the property is not declared.
> 
It depends on what you mean by build directory. Do you mean the root build directory of the entire project? If so, you can specify that in the Projects tab of Qt Creator under Build Settings (see "Build directory"). If you mean to change the directory in which the output artifact(s) of your Product appear, within the build directory, you can specify a relative path using the "destinationDirectory" property of the Product item. For example, you might specify "bin" for executables and "lib" for shared libraries.

Product.buildDirectory is, as noted in the documentation, "automatically set by qbs". You can read the value on the right hand side of a property binding through the expression `product.buildDirectory` but you cannot change it.
> 2. I have found that the object file that is getting created if I build the QBS project has the name "XXXXX.c.o" if the file name is "XXXXX.c". How can I configure QBS to name the object file as "XXXXX.o"?
> 
We did this so that having multiple files with the same base name but different extensions will not cause an error. For example, if you have both file.c and file.cpp, both cannot be built into file.o as this causes a conflict. Currently you cannot change the naming scheme of object files but given a good reason we may add a way for users to configure it. Is there a specific reason you need your object files named XXXXX.o?
> 3. Moreover the object files are getting generated in a folder ".obj" in the default build directory. How to configure this also?
> 
This is currently not user-configurable but probably should be.
> I am new to QBS as well as writing applications in C so any help regarding my above queries would be much appreciated. I shall also like to make some observations on QBS build system and its documentation.
> 1. I believe QBS is a very flexible build system, at least it appears so to me. But the documentation is very poor for a newcomer. Specifically, elaborate documentation is needed in the areas like Transformer, Rule (both multiplex and non-multiplex), Module, etc.
> 
Qbs is a very new product so we still have a lot of work to do in this area but it's definitely on the roadmap.
> 2. Also documentation is needed on different JavaScript objects that are accessible from QBS script like Command, JavaScriptCommand, File, etc.
> 
Some of these are documented here: https://qt-project.org/doc/qbs-1.1/list-of-builtin-services.html, but we're aware that there are a few things that are still missing.
> 3. Examples that are provided with QBS source code are not sufficient to build up ideas on different QBS constructs.
> 
Again, Qbs is still very new but we will certainly include more examples in the future.
> 4. It is not obvious from documentation how to create custom build jobs in QBS. For example lets say in my project I have flex/bison files along with other C files and I want to build those flex/bison files first with respective tools before compiling all the C files. How to specify this custom step?
> 
You'd do this using custom Rules, Transformers, and Modules. I remember another user had written some Qbs scripts to handle flex/bison files; perhaps we can add built-in support at some point. Again, this is something that more extensive documentation could help with as you noted in (1).
> 5. Also lets assume that while building my C project I want to first check if all my unit test cases pass. How to do that in QBS build script?
> 
Depends on what testing suite you're using but you basically create a command line executable product which executes your unit tests, and build and run that product using `qbs run`. You can add a dependency on QtTest by adding Depends { name: "Qt.test" }
> I would really like to see QBS grow as a very flexible and easily adaptable build system for C/C++ projects. So I hope my inputs will be helpful in this regard.
> 
As would we. :) Thanks for your input and please let us know of any bugs you find at bugreports.qt-project.org
> Thanks and regards
> Santanu
> 
> _______________________________________________
> QBS mailing list
> QBS at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qbs

-- 
Jake Petroules - jake.petroules at petroules.com
Chief Technology Officer - Petroules Corporation
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20140503/7464003e/attachment.html>


More information about the Qbs mailing list