Emily Markova | 7b78640 | 2024-01-24 20:05:24 -0800 | [diff] [blame] | 1 | def _assemble_service_worker_files_impl(ctx): |
| 2 | args = ctx.actions.args() |
| 3 | args.add_all(ctx.attr._package.files, before_each = "--input_dir", expand_directories = False) |
| 4 | args.add_all(ctx.outputs.outs, before_each = "--output") |
| 5 | args.add_all(ctx.attr.outs_as_strings, before_each = "--relative_output") |
| 6 | ctx.actions.run( |
| 7 | inputs = ctx.attr._package.files, |
| 8 | outputs = ctx.outputs.outs, |
| 9 | executable = ctx.executable._tool, |
| 10 | arguments = [args], |
| 11 | mnemonic = "AssembleAngularServiceWorker", |
| 12 | ) |
| 13 | |
| 14 | _assemble_service_worker_files = rule( |
| 15 | implementation = _assemble_service_worker_files_impl, |
| 16 | attrs = { |
| 17 | "outs": attr.output_list( |
| 18 | allow_empty = False, |
| 19 | mandatory = True, |
| 20 | ), |
| 21 | "outs_as_strings": attr.string_list( |
| 22 | allow_empty = False, |
| 23 | mandatory = True, |
| 24 | ), |
| 25 | "_package": attr.label( |
| 26 | default = "//:node_modules/@angular/service-worker", |
| 27 | ), |
| 28 | "_tool": attr.label( |
| 29 | default = "//tools/build_rules/js:assemble_service_worker_files", |
| 30 | cfg = "exec", |
| 31 | executable = True, |
| 32 | ), |
| 33 | }, |
| 34 | ) |
| 35 | |
| 36 | def assemble_service_worker_files(outs, **kwargs): |
| 37 | _assemble_service_worker_files( |
| 38 | outs = outs, |
| 39 | outs_as_strings = outs, |
| 40 | **kwargs |
| 41 | ) |