Skip to content

Commit b0c5514

Browse files
committed
Update .NET CDP generation to be more flexible for future versions
1 parent 9492ee6 commit b0c5514

File tree

8 files changed

+22
-46
lines changed

8 files changed

+22
-46
lines changed

dotnet/private/generate_devtools.bzl

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
def _generate_devtools_impl(ctx):
22
outdir = ctx.actions.declare_directory("{}".format(ctx.attr.out))
3+
settings_template_file = ctx.actions.declare_file("generator_settings_{}.json".format(ctx.attr.protocol_version))
4+
5+
ctx.actions.expand_template(
6+
template = ctx.attr._generator_settings_template.files.to_list()[0],
7+
output = settings_template_file,
8+
substitutions = {
9+
"{DEVTOOLS_VERSION}": ctx.attr.protocol_version.upper(),
10+
},
11+
)
312

413
args = ctx.actions.args()
5-
args.add_all("-s", [ctx.attr.src.files.to_list()[0]])
14+
args.add_all("-s", [settings_template_file])
615
args.add_all("-b", [ctx.attr.browser_protocol.files.to_list()[0]])
716
args.add_all("-j", [ctx.attr.js_protocol.files.to_list()[0]])
817
args.add_all("-t", [ctx.attr.template.files.to_list()[0]])
@@ -17,7 +26,7 @@ def _generate_devtools_impl(ctx):
1726
outdir,
1827
],
1928
inputs = [
20-
ctx.file.src,
29+
settings_template_file,
2130
ctx.file.browser_protocol,
2231
ctx.file.js_protocol,
2332
ctx.file.template,
@@ -32,8 +41,9 @@ def _generate_devtools_impl(ctx):
3241
generate_devtools = rule(
3342
implementation = _generate_devtools_impl,
3443
attrs = {
35-
"src": attr.label(
36-
allow_single_file = True,
44+
"protocol_version": attr.string(
45+
mandatory = True,
46+
default = "",
3747
),
3848
"browser_protocol": attr.label(
3949
allow_single_file = True,
@@ -53,5 +63,9 @@ generate_devtools = rule(
5363
cfg = "exec",
5464
),
5565
"deps": attr.label_list(),
66+
"_generator_settings_template": attr.label(
67+
default = Label("//third_party/dotnet/devtools:generator_settings_template.json"),
68+
allow_single_file = True,
69+
),
5670
},
5771
)

dotnet/src/webdriver/WebDriver.csproj

+1-4
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@
9595
</ItemGroup>
9696

9797
<ItemGroup>
98-
<Compile Include="..\..\..\bazel-bin\dotnet\src\webdriver\cdp\v84\**\*.cs" LinkBase="DevTools\generated\v84" />
99-
<Compile Include="..\..\..\bazel-bin\dotnet\src\webdriver\cdp\v85\**\*.cs" LinkBase="DevTools\generated\v85" />
100-
<Compile Include="..\..\..\bazel-bin\dotnet\src\webdriver\cdp\v86\**\*.cs" LinkBase="DevTools\generated\v86" />
101-
<Compile Include="..\..\..\bazel-bin\dotnet\src\webdriver\cdp\v87\**\*.cs" LinkBase="DevTools\generated\v87" />
98+
<Compile Include="..\..\..\bazel-bin\dotnet\src\webdriver\cdp\**\*.cs" LinkBase="DevTools\generated" />
10299
</ItemGroup>
103100

104101
<ItemGroup>

dotnet/src/webdriver/cdp/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ load("//dotnet:selenium-dotnet-version.bzl", "SUPPORTED_DEVTOOLS_VERSIONS")
33

44
[generate_devtools(
55
name = "generate-{}".format(devtools_version),
6-
src = "{}/generator_settings.json".format(devtools_version),
6+
protocol_version = "{}".format(devtools_version),
77
out = "{}".format(devtools_version),
88
browser_protocol = "//common/devtools/chromium/{}:browser_protocol".format(devtools_version),
99
js_protocol = "//common/devtools/chromium/{}:js_protocol".format(devtools_version),

dotnet/src/webdriver/cdp/v85/generator_settings.json

-11
This file was deleted.

dotnet/src/webdriver/cdp/v86/generator_settings.json

-11
This file was deleted.

dotnet/src/webdriver/cdp/v87/generator_settings.json

-11
This file was deleted.
+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
exports_files([
2-
"settings.v84.json",
3-
"settings.v85.json",
4-
"settings.v86.json"
2+
"generator_settings_template.json",
53
])

dotnet/src/webdriver/cdp/v84/generator_settings.json renamed to third_party/dotnet/devtools/generator_settings_template.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"outputPath": "DevToolsSessionDomains.cs"
66
}
77
],
8-
"rootNamespace": "OpenQA.Selenium.DevTools.V84",
8+
"rootNamespace": "OpenQA.Selenium.DevTools.{DEVTOOLS_VERSION}",
99
"runtimeVersion": "",
1010
"includeExperimentalDomains": true
1111
}

0 commit comments

Comments
 (0)