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

Configure and multiplex dependencies using parameterization

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • None

    Description

      It would be cool, if a Product could be configured and multiplexed through a Depends item to it.
      Consider the following imaginary project:

      • Engine
          
      • Graphics (Needs: OpenGL, SDL2, ...)
          
      • Audio (Needs: OpenAL)
          
      • Network (Needs: Winsock2 on Windows)
          
      • Support for png textures (Needs: libpng)
          
      • Support for jpg textures (Needs: libjpg)
      • Some Singleplayer-Game
          
      • Engine (Graphics, Audio, png-support)
      • Some Multiplayer-Game
          
      • Engine (Graphics, Audio, Network, jpg-support)
      • Multiplayer-Game Server
          
      • Engine (Network)

      Engine is a independently developed product, that is only added as dependency to the project.
      The Engine is configurable through defines, that can enable and disable parts of it.

      Since Engine has quite a lot of library dependencies, it would make sense if products depending on it can configure it, to avoid unneeded dependencies.

      StaticLibrary {
           name: "Engine"
           
           property bool withGraphics: false
           property bool withAudio: false
           property bool withNetwork: false
           property bool withPng: false
           property bool withJpg: false
           
           cpp.defines: {
               var result = [];
               if(withGraphics) result.push("HAVE_GRAPHICS");
               if(withAudio) result.push("HAVE_AUDIO");
               ...
               return result;
           }
           cpp.dynamicLibraries: {
               var result = [];
               if(withGraphics) result.concat(["SDL2", "GL"]);
               if(withAudio) result.push("OpenAL");
               ...
               return result;
           }
       }
      Product {
           name: "Some Singleplayer-Game"
           Depends { name: "Engine"; withGraphics: true; withAudio: true; withPng: true }
       }
      Product {
           name: "Some Multiplayer-Game"
           Depends { name: "Engine"; withGraphics: true; withAudio: true; withNetwork: true; withJpg: true }
       }

      If those two products depending on Engine are in the same project, then the Engine would have to be built twice with different configuration (= multiplexed over the passed configuration options).

      Syntax-wise this could maybe be achieved by adding a flag to the property definition, like:

      property multiplex bool withGraphics: false

      Splitting the Engine's components is not possible in our case, because the core would still have to be re-compiled with the defines to make use of the respective components.
      Is there a mechanism in qbs to support such a project-setup already, that I wasn't able to find?

      Attachments

        Issue Links

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

          Activity

            People

              kandeler Christian Kandeler
              seijikun Markus Ebner
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes