Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cases for packaging runfiles #642

Open
philsc opened this issue Nov 25, 2022 · 0 comments
Open

Use cases for packaging runfiles #642

philsc opened this issue Nov 25, 2022 · 0 comments
Labels
P2 An issue that should be worked on when time is available

Comments

@philsc
Copy link

philsc commented Nov 25, 2022

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:

  1. bin is compiled against a pre-compiled library libfoo.so, or
  2. 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:

pkg_files(
    name = "bin_dir",
    srcs = [":bin"],
    prefix = "opt/foo/bin",
    cc_runfiles_prefix = "opt/foo/lib",
    data_runfiles_prefix = "opt/foo/share",
)

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:

pkg_files(
    name = "bin_dir",
    srcs = [":bin"],
    prefix = "opt/foo/bin",
    runfiles_prefix = "opt/foo/data",
)

Right now we work around this by not using pkg_fies when we need runfiles support. Instead, we use pkg_tar because of its include_runfiles support.

@aiuto aiuto added the P2 An issue that should be worked on when time is available label Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 An issue that should be worked on when time is available
Projects
None yet
Development

No branches or pull requests

2 participants