bazelbuild / rules_dotnet

.NET rules for Bazel
Apache License 2.0
187 stars 82 forks source link

How to depend on native code? #349

Open njlr opened 1 year ago

njlr commented 1 year ago

I was wondering if anyone has figured out how to depend on native libraries in a rules_dotnet target?

load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_dotnet//dotnet:defs.bzl", "fsharp_binary")

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

fsharp_binary(
  name = "app",
  srcs = [
    "Program.fs",
  ],
  target_frameworks = [ "net6.0" ],
  private_deps = [
    "@paket.main//microsoft.netcore.app.ref",
  ],
  deps = [
    "@paket.main//fsharp.core",
  ],
  data = [
    ":math", # This is not right of course!
  ],
)

I was thinking about building a NuGet zip file containing a shared library built for each target platform and then depending on that?

Full repo: https://github.com/njlr/bazel-fsharp-native

purkhusid commented 1 year ago

I haven't had use for this yet so I haven't really thought this through. I think we might just need to add an compatability layer in the deps attribute which accepts the providers that the c/c++ rules outputs. I'm not very likely to implement this since I don't need this at the moment but I can review an implementation if anyone is interested.