Skip to content

Commit

Permalink
track native_dlls (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
omsmith committed Oct 3, 2019
1 parent 7d43380 commit d9df065
Show file tree
Hide file tree
Showing 17 changed files with 55 additions and 5 deletions.
5 changes: 3 additions & 2 deletions csharp/private/actions/assembly.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def AssemblyAction(
args.add("/pdb:" + pdb.path)

# assembly references
(refs, runfiles) = collect_transitive_info(deps, target_framework)
(refs, runfiles, native_dlls) = collect_transitive_info(deps, target_framework)
args.add_all(refs, map_each = _format_ref_arg)

# analyzers
Expand Down Expand Up @@ -165,7 +165,7 @@ def AssemblyAction(
progress_message = "Compiling " + name,
inputs = depset(
direct = direct_inputs,
transitive = [refs],
transitive = [refs] + [native_dlls],
),
outputs = [out_file, refout, pdb],
executable = toolchain.runtime,
Expand All @@ -183,6 +183,7 @@ def AssemblyAction(
out = out_file,
refout = refout,
pdb = pdb,
native_dlls = native_dlls,
deps = deps,
transitive_refs = refs,
transitive_runfiles = runfiles,
Expand Down
6 changes: 5 additions & 1 deletion csharp/private/common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def collect_transitive_info(deps, tfm):
transitive_refs = []
direct_runfiles = []
transitive_runfiles = []
native_dlls = []

provider = CSharpAssembly[tfm]

Expand All @@ -44,10 +45,12 @@ def collect_transitive_info(deps, tfm):
direct_runfiles.append(assembly.pdb)

transitive_runfiles.append(assembly.transitive_runfiles)
native_dlls.append(assembly.native_dlls)

return (
depset(direct = direct_refs, transitive = transitive_refs),
depset(direct = direct_runfiles, transitive = transitive_runfiles),
depset(transitive = native_dlls),
)

def _get_provided_by_netstandard(providerInfo):
Expand Down Expand Up @@ -80,11 +83,12 @@ def fill_in_missing_frameworks(providers):
# newer netstandard will be preferred, if applicable
for (base, compatible_tfm) in sorted([(providers[compatible_tfm], compatible_tfm) for compatible_tfm in FrameworkCompatibility[tfm] if compatible_tfm in providers], key=_get_provided_by_netstandard):
# Copy the output from the compatible tfm, re-resolving the deps
(refs, runfiles) = collect_transitive_info(base.deps, tfm)
(refs, runfiles, native_dlls) = collect_transitive_info(base.deps, tfm)
providers[tfm] = CSharpAssembly[tfm](
out = base.out,
refout = base.refout,
pdb = base.pdb,
native_dlls = native_dlls,
deps = base.deps,
transitive_refs = refs,
transitive_runfiles = runfiles,
Expand Down
3 changes: 3 additions & 0 deletions csharp/private/frameworks/net20.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,9 @@ import_library(
name = "System.EnterpriseServices-noncyclic",
target_framework = "net20",
refdll = "//:build/.NETFramework/v2.0/System.EnterpriseServices.dll",
native_dlls = [
"//:build/.NETFramework/v2.0/System.EnterpriseServices.Wrapper.dll",
],
deps = [
"//:Microsoft.VisualC",
"//:mscorlib",
Expand Down
3 changes: 3 additions & 0 deletions csharp/private/frameworks/net40.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,9 @@ import_library(
name = "System.EnterpriseServices-noncyclic",
target_framework = "net40",
refdll = "//:build/.NETFramework/v4.0/System.EnterpriseServices.dll",
native_dlls = [
"//:build/.NETFramework/v4.0/System.EnterpriseServices.Wrapper.dll",
],
deps = [
"//:Microsoft.VisualC",
"//:mscorlib",
Expand Down
3 changes: 3 additions & 0 deletions csharp/private/frameworks/net45.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,9 @@ import_library(
name = "System.EnterpriseServices-noncyclic",
target_framework = "net45",
refdll = "//:build/.NETFramework/v4.5/System.EnterpriseServices.dll",
native_dlls = [
"//:build/.NETFramework/v4.5/System.EnterpriseServices.Wrapper.dll",
],
deps = [
"//:mscorlib",
"//:System",
Expand Down
3 changes: 3 additions & 0 deletions csharp/private/frameworks/net451.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,9 @@ import_library(
name = "System.EnterpriseServices-noncyclic",
target_framework = "net451",
refdll = "//:build/.NETFramework/v4.5.1/System.EnterpriseServices.dll",
native_dlls = [
"//:build/.NETFramework/v4.5.1/System.EnterpriseServices.Wrapper.dll",
],
deps = [
"//:mscorlib",
"//:System",
Expand Down
3 changes: 3 additions & 0 deletions csharp/private/frameworks/net452.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,9 @@ import_library(
name = "System.EnterpriseServices-noncyclic",
target_framework = "net452",
refdll = "//:build/.NETFramework/v4.5.2/System.EnterpriseServices.dll",
native_dlls = [
"//:build/.NETFramework/v4.5.2/System.EnterpriseServices.Wrapper.dll",
],
deps = [
"//:mscorlib",
"//:System",
Expand Down
3 changes: 3 additions & 0 deletions csharp/private/frameworks/net46.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,9 @@ import_library(
name = "System.EnterpriseServices-noncyclic",
target_framework = "net46",
refdll = "//:build/.NETFramework/v4.6/System.EnterpriseServices.dll",
native_dlls = [
"//:build/.NETFramework/v4.6/System.EnterpriseServices.Wrapper.dll",
],
deps = [
"//:mscorlib",
"//:System",
Expand Down
3 changes: 3 additions & 0 deletions csharp/private/frameworks/net461.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,9 @@ import_library(
name = "System.EnterpriseServices-noncyclic",
target_framework = "net461",
refdll = "//:build/.NETFramework/v4.6.1/System.EnterpriseServices.dll",
native_dlls = [
"//:build/.NETFramework/v4.6.1/System.EnterpriseServices.Wrapper.dll",
],
deps = [
"//:mscorlib",
"//:System",
Expand Down
3 changes: 3 additions & 0 deletions csharp/private/frameworks/net462.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,9 @@ import_library(
name = "System.EnterpriseServices-noncyclic",
target_framework = "net462",
refdll = "//:build/.NETFramework/v4.6.2/System.EnterpriseServices.dll",
native_dlls = [
"//:build/.NETFramework/v4.6.2/System.EnterpriseServices.Wrapper.dll",
],
deps = [
"//:mscorlib",
"//:System",
Expand Down
3 changes: 3 additions & 0 deletions csharp/private/frameworks/net47.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,9 @@ import_library(
name = "System.EnterpriseServices-noncyclic",
target_framework = "net47",
refdll = "//:build/.NETFramework/v4.7/System.EnterpriseServices.dll",
native_dlls = [
"//:build/.NETFramework/v4.7/System.EnterpriseServices.Wrapper.dll",
],
deps = [
"//:mscorlib",
"//:System",
Expand Down
3 changes: 3 additions & 0 deletions csharp/private/frameworks/net471.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,9 @@ import_library(
name = "System.EnterpriseServices-noncyclic",
target_framework = "net471",
refdll = "//:build/.NETFramework/v4.7.1/System.EnterpriseServices.dll",
native_dlls = [
"//:build/.NETFramework/v4.7.1/System.EnterpriseServices.Wrapper.dll",
],
deps = [
"//:mscorlib",
"//:System",
Expand Down
3 changes: 3 additions & 0 deletions csharp/private/frameworks/net472.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,9 @@ import_library(
name = "System.EnterpriseServices-noncyclic",
target_framework = "net472",
refdll = "//:build/.NETFramework/v4.7.2/System.EnterpriseServices.dll",
native_dlls = [
"//:build/.NETFramework/v4.7.2/System.EnterpriseServices.Wrapper.dll",
],
deps = [
"//:mscorlib",
"//:System",
Expand Down
3 changes: 3 additions & 0 deletions csharp/private/frameworks/net48.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,9 @@ import_library(
name = "System.EnterpriseServices-noncyclic",
target_framework = "net48",
refdll = "//:build/.NETFramework/v4.8/System.EnterpriseServices.dll",
native_dlls = [
"//:build/.NETFramework/v4.8/System.EnterpriseServices.Wrapper.dll",
],
deps = [
"//:mscorlib",
"//:System",
Expand Down
1 change: 1 addition & 0 deletions csharp/private/providers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def _make_csharp_provider(tfm):
"out": "a dll (for libraries and tests) or an exe (for binaries).",
"refout": "A reference-only DLL/exe. See docs/ReferenceAssemblies.md for more info.",
"pdb": "debug symbols",
"native_dlls": "A list of native DLLs required to build and run this assembly",
"deps": "the non-transitive dependencies for this assembly (used by import_multiframework_library).",
"transitive_refs": "A list of other assemblies to reference when referencing this assembly in a compilation.",
"transitive_runfiles": "Runfiles from the transitive dependencies.",
Expand Down
9 changes: 8 additions & 1 deletion csharp/private/rules/imports.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ def _import_library(ctx):
if ctx.file.refdll != None:
files.append(ctx.file.refdll)

files += ctx.files.native_dlls

tfm = ctx.attr.target_framework

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

providers = {
tfm: CSharpAssembly[tfm](
out = ctx.file.dll,
refout = ctx.file.refdll,
pdb = ctx.file.pdb,
native_dlls = depset(direct = ctx.files.native_dlls, transitive = [native_dlls]),
deps = ctx.attr.deps,
transitive_refs = refs,
transitive_runfiles = runfiles,
Expand Down Expand Up @@ -60,6 +63,10 @@ import_library = rule(
doc = "A metadata-only DLL, suitable for compiling against but not running",
allow_single_file = [".dll"],
),
"native_dlls": attr.label_list(
doc = "A list of native dlls, which while unreferenced, are required for running and compiling",
allow_files = [".dll"],
),
"deps": attr.label_list(
doc = "other DLLs that this DLL depends on.",
providers = AnyTargetFramework,
Expand Down
3 changes: 2 additions & 1 deletion csharp/private/rules/library_set.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ def _library_set(ctx):

tfm = ctx.attr.target_framework

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

providers = {
tfm: CSharpAssembly[tfm](
out = None,
refout = None,
pdb = None,
native_dlls = native_dlls,
deps = ctx.attr.deps,
transitive_refs = refs,
transitive_runfiles = runfiles,
Expand Down

0 comments on commit d9df065

Please sign in to comment.