Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_depe
go_rules_dependencies()

go_register_toolchains(go_version = GO_VERSION)

load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to roll this into api_dependencies in bazel/repositories.bzl (not api/bazel/repositories.bzl).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api_dependencies has http_archive for com_google_googleapis, so that won't work. We can't load from a repo before it's http_archive.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and the naming is confusing. bazel/api_repositories.bzl does not actually load API repositories, so I get why one might get confused (I did).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Lizan, do you still think it's possible to add a load from googleapis without WORKSPACE change? I don't see a way, since googleapis is loaded as one of the last calls in there.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I see what you're saying, I think we want to somehow roll this into a bzl file, @htuch do you have any idea? Just roll additional dependencies (those WORKSPACE rules after envoy_dependencies) in an additional bzl file should work but still somewhat ugly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gentle ping?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think that would work, do you mind take a stab?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the envoy_api hack well, I'd hope @htuch can help there. Either way, this is going to cause churn in importing repositories, even if we change from 2 calls to 3 calls.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but less churning in in the future :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, PTAL


switched_rules_by_language(
name = "com_google_googleapis_imports",
cc = True,
go = True,
grpc = True,
rules_override = {
"py_proto_library": "@envoy_api//bazel:api_build_system.bzl",
},
)
42 changes: 31 additions & 11 deletions api/bazel/api_build_system.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@com_google_protobuf//:protobuf.bzl", "py_proto_library")
load("@com_google_protobuf//:protobuf.bzl", _py_proto_library = "py_proto_library")
load("@com_envoyproxy_protoc_gen_validate//bazel:pgv_proto_library.bzl", "pgv_cc_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_grpc_library", "go_proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_test")
Expand All @@ -24,21 +24,39 @@ def _LibrarySuffix(library_name, suffix):
# https://github.com/bazelbuild/bazel/issues/3935 and/or
# https://github.com/bazelbuild/bazel/issues/2626 are resolved.
def api_py_proto_library(name, srcs = [], deps = [], has_services = 0):
py_proto_library(
_py_proto_library(
name = _Suffix(name, _PY_SUFFIX),
srcs = srcs,
default_runtime = "@com_google_protobuf//:protobuf_python",
protoc = "@com_google_protobuf//:protoc",
deps = [_LibrarySuffix(d, _PY_SUFFIX) for d in deps] + [
"@com_envoyproxy_protoc_gen_validate//validate:validate_py",
"@googleapis//:api_httpbody_protos_py",
"@googleapis//:http_api_protos_py",
"@googleapis//:rpc_status_protos_py",
"@com_google_googleapis//google/rpc:status_py_proto",
"@com_google_googleapis//google/api:annotations_py_proto",
"@com_google_googleapis//google/api:http_py_proto",
"@com_google_googleapis//google/api:httpbody_py_proto",
"@com_github_gogo_protobuf//:gogo_proto_py",
],
visibility = ["//visibility:public"],
)

# This replaces googleapis rules.
Comment thread
htuch marked this conversation as resolved.
Outdated
def py_proto_library(name, deps = []):
srcs = [dep[:-6] + ".proto" if dep.endswith("_proto") else dep for dep in deps]
proto_deps = []

# Ignoring the proto_library has an unfortunate side-effect of losing proto dependencies...
Comment thread
htuch marked this conversation as resolved.
Outdated
if name == "annotations_py_proto":
proto_deps = proto_deps + [":http_py_proto"]
_py_proto_library(
name = name,
srcs = srcs,
default_runtime = "@com_google_protobuf//:protobuf_python",
protoc = "@com_google_protobuf//:protoc",
deps = proto_deps + ["@com_google_protobuf//:protobuf_python"],
visibility = ["//visibility:public"],
)

def api_go_proto_library(name, proto, deps = []):
go_proto_library(
name = _Suffix(name, _GO_PROTO_SUFFIX),
Expand All @@ -53,7 +71,7 @@ def api_go_proto_library(name, proto, deps = []):
"@io_bazel_rules_go//proto/wkt:timestamp_go_proto",
"@io_bazel_rules_go//proto/wkt:wrappers_go_proto",
"@com_envoyproxy_protoc_gen_validate//validate:go_default_library",
"@googleapis//:rpc_status_go_proto",
"@com_google_googleapis//google/rpc:status_go_proto",
],
)

