Documentation

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

string

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

sequence of strings

The list of files to export.

visibility

sequence

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

sequence of strings

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 []).
If the exclude_directories argument is enabled (set to 1), files of type directory will be omitted from the results (default 1).

Parameters

Parameter Description
include

sequence of strings

The list of glob patterns to include.

exclude

sequence of strings

The list of glob patterns to exclude.

exclude_directories

int

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

string

The unique name for this rule.

packages

sequence of strings

A complete enumeration of packages in this group.

includes

sequence of strings

Other package groups that are included in this one.