Ph: 80000000

Introducing qbs

Posted by Jörg on February 15, 2012 · 100 comments

Over the years we have developed a kind of a love-hate relationship towards qmake. It does its job but also has its quirks and is widely considered unmaintainable. The blog post [TMQB] contains a wish list for a qmake replacement. We have considered the various tools on the market, but none satisfied us – see for example [WNCM]. So some time ago we have initiated an internal project to try some of the ideas. This is the outcome of it: the Qt Build Suite, aka qbs (pronounced as “Cubes”).

It is not qmake

Unlike qmake, qbs is not tied to the Qt version, and it generates a proper build graph (dependency graph) from the high-level project description in the project file. Also, classical makefile generators like qmake and CMake create makefiles and leave the execution of the actual build commands to tools like make or ninja. Qbs on the other hand fills the role of a parallel make and directly calls the compiler, linker and other tools, pretty much like SCons and Ant do.

Declarative Language

The language of qbs is a simplified version of QML, providing an IDE-friendly representation of software projects. Still it provides the freedom of writing all kinds of JavaScript expressions on the right-hand-side of property bindings. A project file editor could know how to edit file lists that are pure string array literals. For more complicated constructs it would fall back to opening the project file in a text editor.

files: ["foo.h", "foo.cpp", "main.cpp"]              // editable from IDE
files: generateFileList().concat(['extra.cpp'])      // only editable in your text editor

For most use cases it should be possible to write IDE-friendly project files. But if you need more power, you are free to unleash all your l33t JavaScript skillz.

Now let’s have a look at the obligatory “Hello World” example:

// helloworld.qbp
import qbs.base 1.0

CppApplication {
     name: "HelloWorld"
     files: "main.cpp"
}

The import statement enables us to use items like “Application”. We are giving our application the name “HelloWorld” and adding a C++ source file to it.

A thorough walk-through of the language can be found in the documentation under “language introduction”.

Extensible

Dealing with code generators or resource compilers is something you really want to avoid in qmake. In qbs you can easily write rules to transform files of a certain type to files of another type. One can either call processes that do the transformation externally (e.g., rcc) or directly execute the transformation in JavaScript. This simplified example demonstrates how to turn the .pluginspec.in files of the Qt Creator source tree to .pluginspec files.

Rule {
    ...
    prepare: {
        var cmd = new JavaScriptCommand();
        cmd.description = "generating " + FileInfo.fileName(output.fileName);
        cmd.qtcreator_version = product.module.qtcreator_version;
        cmd.sourceCode = function() {
            var inf = new TextFile(input.fileName);
            var all = inf.readAll();
            all = all.replace(new RegExp('\\\$\\\$QTCREATOR_VERSION(?!\w)', 'g'), qtcreator_version);
            var file = new TextFile(output.fileName, TextFile.WriteOnly);
            file.write(all);
            file.close();
        }
        return cmd;
    }
}

Fast incremental builds

Qbs sees the project as whole and thus does not need to fork itself for subdirectories. Even if only a part of the project is built, the whole build graph is taken into consideration. The problems of recursive make (see [RMCH]) are no more.

This also has the consequence that incremental builds are much faster than with make. I have modified the benchmark generator script from [QPBS] and added qbs support. The following results were obtained from incremental builds of a project with 200 libraries, 50 classes per library, 30 lib-internal includes per file and 10 lib-external includes per file.

On my machine, doing an incremental build without any changed files with make takes

real 0m4.076s
user 0m2.556s
sys 0m1.952s

doing the same with qbs

real 0m0.843s
user 0m0.724s
sys 0m0.112s

Build Instructions

Enough talk. Where do I get it? How to build it?


git clone git://gitorious.org/qt-labs/qbs.git
cd qbs
qmake -r qbs.pro
make
make docs

Please read the docs, esp. the part “configuring qbs”. You can find them online here. Then you can start playing around with the example projects in qbs/tests/manual. If you are more in search of a real-world project, you can find qbs project files for Qt Creator right here.

The project is open for contributions. Please see “Setting up Gerrit” on the Qt Project’s wiki for instructions. The URL of the gerrit remote is <Gerrit/Jira username>@codereview.qt-project.org:qt-labs/qbs.
The project’s mailinglist can be found at http://lists.qt-project.org/mailman/listinfo/qbs

Outlook

The state of this project is experimental. It is meant as a playground for different build tool concepts. Qmake will still be around for a long time, and nobody will force you to use qbs or any other build tool – though of course we will probably try to push qbs for Qt’s own build system at some point.

Users of common meta build tools like CMake or the GNU Autotools may have noticed that a crucial part is missing if qbs is meant to seriously compete in the cross-platform build tool market: adapting to the host environment, aka configure checks. For the time being it is still necessary to use an external configure script to generate a JSON file for qbs’ use, but that is of course not meant to be the long-term solution. The idea is to make configure tests usable like other modules. Their implementation will of course not be purely declarative, but will contain some JavaScript code.

