[Qbs] qm-file build as internal resource

Карелин Павел hkarel at yandex.ru
Tue Dec 12 12:26:31 CET 2017



12.12.2017 11:49, Christian Kandeler пишет:
> On Mon, 11 Dec 2017 19:58:27 +0300
> Карелин Павел <hkarel at yandex.ru> wrote:
>
>> I'm build a third-party project. The peculiarity of the project is that
>> qm-files are represented as internal resources.
>> Now I solved the problem with a terrible hack:
>> 1) Created the 'Translations' product
>> Product {
>>       name: "Translations"
>>       type: "qm"
>>       destinationDirectory: project.sourceDirectory + "/translations"
>>
>>       Depends { name: "Qt.core" }
>>       files: ["*.ts"]
>> }
>>
>> 2) The results of the work 'Translations' are located in the
>> project.sourceDirectory + "/translations" directory
>> 3) The main product made dependent on 'Translations'
>> Depends { name: "Translations" }
>>
>> 4) In the main product I cling the created qm-files through a qrc-resource
>>       Group {
>>           name: "translations"
>>           files: ["translations/translations.qrc"]
>>       }
>>
>> Is it possible to solve this task in another way?
>> qm-resources should be placed by the path ":translations/"
> You left out some details, so I have to take a guess. I assume you are listing the qm files "manually" in the qrc file, and that's what you want to get rid of?
> In that case, something like the following looks adequate:
>
> QtApplication { // Or whatever the main product is
>      Group {
>          name: "translations"
>          files: ["<translation dir>/*.ts"]
>      }
>      Group {
>          fileTagsFilter: ["qm"]
>          fileTags: ["qt.core.resource_data"]
>      }
>
>      // See doc.qt.io/qbs/qt-modules.html#core-properties
>      // for details.
>      Qt.core.resourceSourceBase: Qt.core.qmDir
>      Qt.core.resourcePrefix: "translations"
> }
>
> This should auto-generate the qrc file.
Christian, you were right in your guess. Indeed, the file 
translations.qrc is filled manually. Sorry that did not write about this 
at once. But unfortunately your recipe did not work. I see that qm-files 
are created in the assembly directory, but there is no resulting 
qrc-file. In addition, I have a couple more groups with resources. Will 
these groups be handled correctly?

     Group {
         name: "smileys"
         files: {
             var f = [];
             if (project.useSmileys === "yes")
                 f = ["smileys/emojione.qrc"];
             else if (project.useSmileys === "min")
                 f = ["smileys/smileys.qrc"];
             return f;
         }
     }

     Group {
         name: "resources"
         files: [
             "res.qrc",
         ]
     }


P.S. I can provide a link to the project on github, if that helps.

>
>
> Christian
> _______________________________________________
> Qbs mailing list
> Qbs at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qbs




More information about the Qbs mailing list