I have a Bazel project with a mix of C++, Java and Python and I want to package up everything that gets built "properly" (currently I'm scp-ing the bazel-bin directory around).
What is the best way to take the whole runtime environment that Bazel generates and package it up.
The only option that I can see from the docs is to use rules_pkg
and add a pkg_files
rule for every target and I'm hoping there's an easier way?
Nope there isn't an easier way, because you cannot depend on "everything" like you can build "everything" using wildcards (
//...
) when describing a build target such as packaging rules. It would also suffer from infinite recursion trying to depend on itself. Well, that's sort of the short answer.You can of course search (or query) your build tree and collect information about all targets therein and generate one more (build) target to collect 'em all (just make sure it excludes itself if previously generated).
And, since repository_rules can be used to setup your workspace and operate sort of "outside" bazel build itself (which also makes them fairly dangerous), you could integrate such generated build target into your repository's build.
I personally am not a fan of using wildcards and would prefer defining an "everything" target that actually describes what "everything" is / should be.