"copy files" rule?

4,283 views
Skip to first unread message

ronnie...@oracle.com

unread,
Mar 9, 2016, 10:22:55 PM3/9/16
to bazel-discuss
Is there a built in rule that does nothing but copy a directory to the output directory (runfiles)?  If not, I'd like to propose a "copy_files" rule. 

An example use case would be a configuration type package that produces no binary and has no buildable code, but contains files that are consumed by other packages (at runtime).

This is almost possible with the "java_library" rule used with "data" -- but it also produces an unnecessary jar.

Brian Silverman

unread,
Mar 9, 2016, 10:55:05 PM3/9/16
to ronnie...@oracle.com, bazel-discuss
Are you looking for "filegroup"? Just building a filegroup won't actually copy any files, but if you put a filegroup in other rules' "data" attributes, the files will all get copied.

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/7913711a-0168-48f4-821e-663bac128188%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ronnie Roller

unread,
Mar 9, 2016, 11:11:20 PM3/9/16
to Brian Silverman, bazel-discuss
Filegroup will work, yes. But that's where I'm having issues -- I can't find a suitable rule that will simply and only, copy the filegroup to the output directory. 

Java_library almost works, but it also produces a jar. 

Brian Silverman

unread,
Mar 10, 2016, 11:08:03 AM3/10/16
to Ronnie Roller, bazel-discuss
Bazel doesn't really have a way to do that, and I don't really see how it can be done usefully. The first fundamental problem that comes to mind is there will be no way of differentiating between the output files you want and stale files that are no longer being built.

If you really want, writing a genrule to do this would be fairly easy. If you want to do anything more complicated (like depend on the output files, or manipulate the file paths in any way more complicated than adding another directory on), I would recommend a Skylark rule instead.

Justine Tunney

unread,
Mar 10, 2016, 1:07:28 PM3/10/16
to Brian Silverman, bazel-discuss, Ronnie Roller

Do you want to copy to different directories than the original structure? A feature similar to that is currently in the works. In the meantime, you can generate ln statements at the beginning of the outputted program similar to how the app engine rules do.

ronnie...@oracle.com

unread,
Mar 10, 2016, 1:48:40 PM3/10/16
to bazel-discuss, bsilve...@gmail.com, ronnie...@oracle.com
The same structure will be fine.  Can you point me to an example demonstrating this with "in statements"? 

When do you expect this feature to land?

Kristina Chodorow

unread,
Mar 11, 2016, 9:37:49 AM3/11/16
to ronnie...@oracle.com, bazel-discuss, Brian Silverman

On Thu, Mar 10, 2016 at 1:48 PM, <ronnie...@oracle.com> wrote:
The same structure will be fine.  Can you point me to an example demonstrating this with "in statements"? 

When do you expect this feature to land?

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages