Skip to content

Commit f0e986b

Browse files
committed
protodoc: Don't use aspect
Builds docs an order of magnitude faster, removes code Signed-off-by: Ryan Northey <ryan@synca.io>
1 parent 09e1f41 commit f0e986b

File tree

9 files changed

+59
-164
lines changed

9 files changed

+59
-164
lines changed

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ build --action_env=PATH --host_action_env=PATH
3131
build --enable_platform_specific_config
3232
build --test_summary=terse
3333

34+
build --experimental_proto_descriptor_sets_include_source_info
35+
3436
# Allow tags to influence execution requirements
3537
common --experimental_allow_tags_propagation
3638

api/BUILD

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py.
22

3-
load("@rules_proto//proto:defs.bzl", "proto_library")
3+
load("@rules_proto//proto:defs.bzl", "proto_descriptor_set", "proto_library")
44

55
licenses(["notice"]) # Apache 2
66

@@ -322,3 +322,12 @@ filegroup(
322322
],
323323
visibility = ["//visibility:public"],
324324
)
325+
326+
proto_descriptor_set(
327+
name = "v3_proto_set",
328+
visibility = ["//visibility:public"],
329+
deps = [
330+
":v3_protos",
331+
":xds_protos",
332+
],
333+
)

docs/BUILD

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ load(
44
)
55
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files")
66
load("@rules_pkg//pkg:pkg.bzl", "pkg_tar")
7+
load("//tools/base:envoy_python.bzl", "envoy_genparallel", "envoy_pkg_filter")
78

89
licenses(["notice"]) # Apache 2
910

@@ -43,6 +44,33 @@ filegroup(
4344
srcs = glob(["root/**/*.pb"]),
4445
)
4546

