diff --git a/dotnet/merge-assemblies.bzl b/dotnet/merge-assemblies.bzl new file mode 100644 index 0000000000000..0a829d8ee97a2 --- /dev/null +++ b/dotnet/merge-assemblies.bzl @@ -0,0 +1,41 @@ +load("@io_bazel_rules_dotnet//dotnet/private:context.bzl", "dotnet_context") + +def _merged_assembly_impl(ctx): + args = [ + "-v4", + "-xmldocs", + "-internalize", + ] + + if ctx.attr.keyfile != None: + key_path = ctx.expand_location(ctx.attr.keyfile.files.to_list()[0].path) + args.append("-keyfile:{}".format(key_path)) + + args.append("-out={}".format(ctx.outputs.out.path)) + args.append(ctx.attr.src_assembly.files.to_list()[0].path) + for dep in ctx.files.deps: + args.append(ctx.expand_location(dep.path)) + + ctx.actions.run( + executable = ctx.executable.merge_tool, + arguments = args, + inputs = ctx.attr.src_assembly.files, + outputs = [ctx.outputs.out] + ) + +merged_assembly = rule( + implementation = _merged_assembly_impl, + attrs = { + "src_assembly": attr.label(), + "deps": attr.label_list(), + "out": attr.output(mandatory = True), + "keyfile": attr.label(allow_single_file = True), + "merge_tool": attr.label( + executable = True, + cfg = "host", + default = Label("//third_party/dotnet/ilmerge:ilmerge.exe"), + allow_single_file = True + ), + }, + toolchains = ["@io_bazel_rules_dotnet//dotnet:toolchain_net"], +) diff --git a/dotnet/build-rules.bzl b/dotnet/nuget.bzl similarity index 61% rename from dotnet/build-rules.bzl rename to dotnet/nuget.bzl index d9056f2ed0b80..70191adc8de06 100644 --- a/dotnet/build-rules.bzl +++ b/dotnet/nuget.bzl @@ -1,45 +1,5 @@ load("@io_bazel_rules_dotnet//dotnet/private:context.bzl", "dotnet_context") -def _merged_assembly_impl(ctx): - args = [ - "-v4", - "-xmldocs", - "-internalize", - ] - - if ctx.attr.keyfile != None: - key_path = ctx.expand_location(ctx.attr.keyfile.files.to_list()[0].path) - args.append("-keyfile:{}".format(key_path)) - - args.append("-out={}".format(ctx.outputs.out.path)) - args.append(ctx.attr.src_assembly.files.to_list()[0].path) - for dep in ctx.files.deps: - args.append(ctx.expand_location(dep.path)) - - ctx.actions.run( - executable = ctx.executable.merge_tool, - arguments = args, - inputs = ctx.attr.src_assembly.files, - outputs = [ctx.outputs.out] - ) - -merged_assembly = rule( - implementation = _merged_assembly_impl, - attrs = { - "src_assembly": attr.label(), - "deps": attr.label_list(), - "out": attr.output(mandatory = True), - "keyfile": attr.label(allow_single_file = True), - "merge_tool": attr.label( - executable = True, - cfg = "host", - default = Label("//third_party/dotnet/ilmerge:ilmerge.exe"), - allow_single_file = True - ), - }, - toolchains = ["@io_bazel_rules_dotnet//dotnet:toolchain_net"], -) - def _nuget_package_impl(ctx): args = [ "pack", @@ -98,4 +58,4 @@ nuget_package = rule( allow_single_file = True ), } -) \ No newline at end of file +) diff --git a/dotnet/src/support/BUILD.bazel b/dotnet/src/support/BUILD.bazel index 0284cf23a4524..fc07f41843bbd 100644 --- a/dotnet/src/support/BUILD.bazel +++ b/dotnet/src/support/BUILD.bazel @@ -1,5 +1,5 @@ load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "net_library", "core_library", "core_resource") -load("//dotnet:build-rules.bzl", "merged_assembly", "nuget_package") +load("//dotnet:nuget.bzl", "nuget_package") load("//dotnet:selenium-dotnet-version.bzl", "SE_VERSION", "ASSEMBLY_VERSION", diff --git a/dotnet/src/webdriver/BUILD.bazel b/dotnet/src/webdriver/BUILD.bazel index 20b85b6042fa2..73489cc04ae8a 100644 --- a/dotnet/src/webdriver/BUILD.bazel +++ b/dotnet/src/webdriver/BUILD.bazel @@ -1,5 +1,6 @@ load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "net_library", "core_library", "core_resource") -load("//dotnet:build-rules.bzl", "merged_assembly", "nuget_package") +load("//dotnet:merge-assemblies.bzl", "merged_assembly") +load("//dotnet:nuget.bzl", "nuget_package") load("//dotnet:selenium-dotnet-version.bzl", "SE_VERSION", "ASSEMBLY_VERSION", diff --git a/dotnet/src/webdriverbackedselenium/BUILD.bazel b/dotnet/src/webdriverbackedselenium/BUILD.bazel index 1b68fecb94371..49367fcad8d80 100644 --- a/dotnet/src/webdriverbackedselenium/BUILD.bazel +++ b/dotnet/src/webdriverbackedselenium/BUILD.bazel @@ -1,5 +1,5 @@ load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "net_library", "core_library", "core_resource") -load("//dotnet:build-rules.bzl", "nuget_package") +load("//dotnet:nuget.bzl", "nuget_package") load("//dotnet:selenium-dotnet-version.bzl", "SE_VERSION", "ASSEMBLY_VERSION",