scrow-monorepo/rules/fetch_file.bzl
2026-08-19 02:15:15 +02:00

22 lines
694 B
Python

# TODO implement sha256sum attribute + checksum verification
def _fetch_file_impl(ctx):
out_file = ctx.actions.declare_file(ctx.attr.filename)
ctx.actions.run_shell(
outputs = [out_file],
command = "curl -Lso \"$1\" \"$2\"",
arguments = [out_file.path, ctx.attr.url],
execution_requirements = {
"requires-network": "1",
},
progress_message = "Downloading plugin %s" % ctx.attr.filename,
)
return [DefaultInfo(files = depset([out_file]))]
fetch_file = rule(
implementation = _fetch_file_impl,
attrs = {
"url": attr.string(mandatory = True),
"filename": attr.string(mandatory = True),
},
)