| Jan Schär | 371faac | 2025-07-17 14:02:58 +0200 | [diff] [blame^] | 1 | def _multiplatform_transition_impl(_, attr): |
| 2 | return [ |
| 3 | {"//command_line_option:platforms": str(platform)} |
| 4 | for platform in attr.platforms |
| 5 | ] |
| 6 | |
| 7 | _multiplatform_transition = transition( |
| 8 | implementation = _multiplatform_transition_impl, |
| 9 | inputs = [], |
| 10 | outputs = ["//command_line_option:platforms"], |
| 11 | ) |
| 12 | |
| 13 | def _multiplatform_transition_filegroup_impl(ctx): |
| 14 | files = [src[DefaultInfo].files for src in ctx.attr.srcs] |
| 15 | runfiles = ctx.runfiles().merge_all([src[DefaultInfo].default_runfiles for src in ctx.attr.srcs]) |
| 16 | return [DefaultInfo( |
| 17 | files = depset(transitive = files), |
| 18 | runfiles = runfiles, |
| 19 | )] |
| 20 | |
| 21 | multiplatform_transition_filegroup = rule( |
| 22 | _multiplatform_transition_filegroup_impl, |
| 23 | attrs = { |
| 24 | "platforms": attr.label_list( |
| 25 | providers = [platform_common.PlatformInfo], |
| 26 | mandatory = True, |
| 27 | doc = "The target platforms to transition the srcs.", |
| 28 | ), |
| 29 | "srcs": attr.label_list( |
| 30 | cfg = _multiplatform_transition, |
| 31 | mandatory = True, |
| 32 | doc = "The input to be transitioned to the target platforms.", |
| 33 | ), |
| 34 | }, |
| 35 | doc = "Transitions the srcs to use the provided platforms. The filegroup will contain artifacts for all target platforms.", |
| 36 | ) |