diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 94b80b1fc9..6b90848a5d 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -94,7 +94,7 @@ platforms: - "-@go_googleapis//google/rpc:status_proto" - "-@go_googleapis//google/type:color_go_proto" - "-@gogo_special_proto//github.com/gogo/protobuf/gogoproto:gogoproto" - - "-//go/tools/bazel:go_default_test" + - "-//go/tools/bazel:bazel_test" - "-@io_bazel_rules_go//proto:gogofaster_proto" - "-@io_bazel_rules_go//proto:go_grpc" - "-@io_bazel_rules_go//proto:go_proto" @@ -254,7 +254,7 @@ platforms: test_targets: - "--" - "..." - - "-//go/tools/bazel:go_default_test" + - "-//go/tools/bazel:bazel_test" - "-@org_golang_x_crypto//ed25519:go_default_test" - "-@org_golang_x_crypto//sha3:go_default_test" - "-@org_golang_x_net//ipv4:go_default_test" diff --git a/BUILD.bazel b/BUILD.bazel index 40841dfe79..a8d40365c8 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -26,6 +26,20 @@ load( "stdlib", ) +# gazelle:prefix github.com/bazelbuild/rules_go +# gazelle:exclude tests +# gazelle:exclude third_party +# gazelle:exclude go/tools/builders +# gazelle:exclude go/tools/coverdata +# gazelle:exclude go/tools/fetch_repo +# gazelle:exclude go/tools/windows-testrunner +# gazelle:exclude go/tools/testwrapper +# gazelle:go_naming_convention import_alias + +# TODO(jayconrod): add a gazelle rule so gazelle can be run automatically. +# It can't go here though, because it would break anything that depends on +# rules_go but not Gazelle, including our own go_bazel_tests. + stdlib( name = "stdlib", cgo_context_data = select({ diff --git a/go/tools/bazel/BUILD.bazel b/go/tools/bazel/BUILD.bazel index 3ea2561610..1d15ed453a 100644 --- a/go/tools/bazel/BUILD.bazel +++ b/go/tools/bazel/BUILD.bazel @@ -1,7 +1,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( - name = "go_default_library", + name = "bazel", srcs = [ "bazel.go", "runfiles.go", @@ -11,11 +11,11 @@ go_library( ) go_test( - name = "go_default_test", + name = "bazel_test", size = "small", srcs = ["bazel_test.go"], data = ["empty.txt"], - embed = [":go_default_library"], + embed = [":bazel"], ) # Runfiles functionality in this package is tested by //tests/core/runfiles. @@ -26,3 +26,9 @@ filegroup( srcs = glob(["**"]), visibility = ["//visibility:public"], ) + +alias( + name = "go_default_library", + actual = ":bazel", + visibility = ["//visibility:public"], +) diff --git a/go/tools/bazel_benchmark/BUILD.bazel b/go/tools/bazel_benchmark/BUILD.bazel index db6eff7998..7ca2c5ffe0 100644 --- a/go/tools/bazel_benchmark/BUILD.bazel +++ b/go/tools/bazel_benchmark/BUILD.bazel @@ -1,6 +1,14 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary") +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") go_binary( name = "bazel_benchmark", + embed = [":bazel_benchmark_lib"], + visibility = ["//visibility:public"], +) + +go_library( + name = "bazel_benchmark_lib", srcs = ["bazel_benchmark.go"], + importpath = "github.com/bazelbuild/rules_go/go/tools/bazel_benchmark", + visibility = ["//visibility:private"], ) diff --git a/go/tools/bazel_testing/BUILD.bazel b/go/tools/bazel_testing/BUILD.bazel index 54c9e4a43c..f274c66e4f 100644 --- a/go/tools/bazel_testing/BUILD.bazel +++ b/go/tools/bazel_testing/BUILD.bazel @@ -1,13 +1,13 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( - name = "go_default_library", + name = "bazel_testing", srcs = ["bazel_testing.go"], importpath = "github.com/bazelbuild/rules_go/go/tools/bazel_testing", visibility = ["//visibility:public"], deps = [ - "//go/tools/bazel:go_default_library", - "//go/tools/internal/txtar:go_default_library", + "//go/tools/bazel", + "//go/tools/internal/txtar", ], ) @@ -17,3 +17,9 @@ filegroup( srcs = glob(["**"]), visibility = ["//visibility:public"], ) + +alias( + name = "go_default_library", + actual = ":bazel_testing", + visibility = ["//visibility:public"], +) diff --git a/go/tools/internal/txtar/BUILD.bazel b/go/tools/internal/txtar/BUILD.bazel index 24174e109d..2f354c01bb 100644 --- a/go/tools/internal/txtar/BUILD.bazel +++ b/go/tools/internal/txtar/BUILD.bazel @@ -1,14 +1,20 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( - name = "go_default_library", + name = "txtar", srcs = ["archive.go"], importpath = "github.com/bazelbuild/rules_go/go/tools/internal/txtar", visibility = ["//go/tools:__subpackages__"], ) go_test( - name = "go_default_test", + name = "txtar_test", srcs = ["archive_test.go"], - embed = [":go_default_library"], + embed = [":txtar"], +) + +alias( + name = "go_default_library", + actual = ":txtar", + visibility = ["//go/tools:__subpackages__"], )