[Qbs] How to check whether a project is a subproject of another project?

Иван Комиссаров abbapoh at gmail.com
Sat Jul 20 18:43:41 CEST 2019


You can make two top-level projects, something like «my lib-standalone.qbs» which includes «mylib.qbs» and setups the properties to enable tests/whatever. All what you don’t want for users is disabled by default.

> 20 июля 2019 г., в 6:27, Vincent Hui <vincenthk007 at gmail.com> написал(а):
> 
> Hi Christian,
> 
> Thank you very much for your reply.
> 
> I am sorry for not stating my question clearly. Perhaps I should use isStandalone instead of isSubProject, my motivation is to facilitate users of my libraries which are stored in individual git repository. The main product of my qbs project is a library, other products are examples and tests.
> 
> To reduce build time for whole source tree, I prefer examples and tests of my project are not built if my qbs project is not a standalone project. That means my qbs project is added by other projects as a git module. To save time and code of users of my projects, I prefer users of my projects do not need to override properties of my qbs project in order not to build examples and tests. Therefore I need a property to know whether my qbs project is a standalone project.
> 
> By the way, why path is undocumented? Is it because path is private? Why not make it public? Should path be renamed? path being a property name (https://github.com/qbs/qbs/blob/master/src/lib/corelib/buildgraph/buildgraph.cpp#186 <https://github.com/qbs/qbs/blob/master/src/lib/corelib/buildgraph/buildgraph.cpp#186> line#186) and a type name is a bit confusing I think.
> 
> Thank you again,
> Vincent
> 
> 
> On Thu, 18 Jul 2019 at 00:08, Christian Kandeler <Christian.Kandeler at qt.io <mailto:Christian.Kandeler at qt.io>> wrote:
> On Wed, 17 Jul 2019 23:25:49 +0800
> Vincent Hui <vincenthk007 at gmail.com <mailto:vincenthk007 at gmail.com>> wrote:
> 
> > I want to check whether a project is a subproject of another project. If a
> > project is not a subproject, its examples and tests are built. If a project
> > is a subproject, its examples and tests are not built.
> 
> Declare a property in your project that controls this. Override this property from the containing project. Done.
> 
> > It seems that the method for checking whether a project is a subproject is
> > undocumented.
> 
> There is no such method, and I don't think it would be a good idea to have it.
> 
> > I came up with a method to check whether a project is a subproject. It is
> > checking whether  sourceDirectory is equal to path. I tried a simple
> > project, my method works.
> > 
> > "
> > Project {
> >     readonly property bool isSubProject: (sourceDirectory === path) ? false
> > : true;
> > ......
> > "
> > 
> > Can my method work in complicated projects?
> 
> No. The parent project could be in the same directory.
> 
> 
> Christian
> _______________________________________________
> Qbs mailing list
> Qbs at qt-project.org <mailto:Qbs at qt-project.org>
> https://lists.qt-project.org/listinfo/qbs <https://lists.qt-project.org/listinfo/qbs>
> _______________________________________________
> Qbs mailing list
> Qbs at qt-project.org
> https://lists.qt-project.org/listinfo/qbs

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20190720/1d4c24e9/attachment.html>


More information about the Qbs mailing list