bazel-contrib / bazel-contrib/rules_dotnet

How to depend on native code?

Open
#349 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
209
Forks
98
Avg merge
3h 59m
Merged PRs (30d)
14

Description

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

```starlark
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

Edit: See https://github.com/bazel-contrib/rules_dotnet/pull/535

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the bazel-fsharp-native repository, especially math.c, math.h, and Program.fs, then inspect rules_dotnet PR 535 and the existing fsharp_binary definition. Done means the repository has a supported, demonstrated way for a rules_dotnet target to depend on the native library across its target platforms.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, fsharp
Domain
build-system, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.