How do I move a bazel build target?

772 Views Asked by At

All of the bazel rules put the build targets in a specific place.
I can find the targets through bazel-bin/, but they are all scattered recursively with other non-target files I don't care about.

How do I write a build rule that puts all my programs in a single bin/ directory?

Am I suppose to write my own program that traverses bazel-bin/ and rsyncs all the programs to something like usr/local/bin, or is there a query I can do? I'd like it to just be part of the build rule, but it doesn't seem like the default rules support anything like this. And I don't like the idea of having to run the build, and then run a 2nd step that syncs all my binaries to the same folder.

What is the recommended way of doing this? Its very common to want all your programs and all your tests in the same specific directories.

1

There are 1 best solutions below

2
On BEST ANSWER

Look into using pkg_tar, you can use this to declare the files/outputs you actually want to distribute and the package_dir attribute to put the files in usr/local/bin or wherever you want within the tarball.