Re: [Qbs] Conditionally adding a file tag

2020-07-29 Thread Alberto Mardegan
Hi Ulrich,

On 29/07/20 10:07, Jochen Ulrich wrote:
> I guess the issue here is that FileTaggers are disabled in this case:
> 
>> File taggers are disabled if file tags are set explicitly in a product or 
>> group.
>> For example, the "cpp" tag is not attached to the .cpp files in the 
>> following product
> (see https://doc.qt.io/qbs/qml-qbslanguageitems-filetagger.html#details)

It's not clear to me whether this applies to my case too: my group is
not specifying a file list, but it's using the fileTagsFilter to
populate itself. And in the fileTagsFilter documentation it's written (
https://doc.qt.io/qbs/qml-qbslanguageitems-group.html#fileTagsFilter-prop):

"The file tags that the group's fileTags property specifies will be
added to the matching artifacts."

which seems to be exactly my use-case.

> But normally, it is not a problem to set those tags via a Group when 
> organizing the Groups accordingly.
> For example you could have a dedicated Group for those resources. Something 
> like
> 
> Group {
> name: "Resources"
> fileTags: embedAsResource ? ["qt.core.resource_data"] : []
> qbs.install: !embedAsResource
> qbs.installDir: "share/" + project.relativePluginDir
> qbs.installSourceBase: "../"
> files: [
>   "file1.qml",
>   "file2.qml",
>   "file3..png",
>   "file4.gif",
>  ]
> }

Yes, this would work, but I'm writing a generic QBS item, that's why I
don't want to explicitly list the input files in there.

Ciao,
  Alberto


-- 
http://www.mardy.it - Geek in un lingua international
___
Qbs mailing list
Qbs@qt-project.org
https://lists.qt-project.org/listinfo/qbs


Re: [Qbs] Conditionally adding a file tag

2020-07-29 Thread Jochen Ulrich
Hi Alberto!

I guess the issue here is that FileTaggers are disabled in this case:

> File taggers are disabled if file tags are set explicitly in a product or 
> group.
> For example, the "cpp" tag is not attached to the .cpp files in the following 
> product
(see https://doc.qt.io/qbs/qml-qbslanguageitems-filetagger.html#details)

I don't know why the behavior is like this.
But it seems you need to decide to either set the tags via a Group or via a 
FileTagger.

But normally, it is not a problem to set those tags via a Group when organizing 
the Groups accordingly.
For example you could have a dedicated Group for those resources. Something like

Group {
name: "Resources"
fileTags: embedAsResource ? ["qt.core.resource_data"] : []
qbs.install: !embedAsResource
qbs.installDir: "share/" + project.relativePluginDir
qbs.installSourceBase: "../"
files: [
  "file1.qml",
  "file2.qml",
  "file3..png",
  "file4.gif",
 ]
}

Best 
Jochen Ulrich

___
Qbs mailing list
Qbs@qt-project.org
https://lists.qt-project.org/listinfo/qbs


[Qbs] Conditionally adding a file tag

2020-07-28 Thread Alberto Mardegan
Hi all!
  I have a Product consisting of static files (images, QML and JSON);
you can see the base item here:


https://gitlab.com/mardy/mappero/-/blob/fd935d58a55523bf7d6b281f2728f055704a2b26/qbs/imports/QmlPlugin.qbs

and a trivial QBS file in which it's used:


https://gitlab.com/mardy/mappero/-/blob/fd935d58a55523bf7d6b281f2728f055704a2b26/src/plugins/nominatim/plugin.qbs

It all works fine, the static files are installed in the filesystem in
the proper location.


Now, however, I'm building the Android version and I would like to embed
the same file as a resource, but only when building for Android. So,
I've changed the base item like this:

===
Product {
type: embedAsResource ? "staticlibrary" : "qmlplugin"

property bool embedAsResource: true   // logic is TODO

Depends { name: "Qt.core" }
...
FileTagger {

patterns: [ "*.png", "*.gif", "*.svg" ]

fileTags: "image"

}

FileTagger {
patterns: "*.qml"
fileTags: ["qml"]
}

Group {
fileTagsFilter: [ "qml", "image" ]
fileTags: embedAsResource ? ["qt.core.resource_data"] : []
qbs.install: !embedAsResource
qbs.installDir: "share/" + project.relativePluginDir
qbs.installSourceBase: "../"
}
===

That is, if the embedAsResource property is true (and it always is,
currently), the product should be a static library, and the
"qt.core.resource_data" tag should be added to the static files.

But the above does not work. It appears that the new tag is not being
added. It all works if I add it directly into the FileTagger items, but
I would rather avoid doing that, since I have several of them and adding
a conditional would make the QBS file harder to read.

So, in short, the question is this: why isn't it possible to use the
Group's fileTags property to add a tag in this case? Or am I doing
something else wrong here?

Ciao,
  Alberto

-- 
http://www.mardy.it - Geek in un lingua international
___
Qbs mailing list
Qbs@qt-project.org
https://lists.qt-project.org/listinfo/qbs