Marco Dinatsoli
Marco Dinatsoli

Reputation: 10580

What is the output type in Bazel?

In Bazel you can define an attribute type, which could be int or string ... or output

What does it mean to have a type of attribute as output?

Here's an example:

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(),
    },
)

It's a simple rule, which has the_results as of type output

Upvotes: 0

Views: 715

Answers (1)

Benjamin Peterson
Benjamin Peterson

Reputation: 20530

It means that attribute corresponds to a file that the rule will create an action to produce. See https://docs.bazel.build/versions/master/skylark/rules.html#output-attributes and https://docs.bazel.build/versions/master/skylark/lib/attr.html#output.

Upvotes: 2

Related Questions