bazelbuild / rules_dotnet

.NET rules for Bazel
Apache License 2.0
185 stars 79 forks source link

[Next] Expose F# source files as a provider? #315

Open njlr opened 1 year ago

njlr commented 1 year ago

I have been investigating the feasibility of Fable rules (https://github.com/bazelbuild/rules_dotnet/issues/236) that can consume fsharp_library targets as deps.

The motivation for this is that the user will not have to define their library targets twice to support .NET and Fable.

load("@rules_dotnet//dotnet:defs.bzl", "fsharp_library")
load("@rules_fable//fable:defs.bzl", "fable_library")

fsharp_library(
  name = "lib",
  srcs = [
    "Library.fs",
  ],
  target_frameworks = [ "netstandard2.1" ],
  deps = [
    "@paket.main//netstandard.library.ref",
    "@paket.main//fsharp.core",
  ],
)

fable_library(
  name = "app",
  srcs = [
    "App.fs",
  ],
  deps = [
    ":lib",
  ],
)

Fable requires the source-files (.fs, .fsi) of all dependencies to compile. However, this information does not appear to be exposed by any provider on fsharp_library.

Is it possible to get the sources-files of and fsharp_library?

If not, could this provider be added? Perhaps FSharpInfo?

purkhusid commented 1 year ago

I think having a separate provider with the compilation parameters would not be a bad idea. It could also be used in e.g. a rule that generates csproj/fsproj files. Maybe a DotnetCompileInfo ? I'm currently on paternal leave so I don't have much time for contributions at the moment but I could review a PR if you want to contribute this addition?

njlr commented 1 year ago

This PR is different but related - it exposes the files inside Nuget packages: https://github.com/bazelbuild/rules_dotnet/pull/316