Expand All @@ -70,7 +88,7 @@ def api_go_grpc_library(name, proto, deps = []):
"@io_bazel_rules_go//proto/wkt:struct_go_proto",
"@io_bazel_rules_go//proto/wkt:wrappers_go_proto",
"@com_envoyproxy_protoc_gen_validate//validate:go_default_library",
"@googleapis//:http_api_go_proto",
"@com_google_googleapis//google/api:annotations_go_proto",
],
)

Expand Down Expand Up @@ -109,8 +127,9 @@ def api_proto_library(
"@com_google_protobuf//:struct_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:wrappers_proto",
"@googleapis//:http_api_protos_proto",
"@googleapis//:rpc_status_protos_lib",
"@com_google_googleapis//google/api:http_proto",
"@com_google_googleapis//google/api:annotations_proto",
"@com_google_googleapis//google/rpc:status_proto",
"@com_github_gogo_protobuf//:gogo_proto",
"@com_envoyproxy_protoc_gen_validate//validate:validate_proto",
],
Expand All @@ -121,8 +140,9 @@ def api_proto_library(
linkstatic = linkstatic,
cc_deps = [_LibrarySuffix(d, _CC_SUFFIX) for d in deps] + external_cc_proto_deps + [
"@com_github_gogo_protobuf//:gogo_proto_cc",
"@googleapis//:http_api_protos",
"@googleapis//:rpc_status_protos",
"@com_google_googleapis//google/api:http_cc_proto",
"@com_google_googleapis//google/api:annotations_cc_proto",
"@com_google_googleapis//google/rpc:status_cc_proto",
],
deps = [":" + name],
visibility = ["//visibility:public"],
Expand Down
176 changes: 1 addition & 175 deletions api/bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ def api_dependencies():
locations = REPOSITORY_LOCATIONS,
)
envoy_http_archive(
name = "googleapis",
name = "com_google_googleapis",
locations = REPOSITORY_LOCATIONS,
build_file_content = GOOGLEAPIS_BUILD_CONTENT,
)
envoy_http_archive(
name = "com_github_gogo_protobuf",
Expand All @@ -36,179 +35,6 @@ def api_dependencies():
build_file_content = KAFKASOURCE_BUILD_CONTENT,
)