There is plenty to do! For a non-exhaustive list of ideas, see our issue tracker (once our admins configure public access to the product).

References

[RMCH] Peter Miller (1998), “Recursive Make Considered Harmful”, AUUGN Journal of AUUG Inc., 19(1), pp. 14-25
[TMQB] Marius Storm-Olsen (2009), “To make, or not to make – QMake and beyond”, http://labs.qt.nokia.com/2009/10/12/to-make-or-not-to-make-qmake-and-beyond/
[WNCM] http://lists.qt.nokia.com/pipermail/qt5-feedback/2011-June/000494.html
[QPBS] Noel Llopis (2005), “The Quest for the Perfect Build System”, http://gamesfromwithin.com/the-quest-for-the-perfect-build-system

100 comments


QML Profiler update

Posted by Christiaan Janssen on February 7, 2012 · 11 comments

Hello!

We have been improving the QML Profiler over the last months, with a special focus on the user interface. With the latest features we want to make it easier to navigate the time line, locate points of interest, and manage the statistics effectively to gain some insight into your own application. Among the new features there is ability to load and save traces to disk, so they can be shared among developers or revisited during the development of a project. There is also information about the running animations in the timeline, that is, frames per second and number of concurrent animations playing. And we also integrated the V8 profiler, with its output displayed in a separate tab. This last one, though, is only available if your application runs with Qt5, since this is the first version of Qt that uses the V8 JavaScript engine.

Here is a short video going through some of the new features. I want to apologize in advance for the poor frame rate of the video, since it was taken from my laptop and somehow the video grabber couldn’t manage a higher rate. Since I can’t find how to embed it in here with its original size, consider playing it fullscreen.

I hope the video encourages you to test the QML profiler and use it for your own applications. Feel free to give us any feedback about the current profiler, for example suggesting new features that would be helpful for you.

In the coming days we are going to blog about some other QML tools we have been working on recently, stay tuned.

For feedback/questions, please contact us on IRC at the freenode server, channel #qt-creator.

11 comments


Qt Graphical Effects in Qt Labs

Posted by Sami Lehtonen on February 2, 2012 · 40 comments

Introduction

The Qt Graphical Effects project is on its way to offer a set of design neutral visual effects for Qt Quick 2.0.

Over twenty ready-made QML graphical effect elements are currently available. The effects include code for blending, masking, blurring, coloring, and much more. There are still areas to improve and extend — all ideas, feedback, proposals and even concrete contributions are welcome!

The Effects

The Effects

Using the effects

Using the graphical effect elements should be straightforward for developers and technically oriented designers as you only need to know basic Qt Quick/QML to get started.

Any QML item can be used as a source item for an effect. You can add a drop shadow to an image, for instance, as follows:

import QtQuick 2.0
import QtGraphicalEffects 1.0

Item {
    width: 300
    height: 300

    Rectangle {
        id: background
        anchors.fill: parent
    }

    Image {
        id: butterfly
        source: "images/butterfly.png"
        sourceSize: Qt.size(parent.width, parent.height)
        smooth: true
        visible: false
    }

    DropShadow {
        anchors.fill: butterfly
        horizontalOffset: 3
        verticalOffset: 3
        radius: 8.0
        samples: 16
        color: "#80000000"
        source: butterfly
    }
}

Getting started

Get and build Qt5: http://developer.qt.nokia.com/wiki/Building_Qt_5_from_Git

Make sure that qtbase/bin is in your path and QTDIR points to /qtbase

Get and build Qt Graphical Effects module: https://qt.gitorious.org/qt-labs/qtgraphicaleffects

git clone git@gitorious.org:qt-labs/qtgraphicaleffects.git
cd qtgraphicaleffects
qmake
make install

To see the effects in action, run the code examples from the graphical effects doc/src/snippets folder:

qmlscene doc/src/snippets/DropShadow-example.qml

or launch the Testbed application:

qmlscene tests/manual/testbed/testBed.qml

The Testbed application is a convenient way to browse the effects and their properties as well as to visualise the results. Select an effect from the left, adjust its properties on the right, and see the result in the center in realtime:

API and documentation

The API for each effect is a set of QML properties. The effect properties can be animated just like any other QML properties. The documention contains property descriptions and basic usage examples. To generate the documentation, execute the following commands in the qtgraphicaleffects projects folder:

qmake
make docs

Open the generated doc/html/qml-graphicaleffects-index.html in a browser to view the documentation.

documentation

Implementation details

QML ShaderEffect is a built-in element in Qt Quick 2.0. This powerful QML element allows combining OpenGL Shading Language (GLSL) and QML, and makes it easy to implement visually impressive custom effects. Under the hood, all the effects in this project are based on ShaderEffect elements. Only QML and GLSL have been used, and there are no additional C++ APIs. If you are familiar with GLSL, you can easily study how the existing effects have been implemented. You can then create custom effects by modifying and combining the basic effects.

Links to related blog posts and specifications

 

40 comments


