Uploaded image for project: 'Qbs ("Cubes")'
  1. Qbs ("Cubes")
  2. QBS-1146

Qbs should support dynamic item creation

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 1.8.0
    • General
    • None

    Description

      Suppose you have a project with 2 subprojects that translate into products and you have them simply placed in 2 subfolders. Currently you need to write it like this:

      import Qbs
      Project
      {
          DynamicLibrary
          {
              name: "Lib1"
              files: [ "lib1/*.cpp", "lib1/*.h"] 
          }
          DynamicLibrary
          {
              name: "Lib2"
              files: [ "lib1/*.cpp", "lib1/*.h"]
          }
      }
      

      Notice how the only difference betwen the two products is their name. Would not it be nice if one could do:

      import qbs
      import qbs.File
      
      Project
      {
          id: pro
          property stringList list:
          {
              var list = File.directoryEntries(qbs.sourceDirectory, File.Dirs | File.NoDotAndDotDot);
              var component = Qt.createComponent("Product.qml");
              for(var dir in list)
              {
                  var product = component.createObject(pro);
                  product.name: list[dir];
                  product.files: [ list[dir] + "/*.cpp", list[dir] + "/*.h" ];
              }
      { 
      

      Currently this will not work because this line:

      var component = Qt.createComponent("Product.qml");
      

      uses Qt.createComponent that is not available in Qbs and additionall "Product.qml" is likely not a regular QML component to be created like that. Another obstacle is probably component.createObject with parent being the id of Project but perhaps that would work as in QML.

      I am not sure whether this is possible (with Qbs being dialect of QML) or if there is a better way to accomplish this (most likely). Interestingly this would be possible in qmake if qmake supported multiple projects per file but it would be possible for example to dynamically add subdirs in subdirs project.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              jbornema Joerg Bornemann
              resurr3ction Michael Vlach
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes