bazelbuild / rules_pkg

Bazel rules for creating packages of many types (zip, tar, deb, rpm, ...)
Apache License 2.0
216 stars 174 forks source link

Tarball of a cc_library containing public headers #719

Closed skeptic-monkey closed 1 year ago

skeptic-monkey commented 1 year ago

Hi,

I'd like to release some of my cc_library as prebuilt libraries (using .tar or .zip file)

right now, when using pkg_tar on a cc_library, the .tar file only contains the .a / .so files. Is it possible to also have all the public headers required to build against the library as well ?

aiuto commented 1 year ago

You'll need to make them srcs of the pkg_tar target. But you probably want to use pkg_files to map them into the location you want your users to include from. Perhaps something like /usr/include/my_pkg/.... Or maybe you want them flattened into the same directory as your binary.

Gathering the transitive headers is possible, but not something we should do in this rule set. You might want to ask the rules_cc community. My thought would be you would create a rule that expects CcInfo on its inputs, which would be youre cc_library target. Then you would peek into CcInfo and get the headers bazel would use for compilation. Then from that list, create a PackageFilesInfo mapping the input headers to reasonable locations. But... that's just my off the cuff suggestion.

skeptic-monkey commented 1 year ago

What you're proposing is excactly what I was doing, but before going too far in my rule development I wanted to make sure that I wasn't reinventing the wheel.

Thanks.