- Did you ever feel frustrated using Qbs?
- Not enough details in error log when things go south?
- Crashes?
- Lack of ways to debug your qbs markup?
Did you experience the dreaded "Qbs process quit unexpectedly"?
You are not alone!
In this article I have tried to collect some resources plus tips & tricks related to Qbs debugging, Qbs bug reporting, contributing to Qbs and more.
Let's start at the top with some useful tips & tricks I have learned the hard way while working with Qbs.
Where does Qbs output?
- Qbs will output warnings and errors to "Issues" window in QtCreator.
- The actual compiler invocations will show up in "Compile Output" window.
- Whatever log output your Qbs code produces to "General Messages" window.
Build Settings
- When building your project you of course want "parallel jobs" set to the number of cores on your CPU, but while debugging, sometimes setting it to 1 will give you more serial output which might help you.
- I usually have "keep going" enabled at all times, because sometimes when it is disabled, I don't discover some underlying problems. Other times, all the extra output may be distracting. What I am saying is, it is worth changing this setting depending on your case.
- Show command lines is your friend. It will allow you to see what commands were run by Qbs
- Force Probes I usually keep off during normal use, BUT when I am debugging my qbs files, especially if they contain a probe, simply clicking this checkmark on/off quickly will spit out very useful output as the probes will be invoked directly (it could very much have been a button!).
- The command line used to start Qbs is automatically generated from the settings you chose, but you can also add other options here which may be very useful. For example, you could wrap the Qbs executable in a shell script to start it in a debugger for example.
Make sure to enable warnings in Issues window
Sometimes, a mistake in your qbs file will disable that qbs file entirely. This is a subtle thing that has come to bite my ass several times. It will simply log an error on the following form:
some_qbs_file.qbs:19: warning: Property 'configure' is not declared.
some_qbs_file.qbs:15: warning: Error while handling product 'libcombined':
:-1: warning: toPrimitive
some_qbs_file.qbs:15: warning: Product 'libcombined' had errors and was disabled.
Please note that if you have warnings disabled for the issues window in QtCreator, you will NOT learn about this!
I have submitted a bug report about this.
How to effectively debug your Qbs markup
Qbs markup is based on the QML declarative language invented by Qt. It can sometimes be confusing for beginners, because while it is declarative, it also supports javascript.
This exactly what we use to our advantage when trying to debug Qbs. Let me present an example:
StaticLibrary {
property string someVar: "lorem ipsum"
property bool debug_output: {
console.info("my static lib was here:");
console.info(" + someVar '" + someVar + "'");
return false;
}
//...
console.log() is not the same as console.info() !
If you are familiar with JavaScript at all, you are probably used to console.log() for logging. In Qbs, console.log() will not output anything by default. Yes that is right. console.log() is "debug" output, and for some reason it is not output in QtCreator logs. To show output in the log in QtCreator you need to use console.info() instead. This has bit many of us in the ass.
What to do when Qbs Crashes
Some errors in your .qbs files may lead to Qbs crashing. You will see the following output in the issues window:
You will also typically see something similar to the following in General Messages:
LanguageClient qbs@/tmp/qbs-lsp-1342403 for project: Unexpectedly finished. Restarting in 5 seconds.
LanguageClient qbs@/tmp/qbs-lsp-1342403 for project: QLocalSocket::connectToServer: Invalid name
At this stage you have a few options:
- Abandon Qbs entirely
- Backtrack the changes to your Qbs files one by one until the crash goes away. Please note that Qbs is NOT restarted by QtCreator, so for every change you make, you will have to restart QtCreator!
- Submit a bug report (please upvote these: QBS-1817, QBS-1818, and QBS-1819)
- Fix the bugs in Qbs yourself (see below).
Contributing to Qbs
After Qbs fell from the grace of the Qt Company, it depends on the kind support of passionate personal contributors to stay alive. The project still has many users that love it and is still actively maintained, but it does not have the backing of a large company anymore.
This is open-source, so YOU are the contributor!
- If you would like to build Qbs from source, this is the official documentation.
- If you would like to have a go at contributing to Qbs, here are the official instructions.
No comments:
Post a Comment