diff --git a/api/bazel/BUILD b/api/bazel/BUILD index 0e5c8aea75b01..a8b7b161067fd 100644 --- a/api/bazel/BUILD +++ b/api/bazel/BUILD @@ -1,4 +1,6 @@ load("@io_bazel_rules_go//proto:compiler.bzl", "go_proto_compiler") +load("//:utils.bzl", "json_data") +load(":repository_locations.bzl", "REPOSITORY_LOCATIONS_SPEC") licenses(["notice"]) # Apache 2 @@ -15,3 +17,8 @@ go_proto_compiler( valid_archive = False, visibility = ["//visibility:public"], ) + +json_data( + name = "repository_locations", + data = REPOSITORY_LOCATIONS_SPEC, +) diff --git a/bazel/BUILD b/bazel/BUILD index 303ab531bead3..3b22ffc8ff878 100644 --- a/bazel/BUILD +++ b/bazel/BUILD @@ -1,8 +1,10 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") load("//bazel:envoy_build_system.bzl", "envoy_package") load("//bazel:envoy_internal.bzl", "envoy_select_force_libcpp") +load("//bazel:utils.bzl", "json_data") load("@bazel_skylib//lib:selects.bzl", "selects") load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") +load(":repository_locations.bzl", "REPOSITORY_LOCATIONS_SPEC") licenses(["notice"]) # Apache 2 @@ -591,3 +593,8 @@ alias( name = "windows", actual = "@bazel_tools//src/conditions:windows", ) + +json_data( + name = "repository_locations", + data = REPOSITORY_LOCATIONS_SPEC, +) diff --git a/bazel/api_binding.bzl b/bazel/api_binding.bzl index 8d46d4c1827b8..97718ef5346b9 100644 --- a/bazel/api_binding.bzl +++ b/bazel/api_binding.bzl @@ -13,6 +13,7 @@ def _default_envoy_api_impl(ctx): ] for d in api_dirs: ctx.symlink(ctx.path(ctx.attr.envoy_root).dirname.get_child(ctx.attr.reldir).get_child(d), d) + ctx.symlink(ctx.path(ctx.attr.envoy_root).dirname.get_child("bazel").get_child("utils.bzl"), "utils.bzl") _default_envoy_api = repository_rule( implementation = _default_envoy_api_impl, diff --git a/bazel/utils.bzl b/bazel/utils.bzl new file mode 100644 index 0000000000000..0961f00eb446a --- /dev/null +++ b/bazel/utils.bzl @@ -0,0 +1,18 @@ +load("@bazel_skylib//rules:write_file.bzl", "write_file") + +def json_data( + name, + data, + visibility = ["//visibility:public"], + **kwargs): + """Write a bazel object to a file + + The provided `data` object should be json serializable. + """ + write_file( + name = name, + out = "%s.json" % name, + content = json.encode(data).split("\n"), + visibility = visibility, + **kwargs + ) diff --git a/contrib/BUILD b/contrib/BUILD index aa0691c6142a8..ceedb6dfcaacb 100644 --- a/contrib/BUILD +++ b/contrib/BUILD @@ -1,6 +1,14 @@ +load("//bazel:utils.bzl", "json_data") +load(":contrib_build_config.bzl", "CONTRIB_EXTENSIONS") + licenses(["notice"]) # Apache 2 exports_files([ "extensions_metadata.yaml", "contrib_build_config.bzl", ]) + +json_data( + name = "contrib_extensions_build_config", + data = CONTRIB_EXTENSIONS, +) diff --git a/source/extensions/BUILD b/source/extensions/BUILD index 5d4f6c8a9b745..7105032fd6d61 100644 --- a/source/extensions/BUILD +++ b/source/extensions/BUILD @@ -1,6 +1,14 @@ +load("//bazel:utils.bzl", "json_data") +load(":extensions_build_config.bzl", "EXTENSIONS") + licenses(["notice"]) # Apache 2 exports_files([ "extensions_metadata.yaml", "extensions_build_config.bzl", ]) + +json_data( + name = "extensions_build_config", + data = EXTENSIONS, +)