|
1 |
| -load("@rules_go//go:def.bzl", "go_binary") |
2 |
| -load("//misc/bazel:universal_binary.bzl", "wrap_as_universal_binary") |
| 1 | +load("@rules_go//go:def.bzl", "go_binary", "go_cross_binary") |
3 | 2 |
|
4 |
| -def codeql_go_binary(**kwargs): |
5 |
| - wrap_as_universal_binary(go_binary, **kwargs) |
| 3 | +def codeql_go_binary(*, name, visibility = None, **kwargs): |
| 4 | + def internal(prefix = "internal"): |
| 5 | + return "%s/%s" % (prefix, name) |
| 6 | + |
| 7 | + go_binary( |
| 8 | + name = internal(), |
| 9 | + visibility = ["//visibility:private"], |
| 10 | + **kwargs |
| 11 | + ) |
| 12 | + macos_targets = ("darwin_arm64", "darwin_amd64") |
| 13 | + for target in macos_targets: |
| 14 | + go_cross_binary( |
| 15 | + name = internal(target), |
| 16 | + platform = "@rules_go//go/toolchain:%s" % target, |
| 17 | + target = internal(), |
| 18 | + target_compatible_with = ["@platforms//os:macos"], |
| 19 | + visibility = ["//visibility:private"], |
| 20 | + ) |
| 21 | + native.genrule( |
| 22 | + name = internal("universal"), |
| 23 | + outs = [internal("universal_")], |
| 24 | + srcs = [internal(t) for t in macos_targets], |
| 25 | + target_compatible_with = ["@platforms//os:macos"], |
| 26 | + executable = True, |
| 27 | + visibility = ["//visibility:private"], |
| 28 | + cmd = "lipo -create $(SRCS) -output $@", |
| 29 | + ) |
| 30 | + native.alias( |
| 31 | + name = name, |
| 32 | + actual = select({ |
| 33 | + "@platforms//os:macos": internal("universal"), |
| 34 | + "//conditions:default": internal(), |
| 35 | + }), |
| 36 | + visibility = visibility, |
| 37 | + ) |
0 commit comments