|
9 | 9 | # WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. |
10 | 10 |
|
11 | 11 | load("//tools:configure_file.bzl", "configure_file_impl") |
| 12 | +load("@rules_pkg//pkg:pkg.bzl", "pkg_zip") |
12 | 13 |
|
13 | 14 | def _swift_doxygen_impl(ctx): |
14 | 15 | vars = ctx.attr.vars | {} # copy dict instead of referencing it |
@@ -55,7 +56,46 @@ _swift_doxygen = rule( |
55 | 56 | }, |
56 | 57 | ) |
57 | 58 |
|
| 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 | + |
58 | 78 | 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 |
60 | 85 |
|
61 | 86 | _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