英文:
Access current package's label in BUILD
问题
有没有办法在BUILD文件中获取当前包的标签?
假设我有这样一个规则调用:
do_x_or_fail(
name = "foo",
<...>
message_on_error = "Incorrect BarBaz setup for " + ?CURRENT_PACKAGE? + ". Check Xyz."
)
我该如何实现?CURRENT_PACKAGE?
?
我看到有Label()
或native.package_relative_label()
等函数,但我没能直接从BUILD文件中调用它们。
我尝试在BUILD文件中调用native.package_relative_label()
,但出现以下错误:name 'native' is not defined
。
英文:
Is there a way to obtain the current package's label in the BUILD file?
Imagine I have some rule invocation like this:
do_x_or_fail(
name = "foo",
<...>
message_on_error = "Incorrect BarBaz setup for " + ?CURRENT_PACKAGE? + ". Check Xyz."
)
How would I implement ?CURRENT_PACKAGE?
?
I see there are functions like Label()
or native.package_relative_label()
, but I didn't manage to call them from the BUILD
file directly.
I tried calling native.package_relative_label()
from a BUILD
file. It failed with the following error: name 'native' is not defined
.
答案1
得分: 2
BUILD
文件可以调用package_name()
。
英文:
BUILD
files can invoke package_name()
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论