native
A built-in module to support native rules and other package helper functions. All native rules appear as functions in this module, e.g.native.cc_library
. Note that the native module is only available in the loading phase (i.e. for macros, not for rule implementations). Attributes will ignore None
values, and treat them as if the attribute was unset.The following functions are also available:
existing_rule
unknown native.existing_rule(name)Returns a dictionary representing the attributes of a previously defined rule, or None if the rule does not exist.
Parameters
Parameter | Description |
---|---|
name
|
The name of the rule. |
existing_rules
dict native.existing_rules()Returns a dict containing all the rules instantiated so far. The map key is the name of the rule. The map value is equivalent to the existing_rule output for that rule.
exports_files
None native.exports_files(srcs, visibility=None, licenses=None)Specifies a list of files belonging to this package that are exported to other packages but not otherwise mentioned.
Parameters
Parameter | Description |
---|---|
srcs
|
The list of files to export. |
visibility
|
A visibility declaration can to be specified. The files will be visible to the targets specified. If no visibility is specified, the files will be visible to every package. |
licenses
|
Licenses to be specified. |
glob
sequence native.glob(include=[], exclude=[], exclude_directories=1)Glob returns a list of every file in the current package that:
- Matches at least one pattern in
include
. - Does not match any of the patterns in
exclude
(default[]
).
exclude_directories
argument is enabled (set to 1
), files of type directory will be omitted from the results (default 1
).
Parameters
Parameter | Description |
---|---|
include
|
The list of glob patterns to include. |
exclude
|
The list of glob patterns to exclude. |
exclude_directories
|
A flag whether to exclude directories or not. |
package_group
None native.package_group(name, packages=[], includes=[])This function defines a set of packages and assigns a label to the group. The label can be referenced in
visibility
attributes.
Parameters
Parameter | Description |
---|---|
name
|
The unique name for this rule. |
packages
|
A complete enumeration of packages in this group. |
includes
|
Other package groups that are included in this one. |
package_name
string native.package_name()The name of the package being evaluated. For example, in the BUILD file
some/package/BUILD
, its value will be some/package
. If the BUILD file calls a function defined in a .bzl file, package_name()
will match the caller BUILD file package. This function is equivalent to the deprecated variable PACKAGE_NAME
.
repository_name
string native.repository_name()The name of the repository the rule or build extension is called from. For example, in packages that are called into existence by the WORKSPACE stanza
local_repository(name='local', path=...)
it will be set to @local
. In packages in the main repository, it will be set to @
. This function is equivalent to the deprecated variable REPOSITORY_NAME
.