Skip to content

Commit

Permalink
Update .NET CDP generation to be more flexible for future versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed Dec 4, 2020
1 parent 9492ee6 commit b0c5514
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 46 deletions.
22 changes: 18 additions & 4 deletions dotnet/private/generate_devtools.bzl
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
def _generate_devtools_impl(ctx):
outdir = ctx.actions.declare_directory("{}".format(ctx.attr.out))
settings_template_file = ctx.actions.declare_file("generator_settings_{}.json".format(ctx.attr.protocol_version))

ctx.actions.expand_template(
template = ctx.attr._generator_settings_template.files.to_list()[0],
output = settings_template_file,
substitutions = {
"{DEVTOOLS_VERSION}": ctx.attr.protocol_version.upper(),
},
)

args = ctx.actions.args()
args.add_all("-s", [ctx.attr.src.files.to_list()[0]])
args.add_all("-s", [settings_template_file])
args.add_all("-b", [ctx.attr.browser_protocol.files.to_list()[0]])
args.add_all("-j", [ctx.attr.js_protocol.files.to_list()[0]])
args.add_all("-t", [ctx.attr.template.files.to_list()[0]])
Expand All @@ -17,7 +26,7 @@ def _generate_devtools_impl(ctx):
outdir,
],
inputs = [
ctx.file.src,
settings_template_file,
ctx.file.browser_protocol,
ctx.file.js_protocol,
ctx.file.template,
Expand All @@ -32,8 +41,9 @@ def _generate_devtools_impl(ctx):
generate_devtools = rule(
implementation = _generate_devtools_impl,
attrs = {
"src": attr.label(
allow_single_file = True,
"protocol_version": attr.string(
mandatory = True,
default = "",
),
"browser_protocol": attr.label(
allow_single_file = True,
Expand All @@ -53,5 +63,9 @@ generate_devtools = rule(
cfg = "exec",
),
"deps": attr.label_list(),
"_generator_settings_template": attr.label(
default = Label("//third_party/dotnet/devtools:generator_settings_template.json"),
allow_single_file = True,
),
},
)
5 changes: 1 addition & 4 deletions dotnet/src/webdriver/WebDriver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@
</ItemGroup>

<ItemGroup>
<Compile Include="..\..\..\bazel-bin\dotnet\src\webdriver\cdp\v84\**\*.cs" LinkBase="DevTools\generated\v84" />
<Compile Include="..\..\..\bazel-bin\dotnet\src\webdriver\cdp\v85\**\*.cs" LinkBase="DevTools\generated\v85" />
<Compile Include="..\..\..\bazel-bin\dotnet\src\webdriver\cdp\v86\**\*.cs" LinkBase="DevTools\generated\v86" />
<Compile Include="..\..\..\bazel-bin\dotnet\src\webdriver\cdp\v87\**\*.cs" LinkBase="DevTools\generated\v87" />
<Compile Include="..\..\..\bazel-bin\dotnet\src\webdriver\cdp\**\*.cs" LinkBase="DevTools\generated" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/cdp/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load("//dotnet:selenium-dotnet-version.bzl", "SUPPORTED_DEVTOOLS_VERSIONS")

[generate_devtools(
name = "generate-{}".format(devtools_version),
src = "{}/generator_settings.json".format(devtools_version),
protocol_version = "{}".format(devtools_version),
out = "{}".format(devtools_version),
browser_protocol = "//common/devtools/chromium/{}:browser_protocol".format(devtools_version),
js_protocol = "//common/devtools/chromium/{}:js_protocol".format(devtools_version),
Expand Down
11 changes: 0 additions & 11 deletions dotnet/src/webdriver/cdp/v85/generator_settings.json

This file was deleted.

11 changes: 0 additions & 11 deletions dotnet/src/webdriver/cdp/v86/generator_settings.json

This file was deleted.

11 changes: 0 additions & 11 deletions dotnet/src/webdriver/cdp/v87/generator_settings.json

This file was deleted.

4 changes: 1 addition & 3 deletions third_party/dotnet/devtools/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
exports_files([
"settings.v84.json",
"settings.v85.json",
"settings.v86.json"
"generator_settings_template.json",
])
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"outputPath": "DevToolsSessionDomains.cs"
}
],
"rootNamespace": "OpenQA.Selenium.DevTools.V84",
"rootNamespace": "OpenQA.Selenium.DevTools.{DEVTOOLS_VERSION}",
"runtimeVersion": "",
"includeExperimentalDomains": true
}

0 comments on commit b0c5514

Please sign in to comment.