Skip to content

Commit ae5ce49

Browse files
authored
Fix breakages with Bazel@HEAD and incompatible flags (#4368)
**What type of PR is this?** Adapt to a Bazel breaking change **What does this PR do? Why is it needed?** The `local_config_platform` repo is no longer available with Bazel@HEAD, so the host constraints have to be loaded from `@platforms//host`. Also prepare the BCR test repo for Bazel@HEAD with `--incompatible_autoload_externally=` by applying buildifier lint fixes. **Which issues(s) does this PR fix?** **Other notes for review**
1 parent 8e7d9cd commit ae5ce49

File tree

25 files changed

+63
-21
lines changed

25 files changed

+63
-21
lines changed

MODULE.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ module(
1010
# conflicting with the real bazel_features repo.
1111
bazel_dep(name = "bazel_features", version = "1.9.1", repo_name = "io_bazel_rules_go_bazel_features")
1212
bazel_dep(name = "bazel_skylib", version = "1.2.0")
13-
bazel_dep(name = "platforms", version = "0.0.10")
13+
bazel_dep(name = "platforms", version = "1.0.0")
1414
bazel_dep(name = "rules_proto", version = "7.0.2")
1515
bazel_dep(name = "protobuf", version = "29.0-rc2.bcr.1", repo_name = "com_google_protobuf")
1616
bazel_dep(name = "rules_shell", version = "0.3.0")
1717

1818
go_sdk = use_extension("//go:extensions.bzl", "go_sdk")
19+
1920
# Don't depend on this repo by name, use toolchains instead.
2021
# See https://github.com/bazel-contrib/rules_go/blob/master/go/toolchains.rst
2122
go_sdk.from_file(

WORKSPACE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ go_register_nogo(
6666
nogo = "@//internal:nogo",
6767
)
6868

69+
# Create the host platform repository transitively required by rules_go.
70+
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
71+
load("@platforms//host:extension.bzl", "host_platform_repo")
72+
73+
maybe(
74+
host_platform_repo,
75+
name = "host_platform",
76+
)
77+
6978
http_archive(
7079
name = "rules_proto",
7180
sha256 = "0e5c64a2599a6e26c6a03d6162242d231ecc0de219534c38cb4402171def21e8",

go/private/repositories.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,10 @@ def go_rules_dependencies(force = False):
280280
wrapper(
281281
http_archive,
282282
name = "platforms",
283-
sha256 = "218efe8ee736d26a3572663b374a253c012b716d8af0c07e842e82f238a0a7ee",
283+
sha256 = "3384eb1c30762704fbe38e440204e114154086c8fc8a8c2e3e28441028c019a8",
284284
urls = [
285-
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz",
286-
"https://github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz",
285+
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/1.0.0/platforms-1.0.0.tar.gz",
286+
"https://github.com/bazelbuild/platforms/releases/download/1.0.0/platforms-1.0.0.tar.gz",
287287
],
288288
)
289289

go/private/rules/go_bin_for_host.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
load("@local_config_platform//:constraints.bzl", "HOST_CONSTRAINTS")
15+
load("@platforms//host:constraints.bzl", "HOST_CONSTRAINTS")
1616
load("//go/private:common.bzl", "GO_TOOLCHAIN")
1717

1818
def _ensure_target_cfg(ctx):

go/tools/bazel_benchmark/WORKSPACE.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ go_rules_dependencies()
1717

1818
go_register_toolchains(go_version = "host")
1919

20+
# Create the host platform repository transitively required by rules_go.
21+
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
22+
load("@platforms//host:extension.bzl", "host_platform_repo")
23+
24+
maybe(
25+
host_platform_repo,
26+
name = "host_platform",
27+
)
28+
2029
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
2130

2231
gazelle_dependencies()

go/tools/bazel_testing/bazel_testing.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,16 @@ go_register_nogo(
543543
{{ end}}
544544
)
545545
{{end}}
546+
547+
# Create the host platform repository transitively required by rules_go.
548+
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
549+
load("@platforms//host:extension.bzl", "host_platform_repo")
550+
551+
maybe(
552+
host_platform_repo,
553+
name = "host_platform",
554+
)
555+
546556
{{.Suffix}}
547557
`))
548558

go/tools/releaser/boilerplate.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,17 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_depe
4141
4242
go_rules_dependencies()
4343
44-
go_register_toolchains(version = "%[3]s")`, version, shasum, goVersion)
44+
go_register_toolchains(version = "%[3]s")
45+
46+
# Create the host platform repository transitively required by rules_go.
47+
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
48+
load("@platforms//host:extension.bzl", "host_platform_repo")
49+
50+
maybe(
51+
host_platform_repo,
52+
name = "host_platform",
53+
)
54+
`, version, shasum, goVersion)
4555
}
4656

4757
func findLatestGoVersion() (v string, err error) {

tests/bcr/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ load(
77
"go_test",
88
"nogo",
99
)
10+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
1011
load("//:transition.bzl", "sdk_transition_test")
1112

1213
nogo(

tests/bcr/MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ local_path_override(
2020

2121
bazel_dep(name = "gazelle", version = "0.33.0")
2222
bazel_dep(name = "protobuf", version = "3.19.6")
23+
bazel_dep(name = "rules_shell", version = "0.4.1")
2324

2425
# Required with --incompatible_enable_proto_toolchain_resolution.
2526
# Avoids building protoc from source, which speeds up CI runs.

tests/bcr/proto/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
load("@my_rules_go//go:def.bzl", "go_test")
22
load("@my_rules_go//proto:def.bzl", "go_grpc_library", "go_proto_library")
3+
load("@protobuf//bazel:proto_library.bzl", "proto_library")
34

45
proto_library(
56
name = "foo_proto",

tests/core/go_proto_aspect/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
21
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
2+
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
33
load(":codegen.bzl", "go_generated_library")
44

55
go_generated_library(

tests/core/go_proto_library/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
12
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
23
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
3-
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
44

55
# Common rules
66
proto_library(

tests/core/go_proto_library_importmap/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
12
load("@io_bazel_rules_go//go:def.bzl", "go_test")
23
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
3-
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
44

55
proto_library(
66
name = "foo_proto",

tests/core/go_proto_library_importpath/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
12
load("@io_bazel_rules_go//go:def.bzl", "go_test")
23
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
3-
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
44

55
# Common rules
66
proto_library(

tests/core/transitive_headers/a/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ go_library(
66
"a.go",
77
"a.s",
88
],
9-
deps = ["//tests/core/transitive_headers/b"],
109
importpath = "github.com/bazelbuild/rules_go/tests/core/transitive_headers/a",
10+
deps = ["//tests/core/transitive_headers/b"],
1111
)

tests/core/transitive_headers/b/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ go_library(
66
"b.go",
77
"b.h",
88
],
9-
deps = ["//tests/core/transitive_headers/c"],
109
importpath = "github.com/bazelbuild/rules_go/tests/core/transitive_headers/b",
1110
visibility = ["//visibility:public"],
11+
deps = ["//tests/core/transitive_headers/c"],
1212
)

tests/integration/googleapis/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
12
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
23
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
3-
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
44

55
proto_library(
66
name = "color_service_proto",

tests/integration/grpc_plugin/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
12
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
23
load("@io_bazel_rules_go//proto:def.bzl", "go_grpc_library")
3-
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
44

55
proto_library(
66
name = "hello_proto",

tests/legacy/examples/proto/dep/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
21
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
2+
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
33

44
proto_library(
55
name = "useful_proto",

tests/legacy/examples/proto/embed/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
12
load("@io_bazel_rules_go//go:def.bzl", "go_library")
23
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
3-
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
44

55
proto_library(
66
name = "embed_proto",

tests/legacy/examples/proto/gogo/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
12
load("@io_bazel_rules_go//go:def.bzl", "go_test")
23
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
3-
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
44

55
proto_library(
66
name = "values_proto",

tests/legacy/examples/proto/gostyle/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
21
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
2+
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
33

44
genrule(
55
name = "copy",

tests/legacy/examples/proto/grpc/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
12
load("@io_bazel_rules_go//go:def.bzl", "go_binary")
23
load("@io_bazel_rules_go//proto:def.bzl", "go_grpc_library", "go_proto_library")
3-
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
44

55
proto_library(
66
name = "my_svc_proto",

tests/legacy/examples/proto/lib/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
21
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
2+
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
33

44
proto_library(
55
name = "lib_proto",

tests/legacy/proto_ignore_go_package_option/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
21
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
2+
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
33

44
proto_library(
55
name = "a_proto",

0 commit comments

Comments
 (0)