Skip to content

Commit 6c2373a

Browse files
authored
Use pkg_zip to compress doc [BUILD-450] (#66)
1 parent 169456e commit 6c2373a

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

doxygen/BUILD.bazel

Whitespace-only changes.

doxygen/doxygen.bzl

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
1010

1111
load("//tools:configure_file.bzl", "configure_file_impl")
12+
load("@rules_pkg//pkg:pkg.bzl", "pkg_zip")
1213

1314
def _swift_doxygen_impl(ctx):
1415
vars = ctx.attr.vars | {} # copy dict instead of referencing it
@@ -55,7 +56,46 @@ _swift_doxygen = rule(
5556
},
5657
)
5758

59+
def _filter_html_impl(ctx):
60+
out = ctx.actions.declare_directory(ctx.attr.name)
61+
ctx.actions.run_shell(
62+
outputs = [out],
63+
inputs = ctx.files.srcs,
64+
command = """
65+
cp -r $(find . -type d -regex ".*{html_path}")/* {out}
66+
""".format(out = out.path, html_path = ctx.attr.html_path),
67+
)
68+
return DefaultInfo(files = depset([out]))
69+
70+
_filter_html = rule(
71+
implementation = _filter_html_impl,
72+
attrs = {
73+
"srcs": attr.label_list(mandatory = True),
74+
"html_path": attr.string(mandatory = True),
75+
},
76+
)
77+
5878
def swift_doxygen(**kwargs):
59-
kwargs["tags"] = ["manual"] + kwargs.get("tags", [])
79+
tags = ["manual"] + kwargs.get("tags", [])
80+
name = kwargs["name"]
81+
name_html = name + "_html"
82+
name_zip = name + "_zip"
83+
84+
kwargs["tags"] = tags
6085

6186
_swift_doxygen(**kwargs)
87+
88+
_filter_html(
89+
name = name_html,
90+
tags = tags,
91+
srcs = [name],
92+
html_path = name + "_doxygen/html",
93+
)
94+
95+
pkg_zip(
96+
name = name_zip,
97+
srcs = [name_html],
98+
tags = tags,
99+
package_file_name = name + ".zip",
100+
strip_prefix = name_html,
101+
)

0 commit comments

Comments
 (0)