Philipp Schrader | 175a93c | 2023-02-19 13:13:40 -0800 | [diff] [blame^] | 1 | load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory_bin_action") |
| 2 | |
| 3 | def _assemble_static_files_impl(ctx): |
| 4 | out_dir = ctx.actions.declare_directory(ctx.label.name) |
| 5 | |
| 6 | copy_to_directory_bin = ctx.toolchains["@aspect_bazel_lib//lib:copy_to_directory_toolchain_type"].copy_to_directory_info.bin |
| 7 | |
| 8 | copy_to_directory_bin_action( |
| 9 | ctx, |
| 10 | dst = out_dir, |
| 11 | name = ctx.label.name, |
| 12 | copy_to_directory_bin = copy_to_directory_bin, |
| 13 | files = ctx.files.pictures + ctx.attr.app_files.files.to_list(), |
| 14 | replace_prefixes = ctx.attr.replace_prefixes, |
| 15 | ) |
| 16 | |
| 17 | return [DefaultInfo( |
| 18 | files = depset([out_dir]), |
| 19 | runfiles = ctx.runfiles([out_dir]), |
| 20 | )] |
| 21 | |
| 22 | assemble_static_files = rule( |
| 23 | implementation = _assemble_static_files_impl, |
| 24 | attrs = { |
| 25 | "app_files": attr.label( |
| 26 | mandatory = True, |
| 27 | ), |
| 28 | "pictures": attr.label_list( |
| 29 | mandatory = True, |
| 30 | ), |
| 31 | "replace_prefixes": attr.string_dict( |
| 32 | mandatory = True, |
| 33 | ), |
| 34 | }, |
| 35 | toolchains = ["@aspect_bazel_lib//lib:copy_to_directory_toolchain_type"], |
| 36 | ) |