Skip to content

Commit 5a39b1f

Browse files
committed
chore: warn when copy_to_bin reads from bazel-out
1 parent 562c4b2 commit 5a39b1f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/private/copy_to_bin.bzl

+17
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ target to {file_basename}'s package using:
5555
package = "%s//%s" % (ctx.label.workspace_name, ctx.label.package),
5656
),
5757
)
58+
59+
if file.path.startswith("bazel-"):
60+
first = file.path.split("/")[0]
61+
suffix = first[len("bazel-"):]
62+
if suffix in ["testlogs", "bin", "out"]:
63+
# buildifier: disable=print
64+
print("""
65+
WARNING: sources are being copied from {bin}. This is probably not what you want.
66+
67+
Add these lines to .bazelignore:
68+
bazel-out
69+
bazel-bin
70+
bazel-testlogs
71+
72+
and/or correct the `glob` patterns that are including these files in the sources.
73+
""".format(bin = first))
74+
5875
dst = ctx.actions.declare_file(file.basename, sibling = file)
5976
copy_file_action(ctx, file, dst, is_windows = is_windows)
6077
return dst

0 commit comments

Comments
 (0)