成员
标签
Label Label(label_string)
Label("//tools:default")
参数
参数 | 说明 |
---|---|
label_string
|
必需 标签字符串。 |
name
string Label.name
Label("//pkg/foo:abc").name == "abc"
包裹
string Label.package
Label("//pkg/foo:abc").package == "pkg/foo"
相对
Label Label.relative(relName)
//
开头)或相对于当前软件包的标签。如果此标签位于远程代码库中,则相应参数将相对于该代码库解析。如果参数包含代码库名称,系统会忽略当前标签,并原样返回参数,但如果代码库名称在当前代码库映射中,则会重写该代码库名称。系统也会原封不动地返回预留标签。例如:
Label("//foo/bar:baz").relative(":quux") == Label("//foo/bar:quux") Label("//foo/bar:baz").relative("//wiz:quux") == Label("//wiz:quux") Label("@repo//foo/bar:baz").relative("//wiz:quux") == Label("@repo//wiz:quux") Label("@repo//foo/bar:baz").relative("//visibility:public") == Label("//visibility:public") Label("@repo//foo/bar:baz").relative("@other//wiz:quux") == Label("@other//wiz:quux")
如果传入的仓库映射为 {'@other' : '@remapped'}
,则会进行以下重新映射:
Label("@repo//foo/bar:baz").relative("@other//wiz:quux") == Label("@remapped//wiz:quux")
参数
参数 | 说明 |
---|---|
relName
|
必需 相对于此标签解析的标签。 |
workspace_name
string Label.workspace_name
Label("@foo//bar:baz").workspace_name == "foo"
workspace_root
string Label.workspace_root
Label("@repo//pkg/foo:abc").workspace_root == "external/repo"