bazel 的输出类型是什么?

what is the output type in bazel?

在 Bazel 中你可以定义一个属性类型,可以是 int 或 string ... 或者 output

将一种属性作为“输出”是什么意思?

这是一个例子:

def _something(ctx):

    print("The username is: ", ctx.attr.username)
    print("boolean value is", ctx.attr.boolean)
    print("my age is:", ctx.attr.age)
    print("Start printing hours .." )
    for i in ctx.attr.hours:
        print (i)
    print("Finish printing hours ..")
    print("Depending on: ", ctx.attr.dep_on)

print_me = rule(
    implementation = _something,
    attrs = {
        "username" : attr.string(),
        "boolean" : attr.bool(),
        "age" : attr.int(),
        "hours" : attr.int_list(),
        "dep_on": attr.label(),
        "the_results": attr.output(),
    },
)

这是一个简单的规则,它具有 the_results 作为输出类型

这意味着该属性对应于该规则将创建一个操作来产生的文件。参见 https://docs.bazel.build/versions/master/skylark/rules.html#output-attributes and https://docs.bazel.build/versions/master/skylark/lib/attr.html#output