Qt SDK 1.2 Released

Posted by Hannu Honkala on February 1, 2012 · 40 comments

We are happy to announce that a new important update for Qt SDK is published.
This Qt SDK 1.2 update sets a new baseline for the developers for a longer perspective. Some of the features have already been available as online updates, but Qt SDK 1.2 now integrates the very latest tools, most recent mobile build targets for Symbian and Nokia N9, and the still fresh Qt 4.8 for desktops. We have also introduced some improvements to the SDK and its maintenance tool.

As a summary, this is what is new in the Qt SDK:

    Fixes for Qt Creator 2.4 in a new 2.4.1 patch update     Qt 4.8 for desktops delivering Qt Quick 1.1, Qt platform abstraction, Qt WebKit 2.2, and threaded OpenGL. See Sinan’s blog post for more details.     More Qt Mobility examples for Nokia N9 and Symbian devices     Ability to specify network proxy setting in the SDK Maintenance Tool     Update to the Symbian Complementary Package introducing Analyze Tool plugin and new CODA 1.0.6 installation package     An update to Notifications API improving the end user experience and fixing issues in the Nokia N9 implementation of the API.

If you already have Qt SDK installed, you can update to the latest version by running Update Qt SDK from the Qt SDK application folder on your computer. If you first time are getting started with Qt SDK, you can download 1.2 from our download page.

If you encounter problems, please file a bug report at http://bugreports.qt-project.org.

QShare(this)

40 comments


Qt Creator 2.4.1 released

Posted by Eike Ziller on February 1, 2012 · 3 comments

Today we publish a patch release of Qt Creator 2.4, that is also included in a bigger Qt SDK 1.2 update.

Qt Creator 2.4.1 contains no new features, but fixes a few issues, most notably

finding the QMLViewer.app on case sensitive Mac file systems building debugging helpers for universal builds, and tool chain / mkspec setting in some configurations (Mac) automatic proxy detection on Windows systems

Also see the 2.4.1 change log.

Get the new version from our download page, or through the updated SDK here.

3 comments


Raspberry PI: A case study in deploying Qt apps to generic Linux devices

Posted by dcarr on January 19, 2012

Overview This is an awfully dry post; dry due to the sheer logistic nature of it. This functionality exists and is quite straight forwards to stumble upon. This blog exists in order to draw your attention to it and hopefully minimize the stumble time. You have a device: 1) Running an ssh server 2) With [...]

13 comments Read the full article →

Qt 4 moved to open governance

Posted by Lars Knoll on January 10, 2012

Since we released Qt under open governance on qt-project.org, there was always one piece missing. The Qt 4 repository was so far still handled in the old system. This was done as a simple prioritization, to get the parts of Qt that we considered most relevant for the development community out first. The main problem [...]

8 comments Read the full article →

Qt 5 – A look back at the numbers

Posted by Marius Storm-Olsen on December 22, 2011

Marius Storm-Olsen is Head of Qt OSS in Nokia, and responsible for the operational side of the Qt Project. The Qt OSS team consists of 5 Sr. SW engineers who are exclusively dedicated to the Qt Project (although there are many more Nokia contributors than just those 5), and  focusing on working with the community on [...]

17 comments Read the full article →

The show must go on! Qt experts are talking and showing (again)!

Posted by Vladimir Minenko on December 21, 2011

It seems to be almost a tradition that shortly before Christmas, I post this message… “Qt Developer Days videos are online! Many treasures are inside”. This year is different in many ways… First, we used modern, broadcast grade video equipment and the content is in 720p HD format. All this means a much better video [...]

15 comments Read the full article →

Qt VS Add-in 1.1.10 released

Posted by Jörg on December 19, 2011

Together with Qt 4.8.0 we’ve released version 1.1.10 of the Qt Visual Studio Add-in. This release contains multiple bugfixes and improvements. The full changelog is available here. You can get it here: http://qt.nokia.com/downloads/visual-studio-add-in If you find bugs, please report them in our bug tracker: https://bugreports.qt.nokia.com/ Note: Qt VS Add-in 1.1.10 will be the last release [...]

22 comments Read the full article →

Qt 4.8.0 Released

Posted by Sinan Tanilkan on December 15, 2011

Qt has reached another important evolutionary milestone today. We are very proud to announce that Qt 4.8.0 has now been released. Many people have worked long and hard to deliver Qt 4.8.0. Today that hard work reaches final release maturity, and we are celebrating! Featuring Qt Platform Abstraction, threaded OpenGL support, multithreaded HTTP and optimized [...]

101 comments Read the full article →

New guides for those who are learning Qt Quick or Qt Quick Components on Symbian and N9

Posted by Vladimir Minenko on December 13, 2011

A post about new developer guides has been on the on the Qt Blog for a few weeks. We’ve made a small, but interesting update and we thought we should drop some lines about it. Just a few weeks ago we published two new developer guides. They are targeted toward those just starting out with [...]

21 comments Read the full article →


You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser