Fix bazel build after bazel upgrade (#154)

The bazel build was failing due to a variety of deprecation issues.

This imports git_repository and http_archive from @bazel_tools//tools/build_defs/repo:http.bzl. This also required an upgrade to @io_bazel_rules_go, which then breaks @org_pubref_rules_protobuf//go:rules.bzl.

To fix that, this switches to using go_proto_library from @io_bazel_rules_go//proto:def.bzl, which required some changes to the build params.
pull/77/head^2
Dave Raffensperger 6 years ago committed by GitHub
parent b11a674341
commit 654f0722aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/BUILD.bazel
  2. 23
      src/WORKSPACE
  3. 15
      src/opencensus/proto/agent/common/v1/BUILD.bazel
  4. 14
      src/opencensus/proto/agent/metrics/v1/BUILD.bazel
  5. 17
      src/opencensus/proto/agent/trace/v1/BUILD.bazel
  6. 19
      src/opencensus/proto/metrics/v1/BUILD.bazel
  7. 9
      src/opencensus/proto/resource/v1/BUILD.bazel
  8. 15
      src/opencensus/proto/stats/v1/BUILD.bazel
  9. 36
      src/opencensus/proto/trace/v1/BUILD.bazel

@ -13,6 +13,3 @@
# limitations under the License.
package(default_visibility = ["//visibility:public"])
load("@io_bazel_rules_go//go:def.bzl", "go_prefix")
go_prefix("github.com/census-instrumentation/opencensus-proto")

@ -14,6 +14,9 @@
workspace(name = "opencensus_proto")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Import gRPC git repo so that we can load java_grpc_library build.
git_repository(
name = "grpc_java",
@ -59,32 +62,16 @@ http_archive(
git_repository(
name = "io_bazel_rules_go",
remote = "https://github.com/bazelbuild/rules_go.git",
# we need rules_go of tag 0.12.0
# we need rules_go of tag 0.12.0 or greater
# which includes golang protobuf that supports "paths=source_relative"
# the "paths=source_relative" option for protoc-gen-go makes bazel works as expect
# when go_package was declared in proto files
# see https://github.com/bazelbuild/rules_go/blob/release-0.12/go/private/repositories.bzl#L75
# for the included golang protobuf version and
# see https://github.com/golang/protobuf/pull/544 for "paths=source_relative" usage
tag = "0.12.0",
tag = "0.15.8",
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
go_register_toolchains()
# golang protobuf rules related
git_repository(
name = "org_pubref_rules_protobuf",
commit = "5cae42382b620aa1e347ecf30b3e92fd0d97998c", # Jun 23, 2018
remote = "https://github.com/pubref/rules_protobuf.git",
)
load("@org_pubref_rules_protobuf//go:rules.bzl", "go_proto_repositories")
go_proto_repositories(
excludes = [
# we have specified protobuf above
# so ignore it in case version collision
"com_google_protobuf",
],
)

@ -14,7 +14,7 @@
package(default_visibility = ["//visibility:public"])
load("@org_pubref_rules_protobuf//go:rules.bzl", "go_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
proto_library(
name = "common_proto",
@ -26,17 +26,8 @@ proto_library(
go_proto_library(
name = "common_proto_go",
protos = ["common.proto"],
imports = [
"external/com_google_protobuf/src",
],
inputs = [
"@com_google_protobuf//:well_known_protos",
],
pb_options = [
# omit the go_package declared in proto files to make bazel works as expect
"paths=source_relative",
],
proto = ":common_proto",
importpath = "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1",
deps = [
"@com_github_golang_protobuf//ptypes/timestamp:go_default_library",
],

@ -15,7 +15,7 @@
package(default_visibility = ["//visibility:public"])
load("@grpc_java//:java_grpc_library.bzl", "java_grpc_library")
load("@org_pubref_rules_protobuf//go:rules.bzl", "go_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
proto_library(
name = "metrics_service_proto",
@ -45,17 +45,11 @@ java_grpc_library(
go_proto_library(
name = "metrics_service_proto_go",
protos = ["metrics_service.proto"],
imports = [
"external/com_google_protobuf/src",
],
proto_deps = [
proto = ":metrics_service_proto",
importpath = "github.com/census-instrumentation/opencensus-proto/gen-go/agent/metrics/v1",
deps = [
"//opencensus/proto/agent/common/v1:common_proto_go",
"//opencensus/proto/metrics/v1:metrics_proto_go",
"//opencensus/proto/resource/v1:resource_proto_go",
],
pb_options = [
# omit the go_package declared in proto files to make bazel works as expect
"paths=source_relative",
],
)

@ -15,7 +15,7 @@
package(default_visibility = ["//visibility:public"])
load("@grpc_java//:java_grpc_library.bzl", "java_grpc_library")
load("@org_pubref_rules_protobuf//go:rules.bzl", "go_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
proto_library(
name = "trace_service_proto",
@ -46,18 +46,11 @@ java_grpc_library(
go_proto_library(
name = "trace_service_proto_go",
protos = ["trace_service.proto"],
imports = [
"external/com_google_protobuf/src",
],
proto_deps = [
proto = ":trace_service_proto",
importpath = "github.com/census-instrumentation/opencensus-proto/gen-go/agent/trace/v1",
deps = [
"//opencensus/proto/agent/common/v1:common_proto_go",
"//opencensus/proto/resource/v1:resource_proto_go",
"//opencensus/proto/trace/v1:trace_proto_go",
"//opencensus/proto/trace/v1:trace_config_proto_go",
],
pb_options = [
# omit the go_package declared in proto files to make bazel works as expect
"paths=source_relative",
"//opencensus/proto/trace/v1:trace_and_config_proto_go",
],
)

@ -14,7 +14,7 @@
package(default_visibility = ["//visibility:public"])
load("@org_pubref_rules_protobuf//go:rules.bzl", "go_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
proto_library(
name = "metrics_proto",
@ -38,21 +38,10 @@ java_proto_library(
go_proto_library(
name = "metrics_proto_go",
protos = ["metrics.proto"],
imports = [
"external/com_google_protobuf/src",
],
inputs = [
"@com_google_protobuf//:well_known_protos",
],
pb_options = [
# omit the go_package declared in proto files to make bazel works as expect
"paths=source_relative",
],
proto_deps = [
"//opencensus/proto/resource/v1:resource_proto_go",
],
proto = ":metrics_proto",
importpath = "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1",
deps = [
"//opencensus/proto/resource/v1:resource_proto_go",
"@com_github_golang_protobuf//ptypes/timestamp:go_default_library",
"@com_github_golang_protobuf//ptypes/wrappers:go_default_library",
],

@ -14,7 +14,7 @@
package(default_visibility = ["//visibility:public"])
load("@org_pubref_rules_protobuf//go:rules.bzl", "go_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
proto_library(
name = "resource_proto",
@ -33,9 +33,6 @@ java_proto_library(
go_proto_library(
name = "resource_proto_go",
protos = ["resource.proto"],
pb_options = [
# omit the go_package declared in proto files to make bazel works as expect
"paths=source_relative",
],
proto = ":resource_proto",
importpath = "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1",
)

@ -14,7 +14,7 @@
package(default_visibility = ["//visibility:public"])
load("@org_pubref_rules_protobuf//go:rules.bzl", "go_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
proto_library(
name = "stats_proto",
@ -37,17 +37,8 @@ java_proto_library(
go_proto_library(
name = "stats_proto_go",
protos = ["stats.proto"],
imports = [
"external/com_google_protobuf/src",
],
inputs = [
"@com_google_protobuf//:well_known_protos",
],
pb_options = [
# omit the go_package declared in proto files to make bazel works as expect
"paths=source_relative",
],
proto = ":stats_proto",
importpath = "github.com/census-instrumentation/opencensus-proto/gen-go/stats/v1",
deps = [
"@com_github_golang_protobuf//ptypes/timestamp:go_default_library",
],

@ -14,7 +14,8 @@
package(default_visibility = ["//visibility:public"])
load("@org_pubref_rules_protobuf//go:rules.bzl", "go_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
proto_library(
name = "trace_proto",
@ -52,17 +53,8 @@ java_proto_library(
go_proto_library(
name = "trace_proto_go",
protos = ["trace.proto"],
imports = [
"external/com_google_protobuf/src",
],
inputs = [
"@com_google_protobuf//:well_known_protos",
],
pb_options = [
# omit the go_package declared in proto files to make bazel works as expect
"paths=source_relative",
],
proto = ":trace_proto",
importpath = "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1",
deps = [
"@com_github_golang_protobuf//ptypes/timestamp:go_default_library",
"@com_github_golang_protobuf//ptypes/wrappers:go_default_library",
@ -71,9 +63,19 @@ go_proto_library(
go_proto_library(
name = "trace_config_proto_go",
protos = ["trace_config.proto"],
pb_options = [
# omit the go_package declared in proto files to make bazel works as expect
"paths=source_relative",
],
proto = ":trace_config_proto",
importpath = "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1",
)
# This a workaround because `trace_proto_go` and `trace_config_proto_go` have
# the same importpath, and so cause a compile issue if both are depended on
# directly by another `go_proto_library` (such as `trace_service_proto_go`).
# See: https://github.com/bazelbuild/rules_go/issues/1841
go_library(
name = "trace_and_config_proto_go",
srcs = [],
embed = [
":trace_proto_go",
":trace_config_proto_go",
]
)

Loading…
Cancel
Save