You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: reference/be/common-definitions.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,7 +59,7 @@ but not all.
59
59
60
60
| Attribute | Description |
61
61
| --- | --- |
62
-
| `data` | List of [labels](/concepts/labels); default is `[]` Files needed by this rule at runtime. May list file or rule targets. Generally allows any target. The `runfiles` of targets in the `data` attribute appear in the `*.runfiles` area of any executable which is output by or has a runtime dependency on this target. This may include data files or binaries used when this target's [`srcs`](#typical.srcs) are executed. Typically, this includes the targets' default outputs and their transitive runfiles, but this depends on the implementation of the rules for those targets; most rules include their default outputs in their `runfiles`. See the [data dependencies](/concepts/dependencies#data-dependencies) section for more information about how to depend on and use data files. New rules should define a `data` attribute if they process inputs which might use other inputs at runtime. Rules' implementation functions must also [populate the target's runfiles](https://bazel.build/rules/rules#runfiles) from the outputs and runfiles of any `data` attribute, as well as runfiles from any dependency attribute which provides either source code or runtime dependencies. |
62
+
|`data`| List of [labels](/concepts/labels); default is `[]` Files needed by this rule at runtime. May list file or rule targets. Generally allows any target. The default outputs and runfiles of targets in the `data` attribute should appear in the `*.runfiles` area of any executable which is output by or has a runtime dependency on this target. This may include data files or binaries used when this target's [`srcs`](#typical.srcs) are executed. See the [data dependencies](/concepts/dependencies#data-dependencies) section for more information about how to depend on and use data files. New rules should define a `data` attribute if they process inputs which might use other inputs at runtime. Rules' implementation functions must also [populate the target's runfiles](https://bazel.build/rules/rules#runfiles) from the outputs and runfiles of any `data` attribute, as well as runfiles from any dependency attribute which provides either source code or runtime dependencies. |
63
63
| `deps` | List of [labels](/concepts/labels); default is `[]` Dependencies for this target. Generally should only list rule targets. (Though some rules permit files to be listed directly in `deps`, this should be avoided when possible.) Language-specific rules generally limit the listed targets to those with specific [providers](https://bazel.build/extending/rules#providers). The precise semantics of what it means for a target to depend on another using `deps` are specific to the kind of rule, and the rule-specific documentation goes into more detail. For rules which process source code, `deps` generally specifies code dependencies used by the code in [`srcs`](#typical.srcs). Most often, a `deps` dependency is used to allow one module to use symbols defined in another module written in the same programming language and separately compiled. Cross-language dependencies are also permitted in many cases: For example, a `java_library` target may depend on C++ code in a `cc_library` target, by listing the latter in the `deps` attribute. See the definition of [dependencies](/concepts/build-ref#deps) for more information. |
64
64
|`licenses`| List of strings; [nonconfigurable](#configurable-attributes); default is `["none"]` A list of license-type strings to be used for this particular target. This is part of a deprecated licensing API that Bazel no longer uses. Don't use this. |
65
65
|`srcs`| List of [labels](/concepts/labels); default is `[]` Files processed or included by this rule. Generally lists files directly, but may list rule targets (like `filegroup` or `genrule`) to include their default outputs. Language-specific rules often require that the listed files have particular file extensions. |
Copy file name to clipboardExpand all lines: rules/lib/builtins/bazel_module_tags.mdx
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,4 +4,6 @@ title: 'bazel_module_tags'
4
4
5
5
Contains the tags in a module for the module extension currently being processed. This object has a field for each tag class of the extension, and the value of the field is a list containing an object for each tag instance. This "tag instance" object in turn has a field for each attribute of the tag class.
6
6
7
+
Tag instance objects have a `_sort_key` field that returns an opaque value that can be compared with other sort keys to determine the relative order of tags, even across tag classes. Tags are ordered by their position within a module file and by the BFS ordering of modules in the dependency graph. This can be used with `sorted()` to recover the original order of tags: `sorted(tags, key=lambda tag: tag._sort_key)`.
8
+
7
9
When passed as positional arguments to `print()` or `fail()`, tag instance objects turn into a meaningful string representation of the form "'install' tag at /home/user/workspace/MODULE.bazel:3:4". This can be used to construct error messages that point to the location of the tag in the module file, e.g. `fail("Conflict between", tag1, "and", tag2)`.
Downloads a file to the output path for the provided url, extracts it, and returns a struct containing `success`, a flag which is `true` if the download completed successfully, and if successful, a hash of the file with the fields `sha256` and `integrity`. If the value of the `success` field is false, the `error` field will be set with a message indicating why the download failed. The message in the `error` field is for debugging purposes only and should not be relied upon as a stable API (the format of the string can change between patch versions of Bazel). When `sha256` or `integrity` is user specified, setting an explicit `canonical_id` is highly recommended. e.g. [`get_default_canonical_id`](/rules/lib/repo/cache#get_default_canonical_id)
@@ -64,14 +63,13 @@ Downloads a file to the output path for the provided url, extracts it, and retur
64
63
|`output`|[string](../core/string); or [Label](../builtins/Label); or [path](../builtins/path); default is `''` Path to the directory where the archive will be unpacked, relative to the repository directory. |
65
64
|`sha256`|[string](../core/string); default is `''` The expected SHA-256 hash of the file downloaded. This must match the SHA-256 hash of the file downloaded. It is a security risk to omit the SHA-256 as remote files can change. At best omitting this field will make your build non-hermetic. It is optional to make development easier but should be set before shipping. If provided, the repository cache will first be checked for a file with the given hash; a download will only be attempted if the file was not found in the cache. After a successful download, the file will be added to the cache. |
66
65
|`type`|[string](../core/string); default is `''` The archive type of the downloaded file. By default, the archive type is determined from the file extension of the URL. If the file has no extension, you can explicitly specify either "zip", "jar", "war", "aar", "nupkg", "whl", "tar", "tar.gz", "tgz", "gz", "tar.xz", "txz", "xz", "tar.zst", "tzst", "zst", "tar.bz2", "tbz", "bz2", "ar", "deb", "7z", "tar.br" or "br" here. |
67
-
|`strip_prefix`|[string](../core/string); default is `''` A directory prefix to strip from the extracted files. Many archives contain a top-level directory that contains all files in the archive. Instead of needing to specify this prefix over and over in the `build_file`, this field can be used to strip it from extracted files. For compatibility, this parameter may also be used under the deprecated name `stripPrefix`. Only one of `strip_prefix` or `strip_components` can be used. |
66
+
|`strip_prefix`|[string](../core/string); default is `''` A directory prefix to strip from the extracted files. Many archives contain a top-level directory that contains all files in the archive. Instead of needing to specify this prefix over and over in the `build_file`, this field can be used to strip it from extracted files. For compatibility, this parameter may also be used under the deprecated name `stripPrefix`. |
68
67
|`allow_fail`|[bool](../core/bool); default is `False` If set, indicate the error in the return value instead of raising an error for failed downloads. |
69
68
|`canonical_id`|[string](../core/string); default is `''` If set, restrict cache hits to those cases where the file was added to the cache with the same canonical id. By default caching uses the checksum (`sha256` or `integrity`). |
70
69
|`auth`|[dict](../core/dict); default is `{}` An optional dict specifying authentication information for some of the URLs. |
71
70
|`headers`|[dict](../core/dict); default is `{}` An optional dict specifying http headers for all URLs. |
72
71
|`integrity`|[string](../core/string); default is `''` Expected checksum of the file downloaded, in Subresource Integrity format. This must match the checksum of the file downloaded. It is a security risk to omit the checksum as remote files can change. At best omitting this field will make your build non-hermetic. It is optional to make development easier but should be set before shipping. If provided, the repository cache will first be checked for a file with the given checksum; a download will only be attempted if the file was not found in the cache. After a successful download, the file will be added to the cache. |
73
72
|`rename_files`|[dict](../core/dict); default is `{}` An optional dict specifying files to rename during the extraction. Archive entries with names exactly matching a key will be renamed to the value, prior to any directory prefix adjustment. This can be used to extract archives that contain non-Unicode filenames, or which have files that would extract to the same path on case-insensitive filesystems. |
74
-
|`strip_components`|[int](../core/int); default is `0` Strip the given number of leading components from file paths on extraction. Only one of `strip_components` or `strip_prefix` can be used. |
75
73
76
74
## execute
77
75
@@ -111,7 +109,7 @@ Constructs an opaque object that can be returned from the module extension's imp
@@ -122,10 +120,9 @@ Extract an archive to the repository directory.
122
120
| --- | --- |
123
121
|`archive`|[string](../core/string); or [Label](../builtins/Label); or [path](../builtins/path); required path to the archive that will be unpacked, relative to the repository directory. |
124
122
|`output`|[string](../core/string); or [Label](../builtins/Label); or [path](../builtins/path); default is `''` path to the directory where the archive will be unpacked, relative to the repository directory. |
125
-
|`strip_prefix`|[string](../core/string); default is `''` a directory prefix to strip from the extracted files. Many archives contain a top-level directory that contains all files in the archive. Instead of needing to specify this prefix over and over in the `build_file`, this field can be used to strip it from extracted files. For compatibility, this parameter may also be used under the deprecated name `stripPrefix`. Only one of `strip_prefix` or `strip_components` can be set. |
123
+
|`strip_prefix`|[string](../core/string); default is `''` a directory prefix to strip from the extracted files. Many archives contain a top-level directory that contains all files in the archive. Instead of needing to specify this prefix over and over in the `build_file`, this field can be used to strip it from extracted files. For compatibility, this parameter may also be used under the deprecated name `stripPrefix`. |
126
124
|`rename_files`|[dict](../core/dict); default is `{}` An optional dict specifying files to rename during the extraction. Archive entries with names exactly matching a key will be renamed to the value, prior to any directory prefix adjustment. This can be used to extract archives that contain non-Unicode filenames, or which have files that would extract to the same path on case-insensitive filesystems. |
127
125
|`watch_archive`|[string](../core/string); default is `'auto'` whether to [watch](#watch) the archive file. Can be the string 'yes', 'no', or 'auto'. Passing 'yes' is equivalent to immediately invoking the [`watch()`](#watch) method; passing 'no' does not attempt to watch the file; passing 'auto' will only attempt to watch the file when it is legal to do so (see `watch()` docs for more information. |
128
-
|`strip_components`|[int](../core/int); default is `0` Strip the given number of leading components from file paths on extraction. Only one of `strip_components` or `strip_prefix` can be set. |
129
126
|`type`|[string](../core/string); default is `''` The archive type of the downloaded file. By default, the archive type is determined from the file extension of the URL. If the file has no extension, you can explicitly specify either "zip", "jar", "war", "aar", "nupkg", "whl", "tar", "tar.gz", "tgz", "gz", "tar.xz", "txz", "xz", "tar.zst", "tzst", "zst", "tar.bz2", "tbz", "bz2", "ar", "deb", "7z", "tar.br" or "br" here. |
Whether the root module uses this extension as a non-dev dependency.
261
258
262
-
## tag_sort_key
263
-
264
-
```
265
-
unknown module_ctx.tag_sort_key(tag)
266
-
```
267
-
268
-
Returns an opaque `sort_key` object for the given tag, which can be compared with other `sort_key` objects to determine the relative order of tags, even across tag classes. Tags are ordered by their position within a module file and by the BFS ordering of modules in the dependency graph. This can be used with `sorted()` to recover the original order of tags: `sorted(tags, key=lambda tag: module_ctx.tag_sort_key(tag))`
269
-
270
-
### Parameters
271
-
272
-
| Parameter | Description |
273
-
| --- | --- |
274
-
|`tag`| bazel_module_tag; required A tag obtained from [bazel_module.tags](../builtins/bazel_module#tags). |
0 commit comments