| """Rule to generate Starlark source lists for Gnulib license tiers.""" | |
| visibility(["//third_party/gnulib:__subpackages__"]) | |
| def _generate_gnulib_srcs_impl(ctx): | |
| out_file = ctx.outputs.out | |
| src_files = [] | |
| for src in ctx.attr.srcs: | |
| src_files.extend(src.files.to_list()) | |
| args = ctx.actions.args() | |
| args.use_param_file("@%s", use_always = True) | |
| args.set_param_file_format("multiline") | |
| args.add("--output", out_file) | |
| args.add_all(src_files) | |
| ctx.actions.run( | |
| inputs = src_files, | |
| outputs = [out_file], | |
| executable = ctx.executable._tool, | |
| arguments = [args], | |
| mnemonic = "GenerateGnulibSrcs", | |
| progress_message = "Generating gnulib source lists into %{output}", | |
| ) | |
| return [ | |
| DefaultInfo( | |
| files = depset([out_file]), | |
| runfiles = ctx.runfiles(files = [out_file]), | |
| ), | |
| ] | |
| generate_gnulib_srcs = rule( | |
| doc = "Generates a Starlark file defining LGPL2_SRCS and LGPL3_SRCS from Gnulib modules.", | |
| implementation = _generate_gnulib_srcs_impl, | |
| attrs = { | |
| "srcs": attr.label_list( | |
| allow_files = True, | |
| mandatory = True, | |
| doc = "All Gnulib Modules and Gnulib Infrastructure Files in the repository.", | |
| ), | |
| "out": attr.output( | |
| doc = "Output .bzl file.", | |
| mandatory = True, | |
| ), | |
| "_tool": attr.label( | |
| default = Label("//third_party/gnulib:gnulib_srcs_bin"), | |
| executable = True, | |
| cfg = "exec", | |
| ), | |
| }, | |
| ) |