|
| 1 | +def _foo_binary_impl(ctx): |
| 2 | + print("analyzing", ctx.label) |
| 3 | + if ctx.attr.other != None: |
| 4 | + print("ctx.attr.other.files", ctx.attr.other.files) |
| 5 | + print("ctx.file.other", ctx.file.other) |
| 6 | + if ctx.file.other != None: |
| 7 | + print("dir(ctx.file.other)", dir(ctx.file.other)) |
| 8 | + print("ctx.file.other.basename", ctx.file.other.basename) |
| 9 | + print("ctx.file.other.dirname", ctx.file.other.dirname) |
| 10 | + print("ctx.file.other.extension", ctx.file.other.extension) |
| 11 | + print("ctx.file.other.is_directory", ctx.file.other.is_directory) |
| 12 | + print("ctx.file.other.is_source", ctx.file.other.is_source) |
| 13 | + print("ctx.file.other.owner", ctx.file.other.owner) |
| 14 | + print("ctx.file.other.path", ctx.file.other.path) |
| 15 | + print("ctx.file.other.root", ctx.file.other.root) |
| 16 | + print("ctx.file.other.short_path", ctx.file.other.short_path) |
| 17 | + # print("ctx.file.other.tree_relative_path", ctx.file.other.tree_relative_path) |
| 18 | + |
| 19 | + out = ctx.actions.declare_file(ctx.label.name) |
| 20 | + ctx.actions.write( |
| 21 | + output = out, |
| 22 | + content = "Hello, %s!\n" % ctx.attr.username, |
| 23 | + ) |
| 24 | + return [DefaultInfo(files = depset([out]))] |
| 25 | + |
| 26 | +foo_binary = rule( |
| 27 | + implementation = _foo_binary_impl, |
| 28 | + attrs = { |
| 29 | + "username": attr.string(), |
| 30 | + "other": attr.label(allow_single_file = True), |
| 31 | + }, |
| 32 | +) |
| 33 | + |
| 34 | +print("bzl file evaluation") |
0 commit comments