add golang bazel build support (#132)

pull/134/head
yancl 6 years ago committed by Bogdan Drutu
parent 1aa555954f
commit 475e1d0ccf
  1. 7
      src/BUILD.bazel
  2. 34
      src/WORKSPACE
  3. 20
      src/opencensus/proto/agent/common/v1/BUILD.bazel
  4. 18
      src/opencensus/proto/agent/trace/v1/BUILD.bazel
  5. 21
      src/opencensus/proto/metrics/v1/BUILD.bazel
  6. 20
      src/opencensus/proto/stats/v1/BUILD.bazel
  7. 30
      src/opencensus/proto/trace/v1/BUILD.bazel

@ -10,4 +10,9 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 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")

@ -54,3 +54,37 @@ http_archive(
strip_prefix = "protobuf-3.5.1",
urls = ["https://github.com/google/protobuf/archive/v3.5.1.tar.gz"],
)
# go rules related
git_repository(
name = "io_bazel_rules_go",
remote = "https://github.com/bazelbuild/rules_go.git",
# we need rules_go of tag 0.12.0
# 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",
)
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,6 +14,8 @@
package(default_visibility = ["//visibility:public"])
load("@org_pubref_rules_protobuf//go:rules.bzl", "go_proto_library")
proto_library(
name = "common_proto",
srcs = ["common.proto"],
@ -21,3 +23,21 @@ proto_library(
"@com_google_protobuf//:timestamp_proto",
],
)
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",
],
deps = [
"@com_github_golang_protobuf//ptypes/timestamp:go_default_library",
],
)

@ -15,6 +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")
proto_library(
name = "trace_service_proto",
@ -52,3 +53,20 @@ java_grpc_library(
# deps = [
# ],
#)
go_proto_library(
name = "trace_service_proto_go",
protos = ["trace_service.proto"],
imports = [
"external/com_google_protobuf/src",
],
proto_deps = [
"//opencensus/proto/agent/common/v1:common_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",
],
)

@ -14,6 +14,8 @@
package(default_visibility = ["//visibility:public"])
load("@org_pubref_rules_protobuf//go:rules.bzl", "go_proto_library")
proto_library(
name = "metrics_proto",
srcs = ["metrics.proto"],
@ -32,3 +34,22 @@ java_proto_library(
name = "metrics_proto_java",
deps = [":metrics_proto"],
)
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",
],
deps = [
"@com_github_golang_protobuf//ptypes/timestamp:go_default_library",
"@com_github_golang_protobuf//ptypes/wrappers:go_default_library",
],
)

@ -14,6 +14,8 @@
package(default_visibility = ["//visibility:public"])
load("@org_pubref_rules_protobuf//go:rules.bzl", "go_proto_library")
proto_library(
name = "stats_proto",
srcs = ["stats.proto"],
@ -32,3 +34,21 @@ java_proto_library(
name = "stats_proto_java",
deps = [":stats_proto"],
)
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",
],
deps = [
"@com_github_golang_protobuf//ptypes/timestamp:go_default_library",
],
)

@ -14,6 +14,8 @@
package(default_visibility = ["//visibility:public"])
load("@org_pubref_rules_protobuf//go:rules.bzl", "go_proto_library")
proto_library(
name = "trace_proto",
srcs = ["trace.proto"],
@ -47,3 +49,31 @@ java_proto_library(
name = "trace_config_proto_java",
deps = [":trace_config_proto"],
)
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",
],
deps = [
"@com_github_golang_protobuf//ptypes/timestamp:go_default_library",
"@com_github_golang_protobuf//ptypes/wrappers:go_default_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",
],
)

Loading…
Cancel
Save