Skip to content
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
6 changes: 6 additions & 0 deletions dotnet/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ exports_files(
visibility = ["//visibility:public"],
)

config_setting(
name = "stamp_enabled",
values = {"stamp": "1"},
visibility = ["//dotnet:__subpackages__"],
)

# The NUnit3TestAdapter NuGet package ships its assemblies under build/<tfm>/
# (intended for MSBuild .targets-based wiring) instead of the standard
# lib/<tfm>/ layout, so rules_dotnet's paket extractor leaves the
Expand Down
30 changes: 29 additions & 1 deletion dotnet/private/sourcelink.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ load("@rules_dotnet//dotnet/private/transitions:tfm_transition.bzl", "tfm_transi

def _generate_sourcelink_json(ctx):
output = ctx.actions.declare_file(ctx.label.name + "_sourcelink.json")

# Only stamped builds read the workspace status file: its git revision changes
# every commit and would otherwise invalidate every assembly and test.
if not ctx.attr.stamp:
ctx.actions.write(
output = output,
content = '{{"documents":{{"*":"{repo}/raw/HEAD/*"}}}}\n'.format(
Comment thread
titusfortner marked this conversation as resolved.
repo = ctx.attr.repo_url.rstrip("/"),
),
)
return output

ctx.actions.run_shell(
inputs = [ctx.info_file],
outputs = [output],
Expand Down Expand Up @@ -87,12 +99,28 @@ _SOURCELINK_ATTRS["repo_url"] = attr.string(
doc = "Source repository URL for SourceLink metadata (e.g. https://github.com/owner/repo).",
default = "https://github.com/SeleniumHQ/selenium",
)
_SOURCELINK_ATTRS["stamp"] = attr.bool(
doc = "Embed the current git revision in the SourceLink metadata. Defaults to the --stamp flag.",
default = False,
)

csharp_sourcelink_library = rule(
_csharp_sourcelink_library = rule(
_csharp_sourcelink_library_impl,
doc = "Compile a C# DLL with SourceLink metadata embedded in the PDB.",
attrs = _SOURCELINK_ATTRS,
executable = False,
toolchains = ["@rules_dotnet//dotnet:toolchain_type"],
cfg = tfm_transition,
)

def csharp_sourcelink_library(name, stamp = None, **kwargs):
if stamp == None:
stamp = select({
"//dotnet/private:stamp_enabled": True,
"//conditions:default": False,
})
_csharp_sourcelink_library(
name = name,
stamp = stamp,
**kwargs
)
Loading