I had the chance to talk to @aiuto at Bazelcon last week and I wanted to note the use cases I had in mind for the discussions we had. The discussions were related to packaging runfiles.
Use case 1
This is already detailed in #631. We have a macro around pkg_tar that solves the problem. But if feels like it should really be a flag in pkg_tar instead.
Use case 2
This use case is around runfiles for deployed binaries. For example, we currently have:
cc_binary(
name = "bin",
...
)
pkg_files(
name = "bin_dir",
srcs = [":bin"],
prefix = "opt/foo/bin",
)
pkg_files(
name = "systemd_startup_files",
...
)
pkg_tar(
name = "deployable_tar",
srcs = [
":bin_dir",
":systemd_startup_files",
],
)
I.e. we have a package that gets deployed so that the binaries get started on boot by systemd. This is the most bare example I can think of that is still representative of our use case.
The trouble comes up under 2 scenarios:
bin is compiled against a pre-compiled library libfoo.so, or
bin has data dependencies. E.g. a config file conf.json.
In both scenarios the result is that bin has some runfiles. Unfortunately, it looks like the pkg_files rule discards runfiles information. So the data dependencies and the pre-compiled libraries don't make it into the tarball regardless of the include_runfiles attribute's value.
I don't know what the right answer is here, but it would be kind of nice to say something like this:
I suspect there's no way for pkg_files to distinguish between the binary's data dependencies and the .so files it links against. In that case, a simplified version that would achieve something similar would be:
I had the chance to talk to @aiuto at Bazelcon last week and I wanted to note the use cases I had in mind for the discussions we had. The discussions were related to packaging runfiles.
Use case 1
This is already detailed in #631. We have a macro around
pkg_tar
that solves the problem. But if feels like it should really be a flag inpkg_tar
instead.Use case 2
This use case is around runfiles for deployed binaries. For example, we currently have:
I.e. we have a package that gets deployed so that the binaries get started on boot by systemd. This is the most bare example I can think of that is still representative of our use case.
The trouble comes up under 2 scenarios:
bin
is compiled against a pre-compiled librarylibfoo.so
, orbin
hasdata
dependencies. E.g. a config fileconf.json
.In both scenarios the result is that
bin
has some runfiles. Unfortunately, it looks like thepkg_files
rule discards runfiles information. So thedata
dependencies and the pre-compiled libraries don't make it into the tarball regardless of theinclude_runfiles
attribute's value.I don't know what the right answer is here, but it would be kind of nice to say something like this:
I suspect there's no way for
pkg_files
to distinguish between the binary'sdata
dependencies and the .so files it links against. In that case, a simplified version that would achieve something similar would be:Right now we work around this by not using
pkg_fies
when we need runfiles support. Instead, we usepkg_tar
because of itsinclude_runfiles
support.