47+
envoy_genparallel(
48+
name = "protos_rst",
49+
srcs = [":proto_names"],
50+
outs = ["protos_rst.tar"],
51+
args = [
52+
"$(location @com_google_protobuf//:protoc)",
53+
"--descriptor_set_in=$$(realpath $(location @envoy_api//:v3_proto_set))",
54+
"--plugin=protoc-gen-api_proto_plugin=$(location //tools/protodoc)",
55+
"--api_proto_plugin_out=$$OUTDIR",
56+
],
57+
tools = [
58+
"//tools/protodoc",
59+
"@com_google_protobuf//:protoc",
60+
"@envoy_api//:v3_proto_set",
61+
],
62+
verbosity = "warn",
63+
)
64+
65+
envoy_pkg_filter(
66+
name = "api_rst",
67+
srcs = [":protos_rst"],
68+
matching = "*.rst",
69+
merge_paths = {"contrib/envoy/extensions": "api-v3"},
70+
remap_paths = {"envoy": "api-v3"},
71+
strip_empty = True,
72+
)
73+
4674
genrule(
4775
name = "extensions_security_rst",
4876
srcs = [
@@ -85,42 +113,26 @@ genquery(
85113
)
86114

87115
genrule(
88-
name = "empty_protos_rst",
89-
srcs = [":empty_extensions.json"],
90-
outs = ["empty_protos_rst.tar"],
91-
cmd = """
92-
$(location //tools/protodoc:generate_empty) \\
93-
$(location empty_extensions.json) $@
94-
""",
95-
tools = ["//tools/protodoc:generate_empty"],
96-
)
97-
98-
genrule(
99-
name = "api_rst",
116+
name = "proto_names",
100117
srcs = [
101-
"//tools/protodoc:api_v3_protodoc",
102118
":v3_proto_srcs",
119+
":xds_proto_srcs",
103120
],
104-
outs = ["api_rst.tar"],
121+
outs = ["proto_names.txt"],
105122
cmd = """
106-
$(location //tools/docs:generate_api_rst) \\
107-
$(location v3_proto_srcs) $(locations //tools/protodoc:api_v3_protodoc) $@
123+
cat $(SRCS) | cut -d/ -f3- | tr ':' '/' > $@
108124
""",
109-
tools = ["//tools/docs:generate_api_rst"],
110125
)
111126

112127
genrule(
113-
name = "xds_rst",
114-
srcs = [
115-
"//tools/protodoc:xds_protodoc",
116-
":xds_proto_srcs",
117-
],
118-
outs = ["xds_rst.tar"],
128+
name = "empty_protos_rst",
129+
srcs = [":empty_extensions.json"],
130+
outs = ["empty_protos_rst.tar"],
119131
cmd = """
120-
$(location //tools/docs:generate_api_rst) \\
121-
$(location xds_proto_srcs) $(locations //tools/protodoc:xds_protodoc) $@
132+
$(location //tools/protodoc:generate_empty) \\
133+
$(location empty_extensions.json) $@
122134
""",
123-
tools = ["//tools/docs:generate_api_rst"],
135+
tools = ["//tools/protodoc:generate_empty"],
124136
)
125137

126138
pkg_files(
@@ -206,7 +218,6 @@ pkg_tar(
206218
":extensions_security_rst",
207219
":external_deps_rst",
208220
":version_history_rst",
209-
":xds_rst",
210221
],
211222
)
212223

tools/base/BUILD

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
load("@rules_python//python:defs.bzl", "py_binary")
2-
load("@base_pip3//:requirements.bzl", "requirement")
31
load("//bazel:envoy_build_system.bzl", "envoy_package")
42
load("//tools/base:envoy_python.bzl", "envoy_entry_point")
53

tools/base/envoy_python.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def envoy_genparallel(name, args, srcs, outs, verbosity = "info", tools = [], pa
298298
$$PARALLEL_TARGETS \
299299
&& tar cf $@ -C $$OUTDIR . \
300300
&& rm -rf $$OUTDIR
301-
""" % (parralel, verbosity, " ".join(args)),
301+
""" % (parallel, verbosity, " ".join(args)),
302302
tools = [parallel] + tools,
303303
)
304304

@@ -347,15 +347,15 @@ def envoy_pkg_filter(
347347
commands = []
348348
deletable = []
349349
if matching:
350-
deletable.append('! -name "%s"' % matching)
350+
deletable.append('-type f ! -name "%s"' % matching)
351351
if prune:
352352
deletable.append('-name "%s"' % prune)
353353
if strip_dirs:
354354
deletable.append("-type d -empty")
355355
if strip_files:
356356
deletable.append("-type f -empty")
357357
if deletable:
358-
commands.append("find $$OUTDIR %s" % (" -o ".join("%s -delete" for d in deletable)))
358+
commands.append("find $$OUTDIR %s" % (" -o ".join(["%s -delete" % d for d in deletable])))
359359
for src, target in remap_paths.items():
360360
commands.append("mv $$OUTDIR/%s $$OUTDIR/%s" % (src, target))
361361
for src, target in merge_paths.items():

tools/docs/BUILD

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ py_binary(
2424
data = ["//bazel:all_repository_locations"],
2525
)
2626

27-
py_binary(
28-
name = "generate_api_rst",
29-
srcs = [
30-
"generate_api_rst.py",
31-
],
32-
)
33-
3427
# The upstream lib is maintained here:
3528
#
3629
# https://github.com/envoyproxy/pytooling/tree/main/envoy.docs.sphinx_runner

tools/docs/generate_api_rst.py

Lines changed: 0 additions & 71 deletions
This file was deleted.

tools/protodoc/BUILD

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
load("@rules_python//python:defs.bzl", "py_binary")
22
load("@base_pip3//:requirements.bzl", "requirement")
33
load("//bazel:envoy_build_system.bzl", "envoy_package", "envoy_proto_library")
4-
load("//tools/protodoc:protodoc.bzl", "protodoc_rule")
54
load("//tools/base:envoy_python.bzl", "envoy_jinja_env", "envoy_py_data")
65

76
licenses(["notice"]) # Apache 2
@@ -57,6 +56,11 @@ genrule(
5756
tools = [":manifest_to_json"],
5857
)
5958

59+
envoy_py_data(
60+
name = "manifest_db",
61+
src = ":manifest.json",
62+
)
63+
6064
py_binary(
6165
name = "protodoc",
6266
srcs = ["protodoc.py"],
@@ -65,11 +69,8 @@ py_binary(
6569
":contrib_extensions_db",
6670
":extensions_db",
6771
":jinja",
68-
":manifest_proto_py_proto",
69-
":protodoc_manifest_untyped",
72+
":manifest_db",
7073
"//tools/api_proto_plugin",
71-
# Added temporarily, as config_validation is no longer an immediate dep...
72-
"@bazel_tools//tools/python/runfiles",
7374
"@com_envoyproxy_protoc_gen_validate//validate:validate_py",
7475
"@com_github_cncf_udpa//udpa/annotations:pkg_py_proto",
7576
"@com_github_cncf_udpa//xds/annotations/v3:pkg_py_proto",
@@ -79,16 +80,6 @@ py_binary(
7980
],
8081
)
8182

82-
protodoc_rule(
83-
name = "api_v3_protodoc",
84-
deps = ["@envoy_api//:v3_protos"],
85-
)
86-
87-
protodoc_rule(
88-
name = "xds_protodoc",
89-
deps = ["@envoy_api//:xds_protos"],
90-
)
91-
9283
py_library(
9384
name = "rst_filters",
9485
srcs = ["rst_filters.py"],

tools/protodoc/protodoc.bzl

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)