| Tim Windelschmidt | 156248b | 2025-01-10 00:27:45 +0100 | [diff] [blame] | 1 | def _build_pure_transition_impl(settings, _attr): |
| Serge Bazanski | c3ae758 | 2020-06-08 17:15:26 +0200 | [diff] [blame] | 2 | """ |
| 3 | Transition that enables pure, static build of Go binaries. |
| 4 | """ |
| Tim Windelschmidt | 3a171d1 | 2024-12-09 23:51:23 +0100 | [diff] [blame] | 5 | race = settings["@io_bazel_rules_go//go/config:race"] |
| Serge Bazanski | 30021af | 2023-06-20 13:30:11 +0200 | [diff] [blame] | 6 | pure = not race |
| 7 | |
| Serge Bazanski | c3ae758 | 2020-06-08 17:15:26 +0200 | [diff] [blame] | 8 | return { |
| Serge Bazanski | 30021af | 2023-06-20 13:30:11 +0200 | [diff] [blame] | 9 | "@io_bazel_rules_go//go/config:pure": pure, |
| Serge Bazanski | c3ae758 | 2020-06-08 17:15:26 +0200 | [diff] [blame] | 10 | "@io_bazel_rules_go//go/config:static": True, |
| Tim Windelschmidt | 3a171d1 | 2024-12-09 23:51:23 +0100 | [diff] [blame] | 11 | "//command_line_option:platforms": "//build/platforms:linux_amd64_static", |
| Serge Bazanski | c3ae758 | 2020-06-08 17:15:26 +0200 | [diff] [blame] | 12 | } |
| 13 | |
| 14 | build_pure_transition = transition( |
| 15 | implementation = _build_pure_transition_impl, |
| Serge Bazanski | 30021af | 2023-06-20 13:30:11 +0200 | [diff] [blame] | 16 | inputs = [ |
| 17 | "@io_bazel_rules_go//go/config:race", |
| 18 | ], |
| Serge Bazanski | c3ae758 | 2020-06-08 17:15:26 +0200 | [diff] [blame] | 19 | outputs = [ |
| 20 | "@io_bazel_rules_go//go/config:pure", |
| 21 | "@io_bazel_rules_go//go/config:static", |
| Tim Windelschmidt | 3a171d1 | 2024-12-09 23:51:23 +0100 | [diff] [blame] | 22 | "//command_line_option:platforms", |
| Serge Bazanski | c3ae758 | 2020-06-08 17:15:26 +0200 | [diff] [blame] | 23 | ], |
| 24 | ) |
| 25 | |
| Tim Windelschmidt | 156248b | 2025-01-10 00:27:45 +0100 | [diff] [blame] | 26 | def _build_static_transition_impl(_settings, _attr): |
| Lorenz Brun | 5e4fc2d | 2020-09-22 18:35:15 +0200 | [diff] [blame] | 27 | """ |
| 28 | Transition that enables static builds with CGo and musl for Go binaries. |
| 29 | """ |
| 30 | return { |
| 31 | "@io_bazel_rules_go//go/config:static": True, |
| Leopold | bc93c2b | 2023-01-14 13:12:23 +0100 | [diff] [blame] | 32 | "//command_line_option:platforms": "//build/platforms:linux_amd64_static", |
| Lorenz Brun | 5e4fc2d | 2020-09-22 18:35:15 +0200 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | build_static_transition = transition( |
| 36 | implementation = _build_static_transition_impl, |
| 37 | inputs = [], |
| 38 | outputs = [ |
| 39 | "@io_bazel_rules_go//go/config:static", |
| Leopold | bc93c2b | 2023-01-14 13:12:23 +0100 | [diff] [blame] | 40 | "//command_line_option:platforms", |
| Lorenz Brun | 5e4fc2d | 2020-09-22 18:35:15 +0200 | [diff] [blame] | 41 | ], |
| 42 | ) |