github.com/prysmaticlabs/prysm@v1.4.4/tools/go_image.bzl (about)

     1  load("@io_bazel_rules_docker//container:providers.bzl", "ImageInfo")
     2  
     3  # Defines the debug transition implementation to enforce dbg mode.
     4  def _debug_transition_impl(settings, attr):
     5      return {
     6          "//command_line_option:compilation_mode": "dbg",
     7      }
     8  
     9  # Defines a starlark transition which enforces dbg compilation mode.
    10  build_in_debug_mode = transition(
    11      implementation = _debug_transition_impl,
    12      inputs = [],
    13      outputs = ["//command_line_option:compilation_mode"],
    14  )
    15  
    16  def _alpine_transition_impl(settings, attr):
    17      return {
    18          "//tools:base_image": "alpine",
    19      }
    20  
    21  use_alpine = transition(
    22      implementation = _alpine_transition_impl,
    23      inputs = [],
    24      outputs = ["//tools:base_image"],
    25  )
    26  
    27  # Defines a rule implementation that essentially returns all of the providers from the image attr.
    28  def _go_image_debug_impl(ctx):
    29      img = ctx.attr.image[0]
    30  
    31      return [
    32          img[ImageInfo],
    33          img[OutputGroupInfo],
    34      ]
    35  
    36  # Defines a rule that specifies a starlark transition to enforce debug compilation mode for debug
    37  # images.
    38  go_image_debug = rule(
    39      implementation = _go_image_debug_impl,
    40      attrs = {
    41          "image": attr.label(
    42              cfg = build_in_debug_mode,
    43              executable = True,
    44          ),
    45          # Whitelist is required or bazel complains.
    46          "_whitelist_function_transition": attr.label(default = "@bazel_tools//tools/whitelists/function_transition_whitelist"),
    47      },
    48  )
    49  go_image_alpine = rule(
    50      _go_image_debug_impl,
    51      attrs = {
    52          "image": attr.label(
    53              cfg = use_alpine,
    54              executable = True,
    55          ),
    56          # Whitelist is required or bazel complains.
    57          "_whitelist_function_transition": attr.label(default = "@bazel_tools//tools/whitelists/function_transition_whitelist"),
    58      },
    59  )