diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 242fedc6..4d6df9c2 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -6,6 +6,8 @@ tasks: environment: CC: clang build_flags: + - "--host_platform=@io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_6.0.101" + - "--platforms=@io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_6.0.101" - "--cxxopt=-std=c++17" - "--host_cxxopt=-std=c++17" build_targets: @@ -26,6 +28,8 @@ tasks: - "//scala/..." test_flags: - "--test_output=errors" + - "--host_platform=@io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_6.0.101" + - "--platforms=@io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_6.0.101" - "--cxxopt=-std=c++17" - "--host_cxxopt=-std=c++17" test_targets: @@ -105,6 +109,8 @@ tasks: environment: CC: clang build_flags: + - "--host_platform=@io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_6.0.101" + - "--platforms=@io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_6.0.101" - "--cxxopt=-std=c++17" - "--host_cxxopt=-std=c++17" build_targets: @@ -126,6 +132,8 @@ tasks: - "//swift/..." test_flags: - "--test_output=errors" + - "--host_platform=@io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_6.0.101" + - "--platforms=@io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_6.0.101" - "--cxxopt=-std=c++17" - "--host_cxxopt=-std=c++17" test_targets: @@ -287,6 +295,8 @@ tasks: shell_commands: - set -x - export CC=clang + - export BAZEL_EXTRA_FLAGS="--host_platform=@io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_6.0.101 $BAZEL_EXTRA_FLAGS" + - export BAZEL_EXTRA_FLAGS="--platforms=@io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_6.0.101 $BAZEL_EXTRA_FLAGS" - make csharp_csharp_proto_compile_example - make csharp_csharp_grpc_compile_example - make csharp_csharp_proto_library_example @@ -298,6 +308,8 @@ tasks: shell_commands: - set -x - export CC=clang + - export BAZEL_EXTRA_FLAGS="--host_platform=@io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_6.0.101 $BAZEL_EXTRA_FLAGS" + - export BAZEL_EXTRA_FLAGS="--platforms=@io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_6.0.101 $BAZEL_EXTRA_FLAGS" - make csharp_csharp_proto_compile_example - make csharp_csharp_grpc_compile_example - make csharp_csharp_proto_library_example @@ -342,6 +354,8 @@ tasks: shell_commands: - set -x - export CC=clang + - export BAZEL_EXTRA_FLAGS="--host_platform=@io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_6.0.101 $BAZEL_EXTRA_FLAGS" + - export BAZEL_EXTRA_FLAGS="--platforms=@io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_6.0.101 $BAZEL_EXTRA_FLAGS" - make fsharp_fsharp_proto_compile_example - make fsharp_fsharp_grpc_compile_example - make fsharp_fsharp_proto_library_example @@ -353,6 +367,8 @@ tasks: shell_commands: - set -x - export CC=clang + - export BAZEL_EXTRA_FLAGS="--host_platform=@io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_6.0.101 $BAZEL_EXTRA_FLAGS" + - export BAZEL_EXTRA_FLAGS="--platforms=@io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_6.0.101 $BAZEL_EXTRA_FLAGS" - make fsharp_fsharp_proto_compile_example - make fsharp_fsharp_grpc_compile_example - make fsharp_fsharp_proto_library_example diff --git a/csharp/csharp_grpc_library.bzl b/csharp/csharp_grpc_library.bzl index 4007c1c2..3ed138e9 100644 --- a/csharp/csharp_grpc_library.bzl +++ b/csharp/csharp_grpc_library.bzl @@ -2,7 +2,7 @@ load("//csharp:csharp_grpc_compile.bzl", "csharp_grpc_compile") load("//:defs.bzl", "bazel_build_rule_common_attrs", "proto_compile_attrs") -load("@rules_dotnet//dotnet:defs.bzl", "csharp_library") +load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "csharp_library") def csharp_grpc_library(name, **kwargs): # Compile protos diff --git a/csharp/csharp_proto_library.bzl b/csharp/csharp_proto_library.bzl index 31a49bae..553f39d0 100644 --- a/csharp/csharp_proto_library.bzl +++ b/csharp/csharp_proto_library.bzl @@ -2,7 +2,7 @@ load("//csharp:csharp_proto_compile.bzl", "csharp_proto_compile") load("//:defs.bzl", "bazel_build_rule_common_attrs", "proto_compile_attrs") -load("@rules_dotnet//dotnet:defs.bzl", "csharp_library") +load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "csharp_library") def csharp_proto_library(name, **kwargs): # Compile protos diff --git a/csharp/example/routeguide/BUILD.bazel b/csharp/example/routeguide/BUILD.bazel index 3ef67c3c..2a6dfafb 100644 --- a/csharp/example/routeguide/BUILD.bazel +++ b/csharp/example/routeguide/BUILD.bazel @@ -1,5 +1,5 @@ load("//csharp:defs.bzl", "csharp_grpc_library") -load("@rules_dotnet//dotnet:defs.bzl", "csharp_binary", "csharp_library") +load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "csharp_binary", "csharp_library") csharp_grpc_library( name = "routeguide.dll", diff --git a/csharp/repositories.bzl b/csharp/repositories.bzl index e6c75886..6167744a 100644 --- a/csharp/repositories.bzl +++ b/csharp/repositories.bzl @@ -2,10 +2,10 @@ load( "//:repositories.bzl", - "rules_dotnet", + "io_bazel_rules_dotnet", "rules_proto_grpc_repos", ) def csharp_repos(**kwargs): # buildifier: disable=function-docstring rules_proto_grpc_repos(**kwargs) - rules_dotnet(**kwargs) + io_bazel_rules_dotnet(**kwargs) diff --git a/tools/rulegen/csharp.go b/tools/rulegen/csharp.go index fa97f933..d964b948 100644 --- a/tools/rulegen/csharp.go +++ b/tools/rulegen/csharp.go @@ -49,7 +49,7 @@ nuget_rules_proto_grpc_packages()`) var csharpLibraryRuleTemplateString = `load("//{{ .Lang.Dir }}:{{ .Lang.Name }}_{{ .Rule.Kind }}_compile.bzl", "{{ .Lang.Name }}_{{ .Rule.Kind }}_compile") load("//:defs.bzl", "bazel_build_rule_common_attrs", "proto_compile_attrs") -load("@rules_dotnet//dotnet:defs.bzl", "csharp_library") +load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "csharp_library") def {{ .Rule.Name }}(name, **kwargs): # Compile protos diff --git a/tools/rulegen/main.go b/tools/rulegen/main.go index 1129344b..0d21b985 100644 --- a/tools/rulegen/main.go +++ b/tools/rulegen/main.go @@ -22,10 +22,21 @@ var ciPlatformsMap = map[string][]string{ "macos": []string{"macos"}, } -var extraPlatformFlags = map[string][]string{ - "ubuntu2204": []string{}, - "windows": []string{}, - "macos": []string{}, +// https://github.com/bazelbuild/rules_dotnet/issues/225 +// TODO: Remove if becomes unnecessary +var dotnetPlatformFlags = map[string][]string{ + "ubuntu2204": []string{ + "--host_platform=@io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_6.0.101", + "--platforms=@io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_6.0.101", + }, + "windows": []string{ + "--host_platform=@io_bazel_rules_dotnet//dotnet/toolchain:windows_amd64_6.0.101", + "--platforms=@io_bazel_rules_dotnet//dotnet/toolchain:windows_amd64_6.0.101", + }, + "macos": []string{ + "--host_platform=@io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_6.0.101", + "--platforms=@io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_6.0.101", + }, } func main() { @@ -471,7 +482,7 @@ func mustWriteBazelCIPresubmitYml(dir string, languages []*Language, availableTe out.w(" environment:") out.w(` CC: clang`) out.w(" build_flags:") - for _, flag := range extraPlatformFlags[ciPlatform] { + for _, flag := range dotnetPlatformFlags[ciPlatform] { out.w(` - "%s"`, flag) } out.w(` - "--cxxopt=-std=c++17"`) @@ -485,7 +496,7 @@ func mustWriteBazelCIPresubmitYml(dir string, languages []*Language, availableTe } out.w(" test_flags:") out.w(` - "--test_output=errors"`) - for _, flag := range extraPlatformFlags[ciPlatform] { + for _, flag := range dotnetPlatformFlags[ciPlatform] { out.w(` - "%s"`, flag) } out.w(` - "--cxxopt=-std=c++17"`) @@ -534,7 +545,7 @@ func mustWriteBazelCIPresubmitYml(dir string, languages []*Language, availableTe out.w(" - set -x") out.w(" - export CC=clang") if lang.Name == "csharp" || lang.Name == "fsharp" { - for _, flag := range extraPlatformFlags[ciPlatform] { + for _, flag := range dotnetPlatformFlags[ciPlatform] { out.w(` - export BAZEL_EXTRA_FLAGS="%s $BAZEL_EXTRA_FLAGS"`, flag) } }