Skip to content

Commit

Permalink
bazel: Added a rule to copy a file
Browse files Browse the repository at this point in the history
This is unnecessarily basic, but it can sometimes be useful to
copy a file from one repository to another.

Signed-off-by: SlyMarbo <the.sly.marbo@googlemail.com>
  • Loading branch information
SlyMarbo committed Apr 15, 2022
1 parent 8c65f93 commit 334a6e3
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions bazel/copy_file.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2022 The Firefly Authors.
#
# Use of this source code is governed by a BSD 3-clause
# license that can be found in the LICENSE file.

def _copy_file_impl(ctx):
outfile = ctx.actions.declare_file(ctx.label.name)
ctx.actions.run_shell(
inputs = [ctx.file.src],
outputs = [outfile],
command = "cp %s %s" % (ctx.file.src.path, outfile.path),
)

return [DefaultInfo(
files = depset([outfile]),
)]

copy_file = rule(
implementation = _copy_file_impl,
attrs = {
"src": attr.label(
doc = "Label of the file to copy.",
allow_single_file = True,
mandatory = True,
),
},
)

0 comments on commit 334a6e3

Please sign in to comment.