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

introduce Switch-Case construct

    XMLWordPrintable

Details

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

    Description

      it has been previously suggested to add an if-else construct to the qbs language. however, we rejected it in the presented form for good reasons. see http://lists.qt-project.org/pipermail/qbs/2012-February/000049.html

      but chains of mutually exclusive blocks are relatively common, with two visible consequences:

      • the Properties items are implicitly chained. of course, such magic behavior is entirely unexpected, and therefore a rather bad idea, as proven by confused users. see for example http://lists.qt-project.org/pipermail/qbs/2013-December/000588.html
      • for other items, chaining must be manually implemented (FIXME: i can't find the official guideline, but i remember that there were related mailing list posts)

      a cleaner approach would be making the cascading explicit like this:

      Switch {
          Case {
              condition: qbs.targetOs.contains('windows')
              cpp.defines: "BILLED"
          }
          Case {
              condition: qbs.targetOs.contains('darwin')
              cpp.defines: "STEVED"
          }
          Case {
              condition: qbs.targetOs.contains('unix')
              cpp.defines: "FORKED"
          }
          Case {
              // FIXME: make something out of this that would actually work
              error("Unsupported target OS")
          }
          Case {
              // throws an error, because a conditional case after the default case makes no sense.
              condition: qbs.targetOs.contains('dos')
          }
      }
      

      this is a well-defined structure with no hidden meanings (except for the order of the Case items, which seems natural), so it should be easy to implement and be well toolable.

      note that the suggested semantics for the nested properties are additive by default like for the Properties item. that would make it unnecessary to use Group just to have a conditional list of files.

      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
              buddenha Oswald Buddenhagen
              Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes