-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Create a bazel rule to print Envoy's dependencies #5049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,3 +21,4 @@ TAGS | |
| .vimrc | ||
| .vs | ||
| .vscode | ||
| *.bzlc | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| exports_files(["repository_locations.bzl"]) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
| load(":repository_locations.bzl", "REPOSITORY_LOCATIONS") | ||
|
|
||
| def envoy_http_archive(name, repository_locations = REPOSITORY_LOCATIONS, **kwargs): | ||
| # `existing_rule_keys` contains the names of repositories that have already | ||
| # been defined in the Bazel workspace. By skipping repos with existing keys, | ||
| # users can override dependency versions by using standard Bazel repository | ||
| # rules in their WORKSPACE files. | ||
| existing_rule_keys = native.existing_rules().keys() | ||
| if name in existing_rule_keys: | ||
| # This repository has already been defined, probably because the user | ||
| # wants to override the version. Do nothing. | ||
| return | ||
|
|
||
| loc_key = kwargs.pop("repository_key", name) | ||
| location = repository_locations[loc_key] | ||
|
|
||
| # Git tags are mutable. We want to depend on commit IDs instead. Give the | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think git repositories are already disabled so we can remove this.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lizan where are they disabled? |
||
| # user a useful error if they accidentally specify a tag. | ||
| if "tag" in location: | ||
| fail( | ||
| "Refusing to depend on Git tag %r for external dependency %r: use 'commit' instead." % | ||
| (location["tag"], name), | ||
| ) | ||
|
|
||
| # HTTP tarball at a given URL. Add a BUILD file if requested. | ||
| http_archive( | ||
| name = name, | ||
| urls = location["urls"], | ||
| sha256 = location["sha256"], | ||
| strip_prefix = location.get("strip_prefix", ""), | ||
| **kwargs | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,43 +1,47 @@ | ||
| BAZEL_SKYLIB_RELEASE = "0.5.0" | ||
| BAZEL_SKYLIB_SHA256 = "b5f6abe419da897b7901f90cbab08af958b97a8f3575b0d3dd062ac7ce78541f" | ||
| load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
| load(":envoy_http_archive.bzl", "envoy_http_archive") | ||
|
|
||
| GOGOPROTO_RELEASE = "1.1.1" | ||
| GOGOPROTO_SHA256 = "9f8c2ad49849ab063cd9fef67e77d49606640044227ecf7f3617ea2c92ef147c" | ||
| PROMETHEUSMETRICS_BUILD_CONTENT = """ | ||
| load("@envoy_api//bazel:api_build_system.bzl", "api_proto_library") | ||
| load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") | ||
|
|
||
| PGV_RELEASE = "0.0.11" | ||
| PGV_SHA256 = "d92c7f22929f495cf9f7d825c44f9190eda1d8256af321e3e8692570181b28a6" | ||
| api_proto_library( | ||
| name = "client_model", | ||
| srcs = [ | ||
| "metrics.proto", | ||
| ], | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
|
|
||
| GOOGLEAPIS_GIT_SHA = "d642131a6e6582fc226caf9893cb7fe7885b3411" # May 23, 2018 | ||
| GOOGLEAPIS_SHA = "16f5b2e8bf1e747a32f9a62e211f8f33c94645492e9bbd72458061d9a9de1f63" | ||
| go_proto_library( | ||
| name = "client_model_go_proto", | ||
| importpath = "client_model", | ||
| proto = ":client_model", | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
| """ | ||
|
|
||
| PROMETHEUS_GIT_SHA = "99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c" # Nov 17, 2017 | ||
| PROMETHEUS_SHA = "783bdaf8ee0464b35ec0c8704871e1e72afa0005c3f3587f65d9d6694bf3911b" | ||
| OPENCENSUSTRACE_BUILD_CONTENT = """ | ||
| load("@envoy_api//bazel:api_build_system.bzl", "api_proto_library") | ||
| load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") | ||
|
|
||
| OPENCENSUS_GIT_SHA = "ab82e5fdec8267dc2a726544b10af97675970847" # May 23, 2018 | ||
| OPENCENSUS_SHA = "1950f844d9f338ba731897a9bb526f9074c0487b3f274ce2ec3b4feaf0bef7e2" | ||
| api_proto_library( | ||
| name = "trace_model", | ||
| srcs = [ | ||
| "trace.proto", | ||
| ], | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
|
|
||
| load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
| go_proto_library( | ||
| name = "trace_model_go_proto", | ||
| importpath = "trace_model", | ||
| proto = ":trace_model", | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
| """ | ||
|
|
||
| def api_dependencies(): | ||
| http_archive( | ||
| name = "bazel_skylib", | ||
| sha256 = BAZEL_SKYLIB_SHA256, | ||
| strip_prefix = "bazel-skylib-" + BAZEL_SKYLIB_RELEASE, | ||
| url = "https://github.com/bazelbuild/bazel-skylib/archive/" + BAZEL_SKYLIB_RELEASE + ".tar.gz", | ||
| ) | ||
| http_archive( | ||
| name = "com_lyft_protoc_gen_validate", | ||
| sha256 = PGV_SHA256, | ||
| strip_prefix = "protoc-gen-validate-" + PGV_RELEASE, | ||
| url = "https://github.com/lyft/protoc-gen-validate/archive/v" + PGV_RELEASE + ".tar.gz", | ||
| ) | ||
| http_archive( | ||
| name = "googleapis", | ||
| strip_prefix = "googleapis-" + GOOGLEAPIS_GIT_SHA, | ||
| url = "https://github.com/googleapis/googleapis/archive/" + GOOGLEAPIS_GIT_SHA + ".tar.gz", | ||
| # TODO(dio): Consider writing a Skylark macro for importing Google API proto. | ||
| sha256 = GOOGLEAPIS_SHA, | ||
| build_file_content = """ | ||
| GOOGLEAPIS_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") | ||
|
|
||
|
|
@@ -52,8 +56,8 @@ filegroup( | |
| proto_library( | ||
| name = "api_httpbody_protos_proto", | ||
| srcs = [":api_httpbody_protos_src"], | ||
| deps = ["@com_google_protobuf//:descriptor_proto"], | ||
| visibility = ["//visibility:public"], | ||
| deps = ["@com_google_protobuf//:descriptor_proto"], | ||
| ) | ||
|
|
||
| cc_proto_library( | ||
|
|
@@ -63,8 +67,8 @@ cc_proto_library( | |
| ], | ||
| default_runtime = "@com_google_protobuf//:protobuf", | ||
| protoc = "@com_google_protobuf//:protoc", | ||
| deps = ["@com_google_protobuf//:cc_wkt_protos"], | ||
| visibility = ["//visibility:public"], | ||
| deps = ["@com_google_protobuf//:cc_wkt_protos"], | ||
| ) | ||
|
|
||
| py_proto_library( | ||
|
|
@@ -85,7 +89,7 @@ go_proto_library( | |
| proto = ":api_httpbody_protos_proto", | ||
| visibility = ["//visibility:public"], | ||
| deps = [ | ||
| ":descriptor_go_proto", | ||
| ":descriptor_go_proto", | ||
| ], | ||
| ) | ||
|
|
||
|
|
@@ -108,8 +112,8 @@ go_proto_library( | |
| proto_library( | ||
| name = "http_api_protos_proto", | ||
| srcs = [":http_api_protos_src"], | ||
| deps = ["@com_google_protobuf//:descriptor_proto"], | ||
| visibility = ["//visibility:public"], | ||
| deps = ["@com_google_protobuf//:descriptor_proto"], | ||
| ) | ||
|
|
||
| cc_proto_library( | ||
|
|
@@ -120,8 +124,8 @@ cc_proto_library( | |
| ], | ||
| default_runtime = "@com_google_protobuf//:protobuf", | ||
| protoc = "@com_google_protobuf//:protoc", | ||
| deps = ["@com_google_protobuf//:cc_wkt_protos"], | ||
| visibility = ["//visibility:public"], | ||
| deps = ["@com_google_protobuf//:cc_wkt_protos"], | ||
| ) | ||
|
|
||
| py_proto_library( | ||
|
|
@@ -143,34 +147,34 @@ go_proto_library( | |
| proto = ":http_api_protos_proto", | ||
| visibility = ["//visibility:public"], | ||
| deps = [ | ||
| ":descriptor_go_proto", | ||
| ":descriptor_go_proto", | ||
| ], | ||
| ) | ||
|
|
||
| filegroup( | ||
| name = "rpc_status_protos_src", | ||
| srcs = [ | ||
| "google/rpc/status.proto", | ||
| ], | ||
| visibility = ["//visibility:public"], | ||
| 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"], | ||
| name = "rpc_status_protos_lib", | ||
| srcs = [":rpc_status_protos_src"], | ||
| visibility = ["//visibility:public"], | ||
| deps = ["@com_google_protobuf//:any_proto"], | ||
| ) | ||
|
|
||
| cc_proto_library( | ||
| name = "rpc_status_protos", | ||
| srcs = ["google/rpc/status.proto"], | ||
| default_runtime = "@com_google_protobuf//:protobuf", | ||
| protoc = "@com_google_protobuf//:protoc", | ||
| deps = [ | ||
| "@com_google_protobuf//:cc_wkt_protos" | ||
| ], | ||
| visibility = ["//visibility:public"], | ||
| name = "rpc_status_protos", | ||
| srcs = ["google/rpc/status.proto"], | ||
| default_runtime = "@com_google_protobuf//:protobuf", | ||
| protoc = "@com_google_protobuf//:protoc", | ||
| visibility = ["//visibility:public"], | ||
| deps = [ | ||
| "@com_google_protobuf//:cc_wkt_protos", | ||
| ], | ||
| ) | ||
|
|
||
| go_proto_library( | ||
|
|
@@ -179,30 +183,24 @@ go_proto_library( | |
| proto = ":rpc_status_protos_lib", | ||
| visibility = ["//visibility:public"], | ||
| deps = [ | ||
| "@com_github_golang_protobuf//ptypes/any:go_default_library", | ||
| "@com_github_golang_protobuf//ptypes/any:go_default_library", | ||
| ], | ||
| ) | ||
|
|
||
| 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"], | ||
| 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"], | ||
| ) | ||
| """, | ||
| ) | ||
| """ | ||
|
|
||
| http_archive( | ||
| name = "com_github_gogo_protobuf", | ||
| sha256 = GOGOPROTO_SHA256, | ||
| strip_prefix = "protobuf-" + GOGOPROTO_RELEASE, | ||
| url = "https://github.com/gogo/protobuf/archive/v" + GOGOPROTO_RELEASE + ".tar.gz", | ||
| build_file_content = """ | ||
| GOGOPROTO_BUILD_CONTENT = """ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be at the top next to the other build content defs? Or should they all be next to their consuming sites? Either is good, as long as we are consistent. |
||
| load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library", "py_proto_library") | ||
| load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") | ||
|
|
||
|
|
@@ -211,10 +209,10 @@ proto_library( | |
| srcs = [ | ||
| "gogoproto/gogo.proto", | ||
| ], | ||
| visibility = ["//visibility:public"], | ||
| deps = [ | ||
| "@com_google_protobuf//:descriptor_proto", | ||
| ], | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
|
|
||
| go_proto_library( | ||
|
|
@@ -231,8 +229,8 @@ cc_proto_library( | |
| ], | ||
| default_runtime = "@com_google_protobuf//:protobuf", | ||
| protoc = "@com_google_protobuf//:protoc", | ||
| deps = ["@com_google_protobuf//:cc_wkt_protos"], | ||
| visibility = ["//visibility:public"], | ||
| deps = ["@com_google_protobuf//:cc_wkt_protos"], | ||
| ) | ||
|
|
||
| go_proto_library( | ||
|
|
@@ -254,58 +252,24 @@ py_proto_library( | |
| protoc = "@com_google_protobuf//:protoc", | ||
| visibility = ["//visibility:public"], | ||
| deps = ["@com_google_protobuf//:protobuf_python"], | ||
| ) | ||
| """, | ||
| ) | ||
| )""" | ||
|
|
||
| http_archive( | ||
| def api_dependencies(): | ||
| envoy_http_archive("bazel_skylib") | ||
| envoy_http_archive("com_lyft_protoc_gen_validate") | ||
| envoy_http_archive( | ||
| name = "googleapis", | ||
| build_file_content = GOOGLEAPIS_BUILD_CONTENT, | ||
| ) | ||
| envoy_http_archive( | ||
| name = "com_github_gogo_protobuf", | ||
| build_file_content = GOGOPROTO_BUILD_CONTENT, | ||
| ) | ||
| envoy_http_archive( | ||
| name = "prometheus_metrics_model", | ||
| strip_prefix = "client_model-" + PROMETHEUS_GIT_SHA, | ||
| url = "https://github.com/prometheus/client_model/archive/" + PROMETHEUS_GIT_SHA + ".tar.gz", | ||
| sha256 = PROMETHEUS_SHA, | ||
| build_file_content = """ | ||
| load("@envoy_api//bazel:api_build_system.bzl", "api_proto_library") | ||
| load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") | ||
|
|
||
| api_proto_library( | ||
| name = "client_model", | ||
| srcs = [ | ||
| "metrics.proto", | ||
| ], | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
|
|
||
| go_proto_library( | ||
| name = "client_model_go_proto", | ||
| importpath = "client_model", | ||
| proto = ":client_model", | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
| """, | ||
| build_file_content = PROMETHEUSMETRICS_BUILD_CONTENT, | ||
| ) | ||
|
|
||
| http_archive( | ||
| envoy_http_archive( | ||
| name = "io_opencensus_trace", | ||
| strip_prefix = "opencensus-proto-" + OPENCENSUS_GIT_SHA + "/opencensus/proto/trace", | ||
| url = "https://github.com/census-instrumentation/opencensus-proto/archive/" + OPENCENSUS_GIT_SHA + ".tar.gz", | ||
| sha256 = OPENCENSUS_SHA, | ||
| build_file_content = """ | ||
| load("@envoy_api//bazel:api_build_system.bzl", "api_proto_library") | ||
| load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") | ||
|
|
||
| api_proto_library( | ||
| name = "trace_model", | ||
| srcs = [ | ||
| "trace.proto", | ||
| ], | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
|
|
||
| go_proto_library( | ||
| name = "trace_model_go_proto", | ||
| importpath = "trace_model", | ||
| proto = ":trace_model", | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
| """, | ||
| build_file_content = OPENCENSUSTRACE_BUILD_CONTENT, | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.