Re: [QBS] Qt Quick Compiler with QBS
On 12-Feb-15 16:20, Jicquel Dorian wrote: > I would like to know if it is possible to use the qt quick compiler with > qbs , i searched in the documentation that mentionned it could be used > qith qmake/cmake but no mention of qbs. Apparently nobody tried yet. I've created https://bugreports.qt.io/browse/QBS-749 to track this issue. Cheers, Joerg ___ QBS mailing list QBS@qt-project.org http://lists.qt-project.org/mailman/listinfo/qbs
Re: [QBS] Qt Quick Compiler with QBS
Hi Joerg, Many thanks for adding this feature request. Since QtQuickCompiler is a compiler which seems to work by transforming qml files into cpp files, perhaps it can be handled without any development in QBS but just by using Rules. qiquickcompiler.exe is a command line tool so it should be possible but since when using a pro file, everything is hidden on how it works, we do not have any idea on how to call it. Since we are commercial users, we may ask information to the QtCompany Support team on how call must be made. Do you think it can help? Regards Olivier Le 13/02/2015 10:23, Joerg Bornemann a écrit : > On 12-Feb-15 16:20, Jicquel Dorian wrote: > >> I would like to know if it is possible to use the qt quick compiler with >> qbs , i searched in the documentation that mentionned it could be used >> qith qmake/cmake but no mention of qbs. > Apparently nobody tried yet. I've created > https://bugreports.qt.io/browse/QBS-749 to track this issue. > > > Cheers, > > Joerg > ___ > QBS mailing list > QBS@qt-project.org > http://lists.qt-project.org/mailman/listinfo/qbs > ___ QBS mailing list QBS@qt-project.org http://lists.qt-project.org/mailman/listinfo/qbs
Re: [QBS] Qt Quick Compiler with QBS
On 13-Feb-15 13:15, olivier musse wrote: > Many thanks for adding this feature request. > Since QtQuickCompiler is a compiler which seems to work by transforming > qml files into cpp files, perhaps it can be handled without any > development in QBS but just by using Rules. > qiquickcompiler.exe is a command line tool so it should be possible but > since when using a pro file, everything is hidden on how it works, we do > not have any idea on how to call it. It's possible to add qtquickcompiler support without modifying qbs. But adding a rule is not enough. When you write CONFIG+=quickcompiler the following magic happens: All qrc files in RESOURCES are scanned. If foo.qrc contains .js or .qml files, then it is removed from RESOURCES and passed to the qtquickcompiler instead. If foo.qrc contains additionally files that are not .js or .qml, then those files are added to a newly generated .qrc file. So all QML .qrc files are passed to the qtquickcompiler, the non-QML .qrc files are passed to rcc. Additionally, loader code is generated (qtquickcompiler_loader.cpp). > Since we are commercial users, we may ask information to the QtCompany > Support team on how call must be made. Do you think it can help? I cannot make promises on behalf of our support team. But you can always ask them. :) BR, Joerg ___ QBS mailing list QBS@qt-project.org http://lists.qt-project.org/mailman/listinfo/qbs
Re: [QBS] Qt Quick Compiler with QBS
Hi Joerg, Thanks, it seems you know Qt Quick Compiler better than I ;o) So when do you think the magic part can be added to QBS ? Regards *Olivier MUSSE* */Mana-Sys SARL/* fixe : +33(0)2.90.89.43.10 mob : +33(0)6.84.14.20.33 Le 13/02/2015 14:21, Joerg Bornemann a écrit : On 13-Feb-15 13:15, olivier musse wrote: Many thanks for adding this feature request. Since QtQuickCompiler is a compiler which seems to work by transforming qml files into cpp files, perhaps it can be handled without any development in QBS but just by using Rules. qiquickcompiler.exe is a command line tool so it should be possible but since when using a pro file, everything is hidden on how it works, we do not have any idea on how to call it. It's possible to add qtquickcompiler support without modifying qbs. But adding a rule is not enough. When you write CONFIG+=quickcompiler the following magic happens: All qrc files in RESOURCES are scanned. If foo.qrc contains .js or .qml files, then it is removed from RESOURCES and passed to the qtquickcompiler instead. If foo.qrc contains additionally files that are not .js or .qml, then those files are added to a newly generated .qrc file. So all QML .qrc files are passed to the qtquickcompiler, the non-QML .qrc files are passed to rcc. Additionally, loader code is generated (qtquickcompiler_loader.cpp). Since we are commercial users, we may ask information to the QtCompany Support team on how call must be made. Do you think it can help? I cannot make promises on behalf of our support team. But you can always ask them. :) BR, Joerg ___ QBS mailing list QBS@qt-project.org http://lists.qt-project.org/mailman/listinfo/qbs
Re: [QBS] Qt Quick Compiler with QBS
On 13-Feb-15 15:01, olivier musse wrote: > Thanks, it seems you know Qt Quick Compiler better than I ;o) > So when do you think the magic part can be added to QBS ? I've added an example to QBS-749 that demonstrates how to use the qmlcompiler with qbs 1.3. The magic is done in CompiledQmlApp.qbs. The actual app project looks like this ---snip--- import qbs CompiledQmlApp { name: "MyApp" files: ["main.cpp"] qmlResourceFiles: ["qml.qrc"] } ---snap--- Build the project with qbs -f myapp.qbs and make sure that your Qt build has the QML compiler installed. BR, Joerg ___ QBS mailing list QBS@qt-project.org http://lists.qt-project.org/mailman/listinfo/qbs
Re: [QBS] Qt Quick Compiler with QBS
Hi Joerg, Thanks a lot for this work. We will test it as soon as possible dans give you a feedback on it. BR Olivier ** Le 19/02/2015 12:52, Joerg Bornemann a écrit : On 13-Feb-15 15:01, olivier musse wrote: Thanks, it seems you know Qt Quick Compiler better than I ;o) So when do you think the magic part can be added to QBS ? I've added an example to QBS-749 that demonstrates how to use the qmlcompiler with qbs 1.3. The magic is done in CompiledQmlApp.qbs. The actual app project looks like this ---snip--- import qbs CompiledQmlApp { name: "MyApp" files: ["main.cpp"] qmlResourceFiles: ["qml.qrc"] } ---snap--- Build the project with qbs -f myapp.qbs and make sure that your Qt build has the QML compiler installed. BR, Joerg ___ QBS mailing list QBS@qt-project.org http://lists.qt-project.org/mailman/listinfo/qbs
Re: [QBS] Qt Quick Compiler with QBS
Hi Joerg, This works like a charm. Thanks a lot for this great work, we add it as a module to our projects so that we only need to set a depends on this module. We needed to modify your qbs for it to works. At line 161 we wrote FileInfo.path(info.qrcFilePath)+"/"+qmlJsFile.input, If i can help, find enclosed our module. To use it we only need to write Depends{name:"quickCompiler"} and set qmlrc fileTags as you do on your sample. Many thanks again Olivier Hi Joerg, Thanks a lot for this work. We will test it as soon as possible dans give you a feedback on it. BR Olivier Le 19/02/2015 12:52, Joerg Bornemann a écrit : On 13-Feb-15 15:01, olivier musse wrote: Thanks, it seems you know Qt Quick Compiler better than I ;o) So when do you think the magic part can be added to QBS ? I've added an example to QBS-749 that demonstrates how to use the qmlcompiler with qbs 1.3. The magic is done in CompiledQmlApp.qbs. The actual app project looks like this ---snip--- import qbs CompiledQmlApp { name: "MyApp" files: ["main.cpp"] qmlResourceFiles: ["qml.qrc"] } ---snap--- Build the project with qbs -f myapp.qbs and make sure that your Qt build has the QML compiler installed. BR, Joerg ___ QBS mailing list QBS@qt-project.org http://lists.qt-project.org/mailman/listinfo/qbs import qbs import qbs.TextFile import qbs.FileInfo import qbs.Process Module { name:"qqc" Depends { name: "Qt.quick" } Depends { name: "Qt.core-private" } Depends { name: "Qt.qml-private" } Rule { inputs: ["qmlrc"] Artifact { filePath: input.fileName + ".json" fileTags: ["qmlrcinfo"] } prepare: { var cmd = new JavaScriptCommand(); cmd.description = "Starting quick compiler rule"; cmd.sourceCode = function() { var content = { qrcFilePath: input.filePath }; function qtQuickResourceFileOutputName(fileName) { return fileName.replace(/\.qrc/, "_qtquickcompiler.qrc"); } function qtQuickCompilerOutputName(fileName) { var str = fileName.replace('/', '_'); var i = str.lastIndexOf('.'); if (i != -1) str = str.substr(0, i) + '_' + str.substr(i + 1); str += ".cpp"; return str; } function scanQrc(input) { var absInputDir = FileInfo.path(input.filePath); var qmlJsFiles = []; var otherFiles = []; var process = new Process(); var exitCode = process.exec( product.moduleProperty("Qt.core", "binPath") + '/rcc', ["--list", input.filePath]); if (exitCode !== 0) throw Error("rcc failed with exit code " + exitCode); for (;;) { var line = process.readLine(); if (!line) break; line = line.trim(); line = FileInfo.relativePath(absInputDir, line); if ((/\.(js|qml)$/).test(line)) qmlJsFiles.push(line); else otherFiles.push(line); } if (otherFiles.length) { content.newQrcFilePath = qtQuickResourceFileOutputName(input.fileName) } content.qmlJsFiles = []; qmlJsFiles.forEach(function (f) { content.qmlJsFiles.push({ input: f, output: qtQuickCompilerOutputName(f) }); }); } scanQrc(input); var tf = new TextFile(output.filePath, TextFile.WriteOnly); tf.write(JSON.stringify(content)); tf.close(); } return cmd; } } Rule { inputs: ["qmlrcinfo"] outputFileTags: ["cpp", "qrc"] multiplex: true outputArtifacts: { var infos = []; inputs["qmlrcinfo"].forEach(function (input) { var tf = new TextFile(input.filePath, TextFile.ReadOnly); infos.push(JSON.parse(tf.readAll())); tf.close(); }); var result = []; infos.forEach(function (info) { if (info.newQrcFilePath) { result.push({ filePath: info.newQrcFilePath,