Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ bazel-*
*.pyc
build_docs/
generated/
MODULE.bazel.lock
98 changes: 98 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
module(
name = "envoy_api",
version = "0.0.0-dev",
)

# State-of-the-art MODULE.bazel for Envoy Data Plane API
#
# This MODULE.bazel implements modern bzlmod dependency management following:
# - Bazel 8.0+ best practices
# - BCR (Bazel Central Registry) native dependencies where available
# - Consolidated module extensions for non-BCR dependencies
# - Compatible with the envoy_api module published in BCR
#
# All bazel_dep entries are organized alphabetically for improved readability.

# Core dependencies from Bazel Central Registry
bazel_dep(name = "abseil-cpp", version = "20250127.1", repo_name = "com_google_absl")
bazel_dep(name = "bazel_skylib", version = "1.8.2")
bazel_dep(name = "cel-spec", version = "0.24.0", repo_name = "dev_cel")
bazel_dep(name = "gazelle", version = "0.45.0", repo_name = "bazel_gazelle")
bazel_dep(name = "googleapis", version = "0.0.0-20241220-5e258e33.bcr.1", repo_name = "com_google_googleapis")
bazel_dep(name = "googleapis-cc", version = "1.0.0")
bazel_dep(name = "grpc", version = "1.66.0.bcr.2", repo_name = "com_github_grpc_grpc")
bazel_dep(name = "opencensus-proto", version = "0.4.1", repo_name = "opencensus_proto")
bazel_dep(name = "opentelemetry-proto", version = "1.8.0", repo_name = "opentelemetry_proto")
bazel_dep(name = "protobuf", version = "29.3", repo_name = "com_google_protobuf")
bazel_dep(name = "protoc-gen-validate", version = "1.2.1.bcr.1", repo_name = "com_envoyproxy_protoc_gen_validate")
bazel_dep(name = "re2", version = "2024-07-02.bcr.1", repo_name = "com_googlesource_code_re2")
bazel_dep(name = "rules_go", version = "0.57.0", repo_name = "io_bazel_rules_go")
bazel_dep(name = "rules_jvm_external", version = "6.8")
bazel_dep(name = "rules_proto", version = "7.1.0")
bazel_dep(name = "rules_python", version = "1.4.1")
bazel_dep(name = "xds", version = "0.0.0-20240423-555b57e", repo_name = "com_github_cncf_xds")
bazel_dep(name = "zipkin-api", version = "1.0.0", repo_name = "com_github_openzipkin_zipkinapi")

# Test dependencies from Bazel Central Registry
bazel_dep(name = "googletest", version = "1.17.0", dev_dependency = True, repo_name = "com_google_googletest")

# Go SDK and toolchain configuration
go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.24.6")
use_repo(
go_sdk,
"go_toolchains",
)

# Googleapis extension for language-specific rules
switched_rules = use_extension("@com_google_googleapis//:extensions.bzl", "switched_rules")
switched_rules.use_languages(
cc = True,
go = True,
)

# Non-BCR dependencies extension
# These dependencies are not yet available in BCR or require custom build files
non_module_deps = use_extension("//bazel:extensions.bzl", "non_module_deps")
use_repo(
non_module_deps,
"com_github_chrusty_protoc_gen_jsonschema",
"envoy_toolshed",
"prometheus_metrics_model",
)

# Go dependencies extension
go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
go_deps.module(
path = "github.com/planetscale/vtprotobuf",
sum = "h1:ujRGEVWJEoaxQ+8+HMl8YEpGaDAgohgZxJ5S+d2TTFQ=",
version = "v0.6.1-0.20240409071808-615f978279ca",
)
go_deps.module(
path = "google.golang.org/protobuf",
sum = "h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU=",
version = "v1.36.3",
)
go_deps.module(
path = "google.golang.org/genproto/googleapis/rpc",
sum = "h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI=",
version = "v0.0.0-20250115164207-1a7da9e5054f",
)
go_deps.module(
path = "google.golang.org/genproto/googleapis/api",
sum = "h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI=",
version = "v0.0.0-20250115164207-1a7da9e5054f",
)
go_deps.module(
path = "github.com/golang/protobuf",
sum = "h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=",
version = "v1.5.4",
)
use_repo(
go_deps,
"com_github_golang_protobuf",
"com_github_planetscale_vtprotobuf",
"org_golang_google_genproto_googleapis_api",
"org_golang_google_genproto_googleapis_rpc",
"org_golang_google_protobuf",
)
4 changes: 3 additions & 1 deletion bazel/api_build_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ _CC_GRPC_SUFFIX = "_cc_grpc"
_GO_PROTO_SUFFIX = "_go_proto"
_GO_IMPORTPATH_PREFIX = "github.com/envoyproxy/go-control-plane/"
_JAVA_PROTO_SUFFIX = "_java_proto"
_IS_BZLMOD = str(Label("//:invalid")).startswith("@@")