GOOGLEAPIS_BUILD_CONTENT = """
load("@com_google_protobuf//:protobuf.bzl", "py_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")

filegroup(
name = "api_httpbody_protos_src",
srcs = [
"google/api/httpbody.proto",
],
visibility = ["//visibility:public"],
)

proto_library(
name = "api_httpbody_protos_proto",
srcs = [":api_httpbody_protos_src"],
deps = ["@com_google_protobuf//:descriptor_proto"],
visibility = ["//visibility:public"],
)

cc_proto_library(
name = "api_httpbody_protos",
deps = [":api_httpbody_protos_proto"],
visibility = ["//visibility:public"],
)

py_proto_library(
name = "api_httpbody_protos_py",
srcs = [
"google/api/httpbody.proto",
],
include = ".",
default_runtime = "@com_google_protobuf//:protobuf_python",
protoc = "@com_google_protobuf//:protoc",
visibility = ["//visibility:public"],
deps = ["@com_google_protobuf//:protobuf_python"],
)

go_proto_library(
name = "api_httpbody_go_proto",
importpath = "google.golang.org/genproto/googleapis/api/httpbody",
proto = ":api_httpbody_protos_proto",
visibility = ["//visibility:public"],
deps = [
":descriptor_go_proto",
],
)

filegroup(
name = "http_api_protos_src",
srcs = [
"google/api/annotations.proto",
"google/api/http.proto",
],
visibility = ["//visibility:public"],
)

go_proto_library(
name = "descriptor_go_proto",
importpath = "github.com/golang/protobuf/protoc-gen-go/descriptor",
proto = "@com_google_protobuf//:descriptor_proto",
visibility = ["//visibility:public"],
)

proto_library(
name = "http_api_protos_proto",
srcs = [":http_api_protos_src"],
deps = ["@com_google_protobuf//:descriptor_proto"],
visibility = ["//visibility:public"],
)

cc_proto_library(
name = "http_api_protos",
deps = [":http_api_protos_proto"],
visibility = ["//visibility:public"],
)

py_proto_library(
name = "http_api_protos_py",
srcs = [
"google/api/annotations.proto",
"google/api/http.proto",
],
include = ".",
default_runtime = "@com_google_protobuf//:protobuf_python",
protoc = "@com_google_protobuf//:protoc",
visibility = ["//visibility:public"],
deps = ["@com_google_protobuf//:protobuf_python"],
)

go_proto_library(
name = "http_api_go_proto",
importpath = "google.golang.org/genproto/googleapis/api/annotations",
proto = ":http_api_protos_proto",
visibility = ["//visibility:public"],
deps = [
":descriptor_go_proto",
],
)

filegroup(
name = "rpc_status_protos_src",
srcs = [
"google/rpc/status.proto",
],
visibility = ["//visibility:public"],
)

proto_library(
name = "rpc_status_protos_lib",
srcs = [":rpc_status_protos_src"],
deps = ["@com_google_protobuf//:any_proto"],
visibility = ["//visibility:public"],
)

cc_proto_library(
name = "rpc_status_protos",
deps = [":rpc_status_protos_lib"],
visibility = ["//visibility:public"],
)

go_proto_library(
name = "rpc_status_go_proto",
importpath = "google.golang.org/genproto/googleapis/rpc/status",
proto = ":rpc_status_protos_lib",
visibility = ["//visibility:public"],
deps = [
"@io_bazel_rules_go//proto/wkt:any_go_proto",
],
)

py_proto_library(
name = "rpc_status_protos_py",
srcs = [
"google/rpc/status.proto",
],
include = ".",
default_runtime = "@com_google_protobuf//:protobuf_python",
protoc = "@com_google_protobuf//:protoc",
visibility = ["//visibility:public"],
deps = ["@com_google_protobuf//:protobuf_python"],
)

proto_library(
name = "tracing_proto_proto",
srcs = [
"google/devtools/cloudtrace/v2/trace.proto",
"google/devtools/cloudtrace/v2/tracing.proto",
],
deps = [
":http_api_protos_proto",
":rpc_status_protos_lib",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:wrappers_proto",
"@com_google_protobuf//:empty_proto",
],
)

cc_proto_library(
name = "tracing_proto_cc",
deps = [":tracing_proto_proto"],
)

cc_grpc_library(
name = "tracing_proto",
srcs = [":tracing_proto_proto"],
deps = [":tracing_proto_cc"],
grpc_only = True,
visibility = ["@io_opencensus_cpp//opencensus:__subpackages__"],
)

"""

