以下函数可以从 @bazel_tools//tools/build_defs/repo:utils.bzl
加载。
不确定
maybe(repo_rule, name, kwargs)
实用函数,用于仅在尚不存在代码库的情况下添加代码库。
这是为了实现 https://bazel.build/rules/deploying#dependencies 中记录的 safe repositories.bzl 宏。
参数
repo_rule |
。
代码库规则函数。 |
name |
。
要创建的代码库的名称。 |
kwargs |
可选属性。
传递给 repo_rule 函数的剩余参数。 |
parse_netrc
parse_netrc(contents, filename)
用于解析至少一个基本 .netrc 文件的实用函数。
参数
contents |
。
解析器的输入。 |
filename |
可选。默认值为 None 要在错误消息中使用的文件名(如果有)。 |
patch
patch(ctx, patches, patch_cmds, patch_cmds_win, patch_tool, patch_args, auth)
对已提取的代码库进行修补的实现。
此规则旨在用于代码库规则的实现功能。如果未指定参数 patches
、patch_tool
、patch_args
、patch_cmds
和 patch_cmds_win
,则它们取自 ctx.attr
。
参数
ctx |
。
调用此实用函数的代码库规则的代码库上下文。 |
patches |
可选。默认值为 None 要应用的补丁文件。字符串、标签或路径的列表。 |
patch_cmds |
可选。默认值为 None 要运行修补的 Bash 命令,以逐一向 bash -c 传递。字符串列表 |
patch_cmds_win |
可选。默认值为 None 要运行修补的 Powershell 命令,会逐一传递给 Powershell /c。字符串列表。如果此参数的布尔值为 false,系统将使用 patch_cmds,并忽略此参数。 |
patch_tool |
可选。默认值为 None 为应用补丁而执行的补丁工具的路径。字符串。 |
patch_args |
可选。默认值为 None 需要传递给修补工具的参数。字符串列表。 |
auth |
可选。默认值为 None 可选的字典,用于指定某些网址的身份验证信息。 |
read_netrc
read_netrc(ctx, filename)
用于解析至少一个基本 .netrc 文件的实用函数。
参数
ctx |
。
调用此实用函数的代码库规则的代码库上下文。 |
filename |
。
要读取的 .netrc 文件的名称 |
read_user_netrc
read_user_netrc(ctx)
读取用户的默认 netrc 文件。
参数
ctx |
。
调用此实用函数的代码库规则的代码库上下文。 |
update_attrs
update_attrs(orig, keys, override)
实用函数,用于更改指定属性并将其添加到特定代码库规则调用。
这可让规则可重现。
参数
orig |
。
由特定规则调用根据(显式或隐式)实际设置的属性的字典 |
keys |
。
此规则中定义的完整属性集 |
override |
。
要替换或添加到原始属性的字典 |
use_netrc
use_netrc(netrc, urls, patterns)
根据解析的 netrc 文件和网址列表计算身份验证字典。
参数
netrc |
。
已解析为字典的 netrc 文件,例如从 read_netrc 中获取的 |
urls |
。
网址列表。 |
patterns |
。
授权格式网址的可选字典 |
workspace_and_buildfile
workspace_and_buildfile(ctx)
用于编写 WORKSPACE 和 BUILD 文件(如有请求)的实用函数。
此规则旨在用于代码库规则的实现功能。它假定参数 name
、build_file
、build_file_content
、workspace_file
和 workspace_file_content
存在于 ctx.attr
中;后四个参数可能具有值 None。
参数
ctx |
。
调用此实用函数的代码库规则的代码库上下文。 |