简体   繁体   English

有没有办法直接访问 Bazel 中内置的 starlark 语言类型?

[英]Is there a way to directly access the built-in types of starlark language in Bazel?

For example, is there a way to call the constructor of File class to create an instance of it?例如,有没有办法调用 File class 的构造函数来创建它的实例?

Generally it just depends on the thing you want.一般来说,它只取决于你想要的东西。 Some things like File you have to go through an API, for example to create a file object in a rule function, you would use ctx.actions.declare_file(filename) Some things like File you have to go through an API, for example to create a file object in a rule function, you would use ctx.actions.declare_file(filename)

See this for examples: https://docs.bazel.build/versions/master/skylark/lib/actions.html#declare_file有关示例,请参见: https://docs.bazel.build/versions/master/skylark/lib/actions.html#declare_file

Other things you can create directly, like depset has depset() .您可以直接创建的其他内容,例如depset具有depset() See global functions here https://docs.bazel.build/versions/master/skylark/lib/skylark-overview.html在此处查看全局函数https://docs.bazel.build/versions/master/skylark/lib/skylark-overview.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM