Skip to content

Commit

Permalink
Update bazel build to use new naming convention (#471)
Browse files Browse the repository at this point in the history
* update the bazel build

Signed-off-by: Tanya Bouman <tanyabouman@gmail.com>

* add alias for validate to validate_go

Signed-off-by: Tanya Bouman <tanyabouman@gmail.com>

* add deprecation notices for go_default_library aliases

Signed-off-by: Tanya Bouman <tanyabouman@gmail.com>

Co-authored-by: Alex Konradi <akonradi@google.com>
  • Loading branch information
tanyabouman and akonradi authored Jun 10, 2021
1 parent d9cbdb5 commit 4f41f10
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 54 deletions.
13 changes: 8 additions & 5 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,26 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

# gazelle:prefix github.com/envoyproxy/protoc-gen-validate
# gazelle:exclude tests
# gazelle:exclude example-workspace
# gazelle:exclude validate/validate.h
# gazelle:go_naming_convention import_alias
gazelle(name = "gazelle")

go_binary(
name = "protoc-gen-validate",
embed = [":go_default_library"],
embed = [":protoc-gen-validate_lib"],
importpath = "github.com/envoyproxy/protoc-gen-validate",
visibility = ["//visibility:public"],
)

go_library(
name = "go_default_library",
name = "protoc-gen-validate_lib",
srcs = ["main.go"],
importpath = "github.com/envoyproxy/protoc-gen-validate",
visibility = ["//visibility:private"],
deps = [
"//module:go_default_library",
"@com_github_lyft_protoc_gen_star//:go_default_library",
"@com_github_lyft_protoc_gen_star//lang/go:go_default_library",
"//module",
"@com_github_lyft_protoc_gen_star//:protoc-gen-star",
"@com_github_lyft_protoc_gen_star//lang/go",
],
)
4 changes: 2 additions & 2 deletions dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def go_third_party():
go_repository(
name = "com_github_lyft_protoc_gen_star",
importpath = "github.com/lyft/protoc-gen-star",
sum = "h1:sImehRT+p7lW9n6R7MQc5hVgzWGEkDVZU4AsBQ4Isu8=",
version = "v0.5.1",
sum = "h1:zSGLzsUew8RT+ZKPHc3jnf8XLaVyHzTcAFBzHtCNR20=",
version = "v0.5.3",
)
go_repository(
name = "com_github_pkg_errors",
Expand Down
11 changes: 9 additions & 2 deletions java/pgv-java-grpc/src/test/proto/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@ go_proto_library(
importpath = "github.com/envoyproxy/protoc-gen-validate/java/pgv-java-grpc/src/test/proto",
proto = ":io_envoyproxy_pgv_grpc_proto",
visibility = ["//visibility:public"],
deps = ["//validate:go_default_library"],
deps = ["//validate"],
)

go_library(
name = "go_default_library",
name = "proto",
embed = [":io_envoyproxy_pgv_grpc_go_proto"],
importpath = "github.com/envoyproxy/protoc-gen-validate/java/pgv-java-grpc/src/test/proto",
visibility = ["//visibility:public"],
)

alias(
name = "go_default_library",
actual = ":proto",
deprecation = "Use :proto instead of :go_default_library. Details about the new naming convention: https://github.com/bazelbuild/bazel-gazelle/pull/863",
visibility = ["//visibility:public"],
)
25 changes: 16 additions & 9 deletions module/BUILD
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
name = "module",
srcs = [
"checker.go",
"validate.go",
],
importpath = "github.com/envoyproxy/protoc-gen-validate/module",
visibility = ["//visibility:public"],
deps = [
"//templates:go_default_library",
"//templates/java:go_default_library",
"//validate:go_default_library", # keep
"@com_github_lyft_protoc_gen_star//:go_default_library",
"@com_github_lyft_protoc_gen_star//lang/go:go_default_library",
"@org_golang_google_protobuf//proto:go_default_library",
"@org_golang_google_protobuf//types/known/durationpb:go_default_library",
"@org_golang_google_protobuf//types/known/timestamppb:go_default_library",
"//templates",
"//templates/java",
"//validate",
"@com_github_lyft_protoc_gen_star//:protoc-gen-star",
"@com_github_lyft_protoc_gen_star//lang/go",
"@org_golang_google_protobuf//proto",
"@org_golang_google_protobuf//types/known/durationpb",
"@org_golang_google_protobuf//types/known/timestamppb",
],
)

alias(
name = "go_default_library",
actual = ":module",
deprecation = "Use :module instead of :go_default_library. Details about the new naming convention: https://github.com/bazelbuild/bazel-gazelle/pull/863",
visibility = ["//visibility:public"],
)
21 changes: 14 additions & 7 deletions templates/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
name = "templates",
srcs = ["pkg.go"],
importpath = "github.com/envoyproxy/protoc-gen-validate/templates",
visibility = ["//visibility:public"],
deps = [
"//templates/cc:go_default_library",
"//templates/go:go_default_library",
"//templates/java:go_default_library",
"//templates/shared:go_default_library",
"@com_github_lyft_protoc_gen_star//:go_default_library",
"@com_github_lyft_protoc_gen_star//lang/go:go_default_library",
"//templates/cc",
"//templates/go",
"//templates/java",
"//templates/shared",
"@com_github_lyft_protoc_gen_star//:protoc-gen-star",
"@com_github_lyft_protoc_gen_star//lang/go",
],
)

alias(
name = "go_default_library",
actual = ":templates",
deprecation = "Use :templates instead of :go_default_library. Details about the new naming convention: https://github.com/bazelbuild/bazel-gazelle/pull/863",
visibility = ["//visibility:public"],
)
21 changes: 14 additions & 7 deletions templates/cc/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
name = "cc",
srcs = [
"any.go",
"bytes.go",
Expand All @@ -26,11 +26,18 @@ go_library(
importpath = "github.com/envoyproxy/protoc-gen-validate/templates/cc",
visibility = ["//visibility:public"],
deps = [
"//templates/shared:go_default_library",
"@com_github_iancoleman_strcase//:go_default_library",
"@com_github_lyft_protoc_gen_star//:go_default_library",
"@com_github_lyft_protoc_gen_star//lang/go:go_default_library",
"@org_golang_google_protobuf//types/known/durationpb:go_default_library",
"@org_golang_google_protobuf//types/known/timestamppb:go_default_library",
"//templates/shared",
"@com_github_iancoleman_strcase//:strcase",
"@com_github_lyft_protoc_gen_star//:protoc-gen-star",
"@com_github_lyft_protoc_gen_star//lang/go",
"@org_golang_google_protobuf//types/known/durationpb",
"@org_golang_google_protobuf//types/known/timestamppb",
],
)

alias(
name = "go_default_library",
actual = ":cc",
deprecation = "Use :cc instead of :go_default_library. Details about the new naming convention: https://github.com/bazelbuild/bazel-gazelle/pull/863",
visibility = ["//visibility:public"],
)
13 changes: 10 additions & 3 deletions templates/go/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
name = "go",
srcs = [
"duration.go",
"file.go",
Expand All @@ -13,7 +13,14 @@ go_library(
importpath = "github.com/envoyproxy/protoc-gen-validate/templates/go",
visibility = ["//visibility:public"],
deps = [
"//templates/goshared:go_default_library",
"@com_github_lyft_protoc_gen_star//:go_default_library",
"//templates/goshared",
"@com_github_lyft_protoc_gen_star//:protoc-gen-star",
],
)

alias(
name = "go_default_library",
actual = ":go",
deprecation = "Use :go instead of :go_default_library. Details about the new naming convention: https://github.com/bazelbuild/bazel-gazelle/pull/863",
visibility = ["//visibility:public"],
)
21 changes: 14 additions & 7 deletions templates/goshared/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
name = "goshared",
srcs = [
"any.go",
"bytes.go",
Expand All @@ -24,11 +24,18 @@ go_library(
importpath = "github.com/envoyproxy/protoc-gen-validate/templates/goshared",
visibility = ["//visibility:public"],
deps = [
"//templates/shared:go_default_library",
"@com_github_iancoleman_strcase//:go_default_library",
"@com_github_lyft_protoc_gen_star//:go_default_library",
"@com_github_lyft_protoc_gen_star//lang/go:go_default_library",
"@org_golang_google_protobuf//types/known/durationpb:go_default_library",
"@org_golang_google_protobuf//types/known/timestamppb:go_default_library",
"//templates/shared",
"@com_github_iancoleman_strcase//:strcase",
"@com_github_lyft_protoc_gen_star//:protoc-gen-star",
"@com_github_lyft_protoc_gen_star//lang/go",
"@org_golang_google_protobuf//types/known/durationpb",
"@org_golang_google_protobuf//types/known/timestamppb",
],
)

alias(
name = "go_default_library",
actual = ":goshared",
deprecation = "Use :goshared instead of :go_default_library. Details about the new naming convention: https://github.com/bazelbuild/bazel-gazelle/pull/863",
visibility = ["//visibility:public"],
)
21 changes: 14 additions & 7 deletions templates/java/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
name = "java",
srcs = [
"any.go",
"bool.go",
Expand All @@ -26,11 +26,18 @@ go_library(
importpath = "github.com/envoyproxy/protoc-gen-validate/templates/java",
visibility = ["//visibility:public"],
deps = [
"//templates/shared:go_default_library",
"@com_github_iancoleman_strcase//:go_default_library",
"@com_github_lyft_protoc_gen_star//:go_default_library",
"@com_github_lyft_protoc_gen_star//lang/go:go_default_library",
"@org_golang_google_protobuf//types/known/durationpb:go_default_library",
"@org_golang_google_protobuf//types/known/timestamppb:go_default_library",
"//templates/shared",
"@com_github_iancoleman_strcase//:strcase",
"@com_github_lyft_protoc_gen_star//:protoc-gen-star",
"@com_github_lyft_protoc_gen_star//lang/go",
"@org_golang_google_protobuf//types/known/durationpb",
"@org_golang_google_protobuf//types/known/timestamppb",
],
)

alias(
name = "go_default_library",
actual = ":java",
deprecation = "Use :java instead of :go_default_library. Details about the new naming convention: https://github.com/bazelbuild/bazel-gazelle/pull/863",
visibility = ["//visibility:public"],
)
15 changes: 11 additions & 4 deletions templates/shared/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
name = "shared",
srcs = [
"context.go",
"disabled.go",
Expand All @@ -12,8 +12,15 @@ go_library(
importpath = "github.com/envoyproxy/protoc-gen-validate/templates/shared",
visibility = ["//visibility:public"],
deps = [
"//validate:go_default_library", # keep
"@com_github_lyft_protoc_gen_star//:go_default_library",
"@org_golang_google_protobuf//proto:go_default_library",
"//validate",
"@com_github_lyft_protoc_gen_star//:protoc-gen-star",
"@org_golang_google_protobuf//proto",
],
)

alias(
name = "go_default_library",
actual = ":shared",
deprecation = "Use :shared instead of :go_default_library. Details about the new naming convention: https://github.com/bazelbuild/bazel-gazelle/pull/863",
visibility = ["//visibility:public"],
)
24 changes: 23 additions & 1 deletion validate/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library")
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library")

package(
default_visibility =
Expand Down Expand Up @@ -31,7 +32,7 @@ py_proto_library(
)

go_proto_library(
name = "go_default_library",
name = "validate_go_proto",
importpath = "github.com/envoyproxy/protoc-gen-validate/validate",
proto = ":validate_proto",
)
Expand All @@ -41,7 +42,28 @@ cc_library(
hdrs = ["validate.h"],
)

go_library(
name = "validate_go",
embed = [":validate_go_proto"],
importpath = "github.com/envoyproxy/protoc-gen-validate/validate",
)

java_proto_library(
name = "validate_java",
deps = [":validate_proto"],
)

alias(
name = "go_default_library",
actual = ":validate_go",
deprecation = "Use :validate instead of :go_default_library. Details about the new naming convention: https://github.com/bazelbuild/bazel-gazelle/pull/863",
visibility = ["//visibility:public"],
)

# this alias allows build files generated with Gazelle in other repositories
# to find validate as an external dependency
alias(
name = "validate",
actual = ":validate_go",
visibility = ["//visibility:public"],
)

0 comments on commit 4f41f10

Please sign in to comment.