0

I have a cc_library like so:

cc_library(
  name = "math",
  hdrs = [ "math.h" ],
  srcs = [ "math.c" ],
)

Now, I want to make a zip file that contains shared libraries for macOS, Linux and Windows. It should be arranged so that each shared library is in a subfolder named after the platform.

I want something that looks like this:

load("@rules_pkg//:pkg.bzl", "pkg_zip")

# Not real code
pkg_zip(
  name = "fat_bundle",
  srcs = {
    "runtimes/macos-x64/native/libmath.dylib": ":math#macos_x64,shared",
    "runtimes/linux-x64/native/libmath.so": ":math#linux_x64,shared",
    "runtimes/win-x64/native/math.dll": ":math#windows_x64,shared",
  },
)

However the above is not valid Bazel.

How can I achieve this?

sdgfsdh
  • 33,689
  • 26
  • 132
  • 245
  • 1
    [User-defined transitions](https://bazel.build/extending/config#user-defined-transitions) are the tool Bazel provides for this. https://stackoverflow.com/q/60979761/2263152, https://groups.google.com/g/bazel-discuss/c/H8lS3JL2jt8, and https://stackoverflow.com/q/71173642/2263152 are some related discussions. I think you can figure it out from those, I might have time to write up a proper answer to this specific question later this week, because you're looking for various pieces from each of those. – Brian Silverman Apr 04 '23 at 20:02

0 Answers0