Coder Social home page Coder Social logo

qmlc's Introduction

Qml Compiler
------------

The Qml Compiler can be used to convert Qml source code files into
precompiled Qml files. The precompiled Qml files are faster to load
and do not expose the source code. Normally, the Qt either compiles
the Qml files in the startup or interprets the Qml files runtime.

The Qml uses the JIT compiler shipped with Qt to create precompiled
files. It works thus in same way, as Qt when it is using JIT. Only
that the JIT compilation step is performed already when the program
launches. The loader is used to load precompiled files and link
them into the Qml Engine.

The compiler is created by creating a new version of the Qml
compilation framework, that is builtin in the Qt. The class
QQmlTypeCompiler, that is the core class handling the compilation,
is taken as a base for the compiler. Some of its dependencies
are exported on the Qt, some of the dependencies are rewritten, due
to need for modifications.

The compiler, loader and examples are all based on Qt source code.
They are licensed under LGPL 2.1 (with Digia Qt LGPL exception 1.1)
or BSD license. See source code files for license. Collectively this
component can be used under terms of LGPL 2.1 with Digia Qt LGPL
exception 1.1. See LICENSE.LGPL and LGPL_EXCEPTION.txt for details.


Known limitations
-----------------

There are few limitations with the compiler. The compiler requires
a modified version of the Qt. The modifications are available in the
qtdeclarative repository. Other than that, the target is to
remove these limitations. There might be also a way to no require
modified Qt. The reason for the other limitations is the lack of
implementation.

- It is not possible to mix precompiled and source Qml files
- It is not possible to load Qml from network
- Few structures are still unsupported, for example composite
  singleton
- The test cases are still not very comphrehensive

List of current issues can be found at:
https://github.com/qmlc/qmlc/issues


Using Qml Compiler
------------------

The Qml compiler can be used from command line:

This command will read the Qml file and produce a precompiled qml file.
The produced file is named file.qmc.

 qmc file.qml

The Qml program needs slight modifications.

After creating the QQuickView, the precompiled components need to be loaded:

    QQmlEngine *engine = view.engine();
    QQmlEnginePrivate::get(engine)->v4engine()->iselFactory.reset(new QV4::JIT::ISelFactory);
    QmcLoader loader(engine);
    QQmlComponent *component = loader.loadComponent(":/file.qmc");
    QObject *rootObject = component->create();
    view.setContent(component->url(), component, rootObject);

There is an example in the examples/objectlistmodel how to use the
compiler.

How to run modified Qt in your development machine:
---------------------------------------------------

1. Install Qt 5.3.1 with source code from here:
   http://qt-project.org/downloads

   Rest of the instructions assume that you installed it in /home/user/Qt5.3.1
   If installed elsewhere, replace this path

2. Replace qtdeclarative module with modified

   cd /home/user/Qt5.3.1/5.3/Src/
   mv qtdeclarative qtdeclarative-bak
   git clone https://github.com/qmlc/qtdeclarative.git qtdeclarative
   cd qtdeclarative
   git checkout qmlc-5.3.1

3. Configure development build

   cd /home/user/Qt5.3.1/5.3/Src
   ./configure -developer-build -debug
   make
   make install

4. Configure Qt Kit in the Qt creator /home/user/Qt5.3.1/5.3/Src as directory

qmlc's People

Contributors

miksa avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.