1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
|
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qbs.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\previouspage FileTagger
\nextpage JobLimit
\qmltype Group
\inqmlmodule QbsLanguageItems
\ingroup list-of-items
\keyword QML.Group
\brief Groups files and other items in a product or module.
This item is attached to a \l{Product}{product} or \l{Module}{module} and used to group files
and other items that have something in common.
\section1 Typical Uses of Groups by Example
\code
Application {
Group {
name: "common files"
files: ["myclass.h", "myclass_common_impl.cpp"]
}
Group {
name: "Windows files"
condition: qbs.targetOS.includes("windows")
files: "myclass_win_impl.cpp"
}
Group {
name: "Unix files"
condition: qbs.targetOS.includes("unix")
files: "unixhelper.cpp"
Group {
name: "Linux files"
condition: qbs.targetOS.includes("linux")
files: "myclass_linux_impl.cpp"
}
Group {
name: "FreeBSD files"
condition: qbs.targetOS.includes("freebsd")
files: "myclass_freebsd_impl.cpp"
}
}
Group {
name: "Files to install"
qbs.install: true
qbs.installDir: "share"
files: "runtime_resource.txt"
}
}
\endcode
\section1 Wildcards
When specifying files, you can use the wildcards \c "*", \c "?" and \c "[]", which
have their
\l{https://en.wikipedia.org/wiki/Wildcard_character#File_and_directory_patterns}{usual meaning}
as in Unix Shell. By default, matching files are only picked up directly from the
parent directory, but you can tell \QBS to consider the whole directory tree.
It is also possible to exclude certain files from the list.
The pattern \c "**" used in a pathname expansion context will match all files and zero or more
directories and subdirectories.
For example:
\snippet reference/items/language/group.qbs 0
\section1 Attaching Module Properties to Source Files
Within a \c Group item, module properties can be attached either to all files in the
product, or to only the files in that group. The following example demonstrates both:
\code
Product {
// ...
Group {
condition: project.hasSpecialFeature
cpp.defines: "FEATURE_SPECIFIC"
product.cpp.defines: "WITH_FEATURE"
files: "feature.cpp"
}
}
\endcode
Here, the macro \c "FEATURE_SPECIFIC" will only be visible inside \c feature.cpp, whereas
\c "WITH_FEATURE" applies to all source files in the product.
A group-level property binding starting with \c "product." is semantically equivalent
to putting the same property binding without that prefix inside a top-level \l Properties item
with the same condition as the group. The above example could therefore also have been written
like this:
\code
Product {
// ...
Group {
condition: project.hasSpecialFeature
cpp.defines: "FEATURE_SPECIFIC"
files: "feature.cpp"
}
Properties {
condition: project.hasSpecialFeature
cpp.defines: "WITH_FEATURE"
}
}
\endcode
Obviously, the original variant is to be preferred, as it does not duplicate the condition
and keeps related code close together.
It should be noted that there is a third way to write the same example, with a \l Properties
item inside the group:
\code
Product {
// ...
Group {
condition: project.hasSpecialFeature
cpp.defines: "FEATURE_SPECIFIC"
files: "feature.cpp"
Properties {
cpp.defines: "WITH_FEATURE"
}
}
}
\endcode
This construct just adds verbosity here, but might be useful in cases where the product-level
property binding is dependent on an additional condition.
\section1 Attaching Module Properties to Generated Files
A group can also be used to attach properties to build artifacts such as executables or
libraries. In the following example, an application is installed to "<install root>/bin".
\code
Application {
Group {
fileTagsFilter: "application"
qbs.install: true
qbs.installDir: "bin"
}
}
\endcode
\section1 Groups in Modules
Groups may also appear in \l{Module}{modules}, which causes the respective
sources to be added to the products depending on the said module, unless
the \l{filesAreTargets} property is set.
\section1 Grouping Related Items
Groups can contain other items, namely \l Depends, \l FileTagger, \l Rule and \l Scanner items.
They can also contain other groups, that is, they can be nested. The \l{condition} of
a groups's child item gets logically ANDed with the one of the parent group. Additionally,
if the child item is a group itself, the child group inherits the module properties and
\l{FileTagger}{file tags} as well as the prefix of its parent group.
*/
/*!
\qmlproperty string Group::name
The name of the group. Not used internally; mainly useful for IDEs.
\defaultvalue "Group x", where x is a unique number among all the
groups in the product.
*/
/*!
\qmlproperty pathList Group::files
The files in the group. Mutually exclusive with \l{fileTagsFilter}.
Relative paths are resolved using the parent directory of the file
that contains the Group item. However, if the \l{prefix} property is set to
an absolute path, then that one becomes the base directory.
The values can contain wildcards.
\defaultvalue An empty list
*/
/*!
\qmlproperty bool Group::filesAreTargets
If this property is \c true and the group is in a \l{Module}, the files in the
group will not become source artifacts of the product that depends on the module.
Instead, they are treated like target artifacts of products. That is, they will be
matched against the \l{Rule::inputsFromDependencies}{inputsFromDependencies}
file tag list of \l{Rule}{rules} in products that depend on the module.
\defaultvalue \c false
*/
/*!
\qmlproperty string Group::prefix
A string to prepend to all files. Slashes are allowed and have directory
semantics.
\defaultvalue The prefix of the parent group if one exists, otherwise empty.
*/
/*!
\qmlproperty stringList Group::fileTagsFilter
List of \l{Artifact::fileTags}{artifact.fileTags} to match. Any properties
set in this group will be applied to the product's artifacts whose file tags
match the ones listed here.
The file tags that the group's \l{fileTags} property specifies will
be added to the matching artifacts.
This property is mutually exclusive with \l{files}.
\defaultvalue An empty list
*/
/*!
\qmlproperty bool Group::condition
Determines whether the files in the group are actually considered part of
the project.
\defaultvalue \c true
*/
/*!
\qmlproperty stringList Group::fileTags
A list of file tags to attach to the group's files. These can then be
matched by a \l{Rule}{rule}.
\note \l{FileTagger}{File taggers} are never applied to a file that has this
property set.
\defaultvalue An empty list
*/
/*!
\qmlproperty bool Group::overrideTags
Determines how tags on files that are listed both at the top level of
a product (or the parent group, if there is one) and a group are handled.
If this property is \c true, then the \l{FileTagger}{file tags} set via the
group replace the ones set via the product or parent group.
If it is \c false, the \e {group tags} are added to the \e {parent tags}.
This property is ignored if \l{fileTagsFilter} is set.
\defaultvalue \c true
*/
/*!
\qmlproperty pathList Group::excludeFiles
A list of files that are \e subtracted from the \l{files} list.
The values can contain wildcards.
This property is ignored if \l{fileTagsFilter} is set.
\defaultvalue An empty list
*/
|