Skip to content

Commit ac0a5a8

Browse files
author
Jay Conrod
authored
all: migrate to Gazelle's import_alias naming convention (bazel-contrib#2629)
Rename `go_default_library` targets imported by other repositories to the new names. Leave aliases for the old names. Don't actually upgrade Gazelle yet, since that breaks some brittle tests. Fixes bazel-contrib#2616
1 parent 265b917 commit ac0a5a8

File tree

6 files changed

+52
-12
lines changed

6 files changed

+52
-12
lines changed

.bazelci/presubmit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ platforms:
9494
- "-@go_googleapis//google/rpc:status_proto"
9595
- "-@go_googleapis//google/type:color_go_proto"
9696
- "-@gogo_special_proto//github.com/gogo/protobuf/gogoproto:gogoproto"
97-
- "-//go/tools/bazel:go_default_test"
97+
- "-//go/tools/bazel:bazel_test"
9898
- "-@io_bazel_rules_go//proto:gogofaster_proto"
9999
- "-@io_bazel_rules_go//proto:go_grpc"
100100
- "-@io_bazel_rules_go//proto:go_proto"
@@ -254,7 +254,7 @@ platforms:
254254
test_targets:
255255
- "--"
256256
- "..."
257-
- "-//go/tools/bazel:go_default_test"
257+
- "-//go/tools/bazel:bazel_test"
258258
- "-@org_golang_x_crypto//ed25519:go_default_test"
259259
- "-@org_golang_x_crypto//sha3:go_default_test"
260260
- "-@org_golang_x_net//ipv4:go_default_test"

BUILD.bazel

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ load(
2626
"stdlib",
2727
)
2828

29+
# gazelle:prefix github.com/bazelbuild/rules_go
30+
# gazelle:exclude tests
31+
# gazelle:exclude third_party
32+
# gazelle:exclude go/tools/builders
33+
# gazelle:exclude go/tools/coverdata
34+
# gazelle:exclude go/tools/fetch_repo
35+
# gazelle:exclude go/tools/windows-testrunner
36+
# gazelle:exclude go/tools/testwrapper
37+
# gazelle:go_naming_convention import_alias
38+
39+
# TODO(jayconrod): add a gazelle rule so gazelle can be run automatically.
40+
# It can't go here though, because it would break anything that depends on
41+
# rules_go but not Gazelle, including our own go_bazel_tests.
42+
2943
stdlib(
3044
name = "stdlib",
3145
cgo_context_data = select({

go/tools/bazel/BUILD.bazel

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
22

33
go_library(
4-
name = "go_default_library",
4+
name = "bazel",
55
srcs = [
66
"bazel.go",
77
"runfiles.go",
@@ -11,11 +11,11 @@ go_library(
1111
)
1212

1313
go_test(
14-
name = "go_default_test",
14+
name = "bazel_test",
1515
size = "small",
1616
srcs = ["bazel_test.go"],
1717
data = ["empty.txt"],
18-
embed = [":go_default_library"],
18+
embed = [":bazel"],
1919
)
2020

2121
# Runfiles functionality in this package is tested by //tests/core/runfiles.
@@ -26,3 +26,9 @@ filegroup(
2626
srcs = glob(["**"]),
2727
visibility = ["//visibility:public"],
2828
)
29+
30+
alias(
31+
name = "go_default_library",
32+
actual = ":bazel",
33+
visibility = ["//visibility:public"],
34+
)

go/tools/bazel_benchmark/BUILD.bazel

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
load("@io_bazel_rules_go//go:def.bzl", "go_binary")
1+
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
22

33
go_binary(
44
name = "bazel_benchmark",
5+
embed = [":bazel_benchmark_lib"],
6+
visibility = ["//visibility:public"],
7+
)
8+
9+
go_library(
10+
name = "bazel_benchmark_lib",
511
srcs = ["bazel_benchmark.go"],
12+
importpath = "github.com/bazelbuild/rules_go/go/tools/bazel_benchmark",
13+
visibility = ["//visibility:private"],
614
)

go/tools/bazel_testing/BUILD.bazel

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
load("@io_bazel_rules_go//go:def.bzl", "go_library")
22

33
go_library(
4-
name = "go_default_library",
4+
name = "bazel_testing",
55
srcs = ["bazel_testing.go"],
66
importpath = "github.com/bazelbuild/rules_go/go/tools/bazel_testing",
77
visibility = ["//visibility:public"],
88
deps = [
9-
"//go/tools/bazel:go_default_library",
10-
"//go/tools/internal/txtar:go_default_library",
9+
"//go/tools/bazel",
10+
"//go/tools/internal/txtar",
1111
],
1212
)
1313

@@ -17,3 +17,9 @@ filegroup(
1717
srcs = glob(["**"]),
1818
visibility = ["//visibility:public"],
1919
)
20+
21+
alias(
22+
name = "go_default_library",
23+
actual = ":bazel_testing",
24+
visibility = ["//visibility:public"],
25+
)

go/tools/internal/txtar/BUILD.bazel

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
22

33
go_library(
4-
name = "go_default_library",
4+
name = "txtar",
55
srcs = ["archive.go"],
66
importpath = "github.com/bazelbuild/rules_go/go/tools/internal/txtar",
77
visibility = ["//go/tools:__subpackages__"],
88
)
99

1010
go_test(
11-
name = "go_default_test",
11+
name = "txtar_test",
1212
srcs = ["archive_test.go"],
13-
embed = [":go_default_library"],
13+
embed = [":txtar"],
14+
)
15+
16+
alias(
17+
name = "go_default_library",
18+
actual = ":txtar",
19+
visibility = ["//go/tools:__subpackages__"],
1420
)

0 commit comments

Comments
 (0)