Skip to content

Commit b9d83bf

Browse files
shs96cjimevans
andauthored
[bazel] Update rules_dotnet to the latest version (#12784)
[bazel + .net] Rework Bazel builds of .Net code on top of latest `rules_dotnet` Co-authored-by: Jim Evans <james.h.evans.jr@gmail.com>
1 parent 2ffb772 commit b9d83bf

File tree

61 files changed

+1742
-556
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1742
-556
lines changed

.bazelignore

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
buck-out
2+
dotnet/test/firefox/bin
3+
dotnet/test/firefox/obj
4+
dotnet/test/edge/bin
5+
dotnet/test/edge/obj
6+
dotnet/test/common/bin
7+
dotnet/test/common/obj
8+
dotnet/test/support/bin
9+
dotnet/test/support/obj
10+
dotnet/test/safari/bin
11+
dotnet/test/safari/obj
12+
dotnet/test/chrome/bin
13+
dotnet/test/chrome/obj
14+
dotnet/test/ie/bin
15+
dotnet/test/ie/obj
16+
dotnet/test/remote/bin
17+
dotnet/test/remote/obj
18+
dotnet/src/support/bin
19+
dotnet/src/support/obj
20+
dotnet/src/webdriver/bin
21+
dotnet/src/webdriver/obj
22+
java/build/production
223
java/client/build
324
java/server/build
425
node_modules
5-
java/build/production

.github/workflows/ci-rbe.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
name: Test
2121
uses: ./.github/workflows/bazel.yml
2222
with:
23+
# TODO: experiment with turning off caches
2324
name: All RBE tests
2425
cache-key: rbe
2526
ruby-version: jruby-9.4.2.0

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ test-output/
1313
common/build
1414
/build/
1515
cpp/iedriver/IEReturnTypes.h
16+
dotnet/.idea/
17+
dotnet/packages/
1618
java/client/src/org/openqa/selenium/ie/IeReturnTypes.java
1719
java/server/test/org/openqa/selenium/example
1820
javascript/deps.js

.skipped-tests

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
-//dotnet/test/common:DevTools/DevToolsNetworkTest-chrome
2+
-//dotnet/test/common:Interactions/BasicMouseInterfaceTest-chrome
3+
-//dotnet/test/common:Interactions/BasicMouseInterfaceTest-firefox
4+
-//dotnet/test/common:JavascriptEnabledBrowserTest-chrome
5+
-//dotnet/test/common:NetworkInterceptionTests-chrome
6+
-//dotnet/test/common:TakesScreenshotTest-chrome
7+
-//dotnet/test/common:TakesScreenshotTest-firefox
8+
-//dotnet/test/common:VirtualAuthn/VirtualAuthenticatorTest-chrome
9+
-//dotnet/test/support/UI:SelectBrowserTests-firefox
10+
-//dotnet/test/support/UI:SmallTests
111
-//java/test/org/openqa/selenium:FormHandlingTest-chrome
212
-//java/test/org/openqa/selenium/bidi:BiDiSessionTest-remote
313
-//java/test/org/openqa/selenium/bidi:BiDiTest-remote

WORKSPACE

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,41 @@ load("@maven//:defs.bzl", "pinned_maven_install")
166166
pinned_maven_install()
167167

168168
http_archive(
169-
name = "d2l_rules_csharp",
170-
sha256 = "c0152befb1fd0e08527b38e41ef00b6627f9f0c2be6f2d23a4950f41701fa48a",
171-
strip_prefix = "rules_csharp-50e2f6c79e7a53e50b4518239b5ebcc61279759e",
172-
urls = [
173-
"https://github.com/Brightspace/rules_csharp/archive/50e2f6c79e7a53e50b4518239b5ebcc61279759e.tar.gz",
169+
name = "rules_dotnet",
170+
patch_args = ["-p1"],
171+
patches = [
172+
"//dotnet:0001-Include-more-of-the-SDK.patch",
173+
"//dotnet:0002-Pass-through-information-about-location-of-the-nupkg.patch",
174+
"//dotnet:0003-Make-Runfiles-library-compatible-with-net-standard-2-0.patch",
175+
"//dotnet:0004-Ensure-data-runfiles-are-added-to-tests.patch",
176+
"//dotnet:0005-Ensure-csharp_library-files-are-unique.patch",
174177
],
178+
sha256 = "f445400dac566eed9d7895aa0fb168a5453a07e5128dc1c4852cd9c537e0ca60",
179+
strip_prefix = "rules_dotnet-0.10.7",
180+
url = "https://github.com/bazelbuild/rules_dotnet/releases/download/v0.10.7/rules_dotnet-v0.10.7.tar.gz",
181+
)
182+
183+
load(
184+
"@rules_dotnet//dotnet:repositories.bzl",
185+
"dotnet_register_toolchains",
186+
"rules_dotnet_dependencies",
175187
)
176188

177-
load("//dotnet:workspace.bzl", "selenium_register_dotnet")
189+
rules_dotnet_dependencies()
190+
191+
dotnet_register_toolchains("dotnet", "7.0.400")
192+
193+
load("@rules_dotnet//dotnet:rules_dotnet_nuget_packages.bzl", "rules_dotnet_nuget_packages")
194+
195+
rules_dotnet_nuget_packages()
196+
197+
load("@rules_dotnet//dotnet:paket2bazel_dependencies.bzl", "paket2bazel_dependencies")
198+
199+
paket2bazel_dependencies()
200+
201+
load("//dotnet:paket.bzl", "paket")
178202

179-
selenium_register_dotnet()
203+
paket()
180204

181205
http_archive(
182206
name = "rules_rust",

dotnet/.config/dotnet-tools.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"paket": {
6+
"version": "7.2.1",
7+
"commands": [
8+
"paket"
9+
]
10+
},
11+
"aver": {
12+
"version": "1.0.2",
13+
"commands": [
14+
"aver"
15+
]
16+
}
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
dotnet/repositories.bzl | 6 ++----
2+
1 file changed, 2 insertions(+), 4 deletions(-)
3+
4+
diff --git a/dotnet/repositories.bzl b/dotnet/repositories.bzl
5+
index 988559e..cf8fd6d 100644
6+
--- a/dotnet/repositories.bzl
7+
+++ b/dotnet/repositories.bzl
8+
@@ -83,9 +83,7 @@ filegroup(
9+
}}),
10+
data = glob([
11+
"host/**/*",
12+
- "sdk/**/*.dll",
13+
- "sdk/**/dotnet.runtimeconfig.json",
14+
- "sdk/**/dotnet.deps.json",
15+
+ "sdk/**/*",
16+
"shared/Microsoft.NETCore.App/**/*",
17+
]),
18+
visibility = ["//visibility:public"],
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
diff --git a/dotnet/private/providers.bzl b/dotnet/private/providers.bzl
2+
index df00a25..0b06638 100644
3+
--- a/dotnet/private/providers.bzl
4+
+++ b/dotnet/private/providers.bzl
5+
@@ -44,6 +44,7 @@ NuGetInfo = provider(
6+
fields = {
7+
"targeting_pack_overrides": "map[string, string]: Targeting packs like e.g. Microsoft.NETCore.App.Ref have a PackageOverride.txt that includes a list of NuGet packages that should be omitted in a compiliation because they are included in the targeting pack",
8+
"sha512": "string: the SHA512 SRI string for the package",
9+
+ "nupkg": "File: the underlying `.nupkg` file which provides this package",
10+
},
11+
)
12+
13+
diff --git a/dotnet/private/rules/nuget/imports.bzl b/dotnet/private/rules/nuget/imports.bzl
14+
index a41bc70..79ebc94 100644
15+
--- a/dotnet/private/rules/nuget/imports.bzl
16+
+++ b/dotnet/private/rules/nuget/imports.bzl
17+
@@ -59,6 +59,7 @@ def _import_library(ctx):
18+
), NuGetInfo(
19+
targeting_pack_overrides = ctx.attr.targeting_pack_overrides,
20+
sha512 = ctx.attr.sha512,
21+
+ nupkg = ctx.file.nupkg,
22+
)]
23+
24+
import_library = rule(
25+
@@ -107,6 +108,10 @@ import_library = rule(
26+
"sha512": attr.string(
27+
doc = "The SHA512 sum of the NuGet package",
28+
),
29+
+ "nupkg": attr.label(
30+
+ doc = "The `.nupkg` file providing this import",
31+
+ allow_single_file = True,
32+
+ ),
33+
},
34+
toolchains = [
35+
"@rules_dotnet//dotnet:toolchain_type",
36+
diff --git a/dotnet/private/rules/nuget/nuget_archive.bzl b/dotnet/private/rules/nuget/nuget_archive.bzl
37+
index 38a9473..683abdd 100644
38+
--- a/dotnet/private/rules/nuget/nuget_archive.bzl
39+
+++ b/dotnet/private/rules/nuget/nuget_archive.bzl
40+
@@ -19,6 +19,8 @@ load(
41+
"RUNTIME_GRAPH",
42+
)
43+
44+
+GLOBAL_NUGET_PREFIX = "nuget"
45+
+
46+
def _is_windows(repository_ctx):
47+
"""Returns true if the host operating system is windows."""
48+
os_name = repository_ctx.os.name.lower()
49+
@@ -321,7 +323,17 @@ def _nuget_archive_impl(ctx):
50+
51+
# Then get the auth dict for the package base urls
52+
auth = _get_auth_dict(ctx, ctx.attr.netrc, urls)
53+
- ctx.download_and_extract(urls, type = "zip", integrity = ctx.attr.sha512, auth = auth)
54+
+ file_name = "%s.zip" % ctx.name
55+
+ nupkg_name = "%s.%s.nupkg" % (ctx.attr.id, ctx.attr.version)
56+
+ names = [nupkg_name]
57+
+ if nupkg_name.startswith(GLOBAL_NUGET_PREFIX):
58+
+ nupkg_name = nupkg_name[len(GLOBAL_NUGET_PREFIX) + 1:]
59+
+ names.append(nupkg_name)
60+
+
61+
+ ctx.download(urls, output = file_name, integrity = ctx.attr.sha512, auth = auth)
62+
+ ctx.extract(archive = file_name)
63+
+ for name in names:
64+
+ ctx.symlink(file_name, name)
65+
66+
files = _read_dir(ctx, ".").replace(str(ctx.path(".")) + "/", "").splitlines()
67+
68+
@@ -447,6 +459,7 @@ load("@rules_dotnet//dotnet/private/rules/nuget:nuget_archive.bzl", "tfm_filegro
69+
"filegroup(name = \"data\", srcs = [])",
70+
_create_rid_native_select("native", native) or "filegroup(name = \"native\", srcs = [])",
71+
"filegroup(name = \"content_files\", srcs = [%s])" % ",".join(["\n \"%s\"" % a for a in groups.get("contentFiles")["any"]]),
72+
+ "exports_files([\"%s\"])" % nupkg_name,
73+
]))
74+
75+
nuget_archive = repository_rule(
76+
diff --git a/dotnet/private/rules/nuget/nuget_repo.bzl b/dotnet/private/rules/nuget/nuget_repo.bzl
77+
index 77c2a67..c5cc56d 100644
78+
--- a/dotnet/private/rules/nuget/nuget_repo.bzl
79+
+++ b/dotnet/private/rules/nuget/nuget_repo.bzl
80+
@@ -1,9 +1,7 @@
81+
"NuGet Repo"
82+
83+
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
84+
-load("@rules_dotnet//dotnet/private/rules/nuget:nuget_archive.bzl", "nuget_archive")
85+
-
86+
-_GLOBAL_NUGET_PREFIX = "nuget"
87+
+load("@rules_dotnet//dotnet/private/rules/nuget:nuget_archive.bzl", "GLOBAL_NUGET_PREFIX", "nuget_archive")
88+
89+
def _nuget_repo_impl(ctx):
90+
for package in ctx.attr.packages:
91+
@@ -22,8 +20,15 @@ def _nuget_repo_impl(ctx):
92+
targeting_pack_overrides = ctx.attr.targeting_pack_overrides[name.lower()]
93+
template = Label("@rules_dotnet//dotnet/private/rules/nuget:template.BUILD")
94+
95+
+ nupkg_path = "@{PREFIX}.{NAME_LOWER}.v{VERSION}//:{NAME_LOWER}.{VERSION}.nupkg".format(
96+
+ PREFIX = GLOBAL_NUGET_PREFIX,
97+
+ NAME = name,
98+
+ NAME_LOWER = name.lower(),
99+
+ VERSION = version,
100+
+ )
101+
+
102+
ctx.template("{}/{}/BUILD.bazel".format(name.lower(), version), template, {
103+
- "{PREFIX}": _GLOBAL_NUGET_PREFIX,
104+
+ "{PREFIX}": GLOBAL_NUGET_PREFIX,
105+
"{NAME}": name,
106+
"{NAME_LOWER}": name.lower(),
107+
"{VERSION}": version,
108+
@@ -36,7 +41,7 @@ def _nuget_repo_impl(ctx):
109+
ctx.file("{}/BUILD.bazel".format(name.lower()), r"""package(default_visibility = ["//visibility:public"])
110+
alias(name = "{name}", actual = "//{name}/{version}")
111+
alias(name = "content_files", actual = "@{prefix}.{name}.v{version}//:content_files")
112+
-""".format(prefix = _GLOBAL_NUGET_PREFIX, name = name.lower(), version = version))
113+
+""".format(prefix = GLOBAL_NUGET_PREFIX, name = name.lower(), version = version))
114+
115+
_nuget_repo = repository_rule(
116+
_nuget_repo_impl,
117+
@@ -63,7 +68,7 @@ def nuget_repo(name, packages):
118+
# maybe another nuget_repo has the same nuget package dependency
119+
maybe(
120+
nuget_archive,
121+
- name = "{}.{}.v{}".format(_GLOBAL_NUGET_PREFIX, package_name, version),
122+
+ name = "{}.{}.v{}".format(GLOBAL_NUGET_PREFIX, package_name, version),
123+
sources = package["sources"],
124+
netrc = package.get("netrc", None),
125+
id = package_name,
126+
diff --git a/dotnet/private/rules/nuget/template.BUILD b/dotnet/private/rules/nuget/template.BUILD
127+
index 783f025..b62bce2 100644
128+
--- a/dotnet/private/rules/nuget/template.BUILD
129+
+++ b/dotnet/private/rules/nuget/template.BUILD
130+
@@ -16,4 +16,5 @@ import_library(
131+
deps = select({
132+
{DEPS},
133+
}),
134+
+ nupkg = "@{PREFIX}.{NAME_LOWER}.v{VERSION}//:{NAME_LOWER}.{VERSION}.nupkg"
135+
)

0 commit comments

Comments
 (0)