Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a csharp_library_set rule #84

Merged
merged 1 commit into from
Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions csharp/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ load(
"//csharp/private:rules/library.bzl",
_csharp_library = "csharp_library",
)
load(
"//csharp/private:rules/library_set.bzl",
_csharp_library_set = "csharp_library_set",
)
load(
"//csharp/private:rules/nunit_test.bzl",
_csharp_nunit_test = "csharp_nunit_test",
Expand All @@ -32,6 +36,7 @@ load(

csharp_binary = _csharp_binary
csharp_library = _csharp_library
csharp_library_set = _csharp_library_set
csharp_nunit_test = _csharp_nunit_test
csharp_register_toolchains = _csharp_register_toolchains
csharp_repositories = _csharp_repositories
Expand Down
45 changes: 45 additions & 0 deletions csharp/private/rules/library_set.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
load(
"@d2l_rules_csharp//csharp/private:common.bzl",
"collect_transitive_info",
"fill_in_missing_frameworks",
)
load("@d2l_rules_csharp//csharp/private:providers.bzl", "AnyTargetFramework", "CSharpAssembly")

def _library_set(ctx):
files = []

tfm = ctx.attr.target_framework

(refs, runfiles) = collect_transitive_info(ctx.attr.deps, tfm)

providers = {
tfm: CSharpAssembly[tfm](
out = None,
refout = None,
pdb = None,
deps = ctx.attr.deps,
transitive_refs = refs,
transitive_runfiles = runfiles,
actual_tfm = tfm
),
}

fill_in_missing_frameworks(providers)

return providers.values()

csharp_library_set = rule(
_library_set,
doc = "Defines a set of C# libraries to be depended on together",
attrs = {
"target_framework": attr.string(
doc = "The target framework for this set of libraries",
mandatory = True,
),
"deps": attr.label_list(
doc = "The set of libraries",
providers = AnyTargetFramework,
),
},
executable = False,
)