_COMMON_PROTO_DEPS = [
"@com_google_protobuf//:any_proto",
Expand All @@ -42,7 +43,8 @@ _COMMON_PROTO_DEPS = [
def _proto_mapping(dep, proto_dep_map, proto_suffix):
mapped = proto_dep_map.get(dep)
if mapped == None:
prefix = "@" + Label(dep).workspace_name if not dep.startswith("//") else ""
prefix = "@@" if _IS_BZLMOD else "@"
prefix = prefix + Label(dep).repo_name if not dep.startswith("//") else ""
return prefix + "//" + Label(dep).package + ":" + Label(dep).name + proto_suffix
return mapped

Expand Down
1 change: 0 additions & 1 deletion bazel/cc_proto_descriptor_library/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ cc_library(
"@com_google_absl//absl/strings:str_format",
"@com_google_protobuf//:protobuf",
"@com_google_protobuf//src/google/protobuf/compiler:code_generator",
"@com_google_protobuf//src/google/protobuf/compiler:retention",
],
)

Expand Down
33 changes: 33 additions & 0 deletions bazel/extensions.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Non-BCR dependencies for Envoy Data Plane API.

This extension provides repositories that are not available in Bazel Central Registry (BCR).
"""

load(":repositories.bzl", "api_dependencies")

def _non_module_deps_impl(module_ctx):
"""Implementation for non_module_deps extension.

This extension calls api_dependencies(bzlmod=True) which creates repositories
not in BCR. It safely coexists with BCR deps because envoy_http_archive
checks native.existing_rules() before creating repositories.

Args:
module_ctx: Module extension context
"""
api_dependencies(bzlmod = True)

non_module_deps = module_extension(
implementation = _non_module_deps_impl,
doc = """
Extension for Envoy API dependencies not available in BCR.

This extension creates the following repositories:
- prometheus_metrics_model: Prometheus client model
- com_github_chrusty_protoc_gen_jsonschema: Proto to JSON schema compiler
- envoy_toolshed: Tooling and libraries for Envoy development

For WORKSPACE mode, call api_dependencies() directly from WORKSPACE.
This extension should only be used in MODULE.bazel files.
""",
)
25 changes: 17 additions & 8 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,23 @@ def external_http_archive(name, **kwargs):
**kwargs
)

def api_dependencies():
def api_dependencies(bzlmod = False):
# Dependencies needed for both WORKSPACE and bzlmod
external_http_archive(
name = "prometheus_metrics_model",
build_file_content = PROMETHEUSMETRICS_BUILD_CONTENT,
)
external_http_archive(
name = "com_github_chrusty_protoc_gen_jsonschema",
)
external_http_archive(
name = "envoy_toolshed",
)

# WORKSPACE-only dependencies (available in BCR for bzlmod or not needed)
if bzlmod:
return

external_http_archive(
name = "bazel_skylib",
)
Expand All @@ -30,10 +46,6 @@ def api_dependencies():
external_http_archive(
name = "com_github_cncf_xds",
)
external_http_archive(
name = "prometheus_metrics_model",
build_file_content = PROMETHEUSMETRICS_BUILD_CONTENT,
)
external_http_archive(
name = "rules_buf",
)
Expand All @@ -51,9 +63,6 @@ def api_dependencies():
external_http_archive(
name = "dev_cel",
)
external_http_archive(
name = "com_github_chrusty_protoc_gen_jsonschema",
)

PROMETHEUSMETRICS_BUILD_CONTENT = """
load("@envoy_api//bazel:api_build_system.bzl", "api_cc_py_proto_library")
Expand Down
13 changes: 13 additions & 0 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,17 @@ REPOSITORY_LOCATIONS_SPEC = dict(
license = "Apache-2.0",
license_url = "https://github.com/google/cel-spec/blob/v{version}/LICENSE",
),
envoy_toolshed = dict(
project_name = "envoy_toolshed",
project_desc = "Tooling, libraries, runners and checkers for Envoy proxy's CI",
project_url = "https://github.com/envoyproxy/toolshed",
version = "0.3.5",
sha256 = "ec59fe6cf1432d33c0207e9f85bda3cbf653b54b3a16f3f94479b6cc8f3d1701",
release_date = "2025-10-27",
strip_prefix = "toolshed-bazel-v{version}/bazel",
urls = ["https://github.com/envoyproxy/toolshed/archive/bazel-v{version}.tar.gz"],
use_category = ["build"],
license = "Apache-2.0",
license_url = "https://github.com/envoyproxy/toolshed/blob/bazel-v{version}/LICENSE",
),
)