diff --git a/api/bazel/external_deps.bzl b/api/bazel/external_deps.bzl index d541512ce98b6..061c6282d5cd1 100644 --- a/api/bazel/external_deps.bzl +++ b/api/bazel/external_deps.bzl @@ -35,6 +35,9 @@ DEPENDENCY_ANNOTATIONS = [ # This attribute is mandatory for each dependecy. "use_category", + # Use the project name rather than the starlark key as the repo name. + "use_project_name", + # The dependency version. This may be either a tagged release (preferred) # or git SHA (as an exception when no release tagged version is suitable). "version", @@ -81,14 +84,18 @@ def load_repository_locations(repository_locations_spec): locations = {} for key, location in load_repository_locations_spec(repository_locations_spec).items(): mutable_location = dict(location) - locations[key] = mutable_location - - if "sha256" not in location or len(location["sha256"]) == 0: - _fail_missing_attribute("sha256", key) if "project_name" not in location: _fail_missing_attribute("project_name", key) + if location.get("use_project_name", False): + locations[location["project_name"]] = mutable_location + else: + locations[key] = mutable_location + + if "sha256" not in location or len(location["sha256"]) == 0: + _fail_missing_attribute("sha256", key) + if "project_desc" not in location: _fail_missing_attribute("project_desc", key) diff --git a/bazel/dependency_imports.bzl b/bazel/dependency_imports.bzl index d2ab0fc039089..a7081fab0a9e4 100644 --- a/bazel/dependency_imports.bzl +++ b/bazel/dependency_imports.bzl @@ -1,4 +1,4 @@ -load("@aspect_bazel_lib//lib:repositories.bzl", "register_jq_toolchains", "register_yq_toolchains") +load("@bazel_lib//lib:repositories.bzl", "bazel_lib_register_toolchains") load("@base_pip3//:requirements.bzl", pip_dependencies = "install_deps") load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository") load("@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies") @@ -23,6 +23,7 @@ load("@rules_rust//crate_universe:defs.bzl", "crates_repository") load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies") load("@rules_rust//rust:defs.bzl", "rust_common") load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains", "rust_repository_set") +load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains") # go version for rules_go GO_VERSION = "1.24.6" @@ -41,6 +42,8 @@ def envoy_dependency_imports( buf_version = BUF_VERSION): compatibility_proxy_repo() rules_foreign_cc_dependencies() + rules_shell_dependencies() + rules_shell_toolchains() go_rules_dependencies() go_register_toolchains(go_version) if go_version != "host": @@ -79,8 +82,7 @@ def envoy_dependency_imports( oss_fuzz = True, honggfuzz = False, ) - register_jq_toolchains(version = jq_version) - register_yq_toolchains(version = yq_version) + bazel_lib_register_toolchains() parser_deps() rules_buf_toolchains( diff --git a/bazel/dependency_imports_extra.bzl b/bazel/dependency_imports_extra.bzl index de302800d2e8e..83e2a65d2c7ab 100644 --- a/bazel/dependency_imports_extra.bzl +++ b/bazel/dependency_imports_extra.bzl @@ -1,5 +1,11 @@ +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") load("@dynamic_modules_rust_sdk_crate_index//:defs.bzl", "crate_repositories") +load("@platforms//host:extension.bzl", "host_platform_repo") # Dependencies that rely on a first stage of envoy_dependency_imports() in dependency_imports.bzl. def envoy_dependency_imports_extra(): crate_repositories() + maybe( + host_platform_repo, + name = "host_platform", + ) diff --git a/bazel/repo.bzl b/bazel/repo.bzl index bb41ba8a76148..0d03048520d59 100644 --- a/bazel/repo.bzl +++ b/bazel/repo.bzl @@ -27,7 +27,7 @@ def _envoy_repo_impl(repository_ctx): Project and repo data can be accessed in JSON format using `@envoy_repo//:project`, eg: ```starlark - load("@aspect_bazel_lib//lib:jq.bzl", "jq") + load("@jq.bzl", "jq") jq( name = "project_version", diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 465f8f55a0f03..500374ffa01ae 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -228,10 +228,12 @@ def envoy_dependencies(skip_targets = []): external_http_archive("rules_pkg") external_http_archive("com_github_aignas_rules_shellcheck") external_http_archive( - "aspect_bazel_lib", - patch_args = ["-p1"], - patches = ["@envoy//bazel:aspect.patch"], + "bazel_lib", + # patch_args = ["-p1"], + # patches = ["@envoy//bazel:aspect.patch"], ) + external_http_archive("jq.bzl") + external_http_archive("yq.bzl") _com_github_fdio_vpp_vcl() diff --git a/bazel/repositories_extra.bzl b/bazel/repositories_extra.bzl index 84e2a69c092fa..bd80479806bac 100644 --- a/bazel/repositories_extra.bzl +++ b/bazel/repositories_extra.bzl @@ -1,4 +1,4 @@ -load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies") +load("@bazel_lib//lib:repositories.bzl", "bazel_lib_dependencies") load("@bazel_features//:deps.bzl", "bazel_features_deps") load("@com_google_protobuf//bazel/private:proto_bazel_features.bzl", "proto_bazel_features") load("@emsdk//:deps.bzl", emsdk_deps = "deps") @@ -31,7 +31,7 @@ def envoy_dependencies_extra( ignore_root_user_error = ignore_root_user_error, ) - aspect_bazel_lib_dependencies() + bazel_lib_dependencies() if not native.existing_rule("proto_bazel_features"): proto_bazel_features(name = "proto_bazel_features") diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl index 18a626a280e20..b80d006681e1e 100644 --- a/bazel/repository_locations.bzl +++ b/bazel/repository_locations.bzl @@ -125,6 +125,21 @@ REPOSITORY_LOCATIONS_SPEC = dict( license = "Apache-2.0", license_url = "https://github.com/envoyproxy/toolshed/blob/bazel-v{version}/LICENSE", ), + jq_bzl = dict( + project_name = "jq.bzl", + project_desc = "Bazel rule wrapping the jq utility", + project_url = "https://github.com/bazel-contrib/jq.bzl", + use_project_name = True, + version = "0.4.0", + sha256 = "21617eb71fb775a748ef5639131ab943ef39946bd2a4ce96ea60b03f985db0c5", + strip_prefix = "jq.bzl-{version}", + urls = ["https://github.com/bazel-contrib/jq.bzl/releases/download/v{version}/jq.bzl-v{version}.tar.gz"], + release_date = "2025-06-02", + cpe = "N/A", + use_category = ["build", "test_only"], + license = "Apache-2.0", + license_url = "https://github.com/bazel-contrib/jq.bzl/blob/v{version}/LICENSE", + ), rules_fuzzing = dict( project_name = "Fuzzing Rules for Bazel", project_desc = "Bazel rules for fuzz tests", @@ -172,16 +187,16 @@ REPOSITORY_LOCATIONS_SPEC = dict( release_date = "2025-10-13", cpe = "cpe:2.3:a:google:boringssl:*", ), - aspect_bazel_lib = dict( - project_name = "Aspect Bazel helpers", - project_desc = "Base Starlark libraries and basic Bazel rules which are useful for constructing rulesets and BUILD files", - project_url = "https://github.com/aspect-build/bazel-lib", - version = "2.16.0", - sha256 = "092f841dd9ea8e736ea834f304877a25190a762d0f0a6c8edac9f94aac8bbf16", + bazel_lib = dict( + project_name = "Bazel lib", + project_desc = "Common useful functions for writing BUILD files and Starlark macros/rules", + project_url = "https://github.com/bazel-contrib/bazel-lib", + version = "3.0.0", + sha256 = "622914a38966f7dec9b1200b40082bec4c4e19631a447da1b62208f3f55debfb", strip_prefix = "bazel-lib-{version}", urls = ["https://github.com/aspect-build/bazel-lib/archive/v{version}.tar.gz"], use_category = ["build", "test_only"], - release_date = "2025-05-06", + release_date = "2025-10-17", cpe = "N/A", license = "Apache-2.0", license_url = "https://github.com/aspect-build/bazel-lib/blob/v{version}/LICENSE", @@ -1190,6 +1205,21 @@ REPOSITORY_LOCATIONS_SPEC = dict( release_date = "2025-07-09", cpe = "cpe:2.3:a:google:v8:*", ), + yq_bzl = dict( + project_name = "yq.bzl", + project_desc = "Bazel rule wrapping the yq utility", + project_url = "https://github.com/bazel-contrib/yq.bzl", + use_project_name = True, + version = "0.3.1", + sha256 = "7132988406a5bd2021df4efc43e6e6f0bb5c7f976adf16107dc76711881e3051", + strip_prefix = "yq.bzl-{version}", + urls = ["https://github.com/bazel-contrib/yq.bzl/releases/download/v{version}/yq.bzl-v{version}.tar.gz"], + release_date = "2025-06-02", + cpe = "N/A", + use_category = ["build", "test_only"], + license = "Apache-2.0", + license_url = "https://github.com/bazel-contrib/yq.bzl/blob/v{version}/LICENSE", + ), fast_float = dict( project_name = "fast_float number parsing library", project_desc = "Fast and exact implementation of the C++ from_chars functions for number types: 4x to 10x faster than strtod, part of GCC 12, Chromium, Redis and WebKit/Safari", diff --git a/mobile/test/BUILD b/mobile/test/BUILD index d9ee2088fe228..1c0ec18190929 100644 --- a/mobile/test/BUILD +++ b/mobile/test/BUILD @@ -1,4 +1,4 @@ -load("@aspect_bazel_lib//lib:yq.bzl", "yq") +load("@yq.bzl", "yq") licenses(["notice"]) # Apache 2 diff --git a/test/BUILD b/test/BUILD index 29dc0331dfcaa..1c082b799ba1e 100644 --- a/test/BUILD +++ b/test/BUILD @@ -1,4 +1,4 @@ -load("@aspect_bazel_lib//lib:yq.bzl", "yq") +load("@yq.bzl", "yq") load( "//bazel:envoy_build_system.bzl", "envoy_cc_test_library", diff --git a/tools/base/envoy_python.bzl b/tools/base/envoy_python.bzl index c94f2153ea332..beed10a7456f0 100644 --- a/tools/base/envoy_python.bzl +++ b/tools/base/envoy_python.bzl @@ -1,8 +1,8 @@ -load("@aspect_bazel_lib//lib:jq.bzl", "jq") -load("@aspect_bazel_lib//lib:yq.bzl", "yq") load("@base_pip3//:requirements.bzl", "requirement") +load("@jq.bzl", "jq") load("@rules_python//python:defs.bzl", "py_binary", "py_library") load("@rules_python//python/entry_points:py_console_script_binary.bzl", "py_console_script_binary") +load("@yq.bzl", "yq") ENVOY_PYTOOL_NAMESPACE = [ ":py-init", diff --git a/tools/code/BUILD b/tools/code/BUILD index 5e5ebb2486020..4be7dde75f2fc 100644 --- a/tools/code/BUILD +++ b/tools/code/BUILD @@ -1,5 +1,5 @@ -load("@aspect_bazel_lib//lib:jq.bzl", "jq") load("@envoy_repo//:path.bzl", "PATH") +load("@jq.bzl", "jq") load("@rules_python//python/entry_points:py_console_script_binary.bzl", "py_console_script_binary") load("@rules_shell//shell:sh_test.bzl", "sh_test") load( diff --git a/tools/coverage/BUILD b/tools/coverage/BUILD index 0d359127605af..1d1e427eb9cb3 100644 --- a/tools/coverage/BUILD +++ b/tools/coverage/BUILD @@ -1,5 +1,5 @@ -load("@aspect_bazel_lib//lib:jq.bzl", "jq") load("@envoy_repo//:path.bzl", "PATH") +load("@jq.bzl", "jq") load("@rules_shell//shell:sh_binary.bzl", "sh_binary") load("//bazel:envoy_build_system.bzl", "envoy_package") diff --git a/tools/proto_format/BUILD b/tools/proto_format/BUILD index 06ff1d07a1649..1f337852d5287 100644 --- a/tools/proto_format/BUILD +++ b/tools/proto_format/BUILD @@ -1,5 +1,5 @@ -load("@aspect_bazel_lib//lib:jq.bzl", "jq") load("@envoy_repo//:path.bzl", "PATH") +load("@jq.bzl", "jq") load("@rules_python//python:defs.bzl", "py_binary") load("//tools/base:envoy_python.bzl", "envoy_genjson", "envoy_py_data", "envoy_pytool_binary") load("//tools/python:namespace.bzl", "envoy_py_namespace") diff --git a/tools/protoxform/BUILD b/tools/protoxform/BUILD index 500f801e547e0..69a7d721f0e70 100644 --- a/tools/protoxform/BUILD +++ b/tools/protoxform/BUILD @@ -1,5 +1,5 @@ -load("@aspect_bazel_lib//lib:jq.bzl", "jq") load("@com_github_grpc_grpc//bazel:python_rules.bzl", "py_proto_library") +load("@jq.bzl", "jq") load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix") load("@rules_pkg//pkg:pkg.bzl", "pkg_tar") load("@rules_python//python:defs.bzl", "py_binary", "py_library")