GOGOPROTO_BUILD_CONTENT = """
load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library", "py_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
Expand Down
6 changes: 3 additions & 3 deletions api/bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ OPENCENSUS_PROTO_SHA256 = "a4e87a1da21d1b3a16674332c3ee6e2689d52f3532e2ff8cb4a62
PGV_GIT_SHA = "26db5cb7c01a67c6a2e21a832106406185530b2f"
PGV_SHA256 = "6510cbcf69d99059c652ae2376f6240bc761d0b019cd962225f4f609be361e26"

GOOGLEAPIS_GIT_SHA = "d642131a6e6582fc226caf9893cb7fe7885b3411" # May 23, 2018
GOOGLEAPIS_SHA = "16f5b2e8bf1e747a32f9a62e211f8f33c94645492e9bbd72458061d9a9de1f63"
GOOGLEAPIS_GIT_SHA = "0ce9d41a2c6efa6a71a06ace0d088f3e548a4431" # Jul 17, 2019
GOOGLEAPIS_SHA = "08687b82779972a2021af5143430b294c0941d1b48242aa4f5c7ad50f10e89a6"

PROMETHEUS_GIT_SHA = "99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c" # Nov 17, 2017
PROMETHEUS_SHA = "783bdaf8ee0464b35ec0c8704871e1e72afa0005c3f3587f65d9d6694bf3911b"
Expand All @@ -28,7 +28,7 @@ REPOSITORY_LOCATIONS = dict(
strip_prefix = "protoc-gen-validate-" + PGV_GIT_SHA,
urls = ["https://github.com/envoyproxy/protoc-gen-validate/archive/" + PGV_GIT_SHA + ".tar.gz"],
),
googleapis = dict(
com_google_googleapis = dict(
# TODO(dio): Consider writing a Skylark macro for importing Google API proto.
sha256 = GOOGLEAPIS_SHA,
strip_prefix = "googleapis-" + GOOGLEAPIS_GIT_SHA,
Expand Down
4 changes: 2 additions & 2 deletions bazel/api_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def envoy_api_dependencies():

native.bind(
name = "api_httpbody_protos",
actual = "@googleapis//:api_httpbody_protos",
actual = "@com_google_googleapis//google/api:httpbody_cc_proto",
)
native.bind(
name = "http_api_protos",
actual = "@googleapis//:http_api_protos",
actual = "@com_google_googleapis//google/api:annotations_cc_proto",
)
9 changes: 5 additions & 4 deletions bazel/envoy_build_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,13 @@ def envoy_proto_descriptor(name, out, srcs = [], external_deps = []):
include_paths = [".", native.package_name()]

if "api_httpbody_protos" in external_deps:
srcs.append("@googleapis//:api_httpbody_protos_src")
include_paths.append("external/googleapis")
srcs.append("@com_google_googleapis//google/api:httpbody.proto")
include_paths.append("external/com_google_googleapis")

if "http_api_protos" in external_deps:
srcs.append("@googleapis//:http_api_protos_src")
include_paths.append("external/googleapis")
srcs.append("@com_google_googleapis//google/api:annotations.proto")
srcs.append("@com_google_googleapis//google/api:http.proto")
include_paths.append("external/com_google_googleapis")

if "well_known_protos" in external_deps:
srcs.append("@com_google_protobuf//:well_known_protos")
Expand Down
4 changes: 2 additions & 2 deletions bazel/envoy_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def envoy_proto_library(name, external_deps = [], **kwargs):
external_proto_deps = []
external_cc_proto_deps = []
if "api_httpbody_protos" in external_deps:
external_cc_proto_deps.append("@googleapis//:api_httpbody_protos")
external_proto_deps.append("@googleapis//:api_httpbody_protos_proto")
external_cc_proto_deps.append("@com_google_googleapis//google/api:httpbody_cc_proto")
external_proto_deps.append("@com_google_googleapis//google/api:httpbody_proto")
api_proto_library(
name,
external_cc_proto_deps = external_cc_proto_deps,
Expand Down
2 changes: 1 addition & 1 deletion bazel/foreign_cc/com_lightstep_tracer_cpp.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
srcs = ["collector.proto"],
deps = [
- "@lightstep_vendored_googleapis//:googleapis_proto",
+ "@googleapis//:http_api_protos_proto",
+ "@com_google_googleapis//google/api:annotations_proto",
"@com_google_protobuf//:timestamp_proto",
],
visibility = ["//visibility:public"],
11 changes: 0 additions & 11 deletions bazel/foreign_cc/io_opencensus_cpp.patch

This file was deleted.

3 changes: 1 addition & 2 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def envoy_dependencies(skip_targets = []):
_python_deps()
_cc_deps()
_go_deps(skip_targets)

api_dependencies()

def _boringssl():
Expand Down Expand Up @@ -515,8 +516,6 @@ def _io_opencensus_cpp():
location = REPOSITORY_LOCATIONS["io_opencensus_cpp"]
http_archive(
name = "io_opencensus_cpp",
patch_args = ["-p0"],
patches = ["@envoy//bazel/foreign_cc:io_opencensus_cpp.patch"],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Thank you.

**location
)
native.bind(
Expand Down
Loading