qt5qbs

QBS profiles are not saved and updated at any time


I have QtCreator on a PC running Windows and Ubuntu. Ubuntu I use to build a project for Linux and for RaspberryPi. A Windows PC is used to build the project in x86, x86_64 and android: armv7a, arm64, x86 (for the emulator). Also windows is used to develop embedded software for stm32. Accordingly, I need 6 qbs profiles for windows and 3 profiles for linux. The project itself uses QBS as a build system.

The problem is that it is very difficult to determine which set is currently in use. Below I give the beginning of my qbs file, where I initialize the main variables.

import qbs

Project {

    property var _TargetEnum: ({
                                   win_x86      : 1,
                                   win_x86_64   : 2,
                                   raspberryPi  : 3,
                                   stm32        : 4,
                                   android      : 5, 
                                   linux        : 6, 
                               })

    property var Target
    Properties {
        condition: (qbs.targetPlatform === "windows")
        Target: (qbs.architecture === "x86") ? _TargetEnum.win_x86 : _TargetEnum.win_x86_64
    }
    Properties {
        condition: (qbs.targetPlatform === "RaspberryPi")
        Target: _TargetEnum.raspberryPi
    }
    Properties {
        condition: (qbs.targetPlatform === "stm32")
        Target: _TargetEnum.stm32
    }
    Properties {
        condition: (qbs.targetPlatform === "android")
        Target: _TargetEnum.android
    }
    Properties {
        condition: (qbs.targetPlatform === "linux")
        Target: _TargetEnum.linux
    }

    property var _BuildModeEnum: ({
                                  debug     : 1,
                                  release   : 2
                              })

    property var BuildMode: qbs.buildVariant.contains("debug") ?
                                 _BuildModeEnum.debug :
                                 _BuildModeEnum.release
...
}

QBS profiles created automatically do not have completely filled fields and I have to manually fill in these fields using the qbs-config-ui utility. Moreover, the behavior of this utility and qtcreator is different in windows and linux.

In windows, the following happens: after opening qtcreator, the old settings in Tools-Kit-Qbs remain from the last working session, after opening a working project, the settings are reset to the default state. Next, I open the qbs-config-ui utility and manually make changes to qbs.targetPlatform and qbs.architecture in the packages I need, I save the settings. In QtCreator, I open the settings window and see that my changes have been made. Then I can work until the next working session.

In Linux, this behavior is generally absent, no regularities how the profile is updated in QtCreator and how it flies I have not yet been able to see.

My question is how do I properly configure QBS profiles once and for all so that I don’t have to reconfigure them.


Solution

  • Do not try to attempt to amend qbs profiles derived from Qt Creator kits "from the outside" -- that will not work reliably, as you've discovered. These profiles can get regenerated at any time. Instead, go to Tools -> Options -> Kits and do your changes via the "Additional Qbs Properties" entry in the kit dialog. These changes will persist.