Skip to content

Commit 4ca8faa

Browse files
committed
Go: introduce universal binaries on macOS
1 parent 393f6b7 commit 4ca8faa

File tree

11 files changed

+50
-13
lines changed

11 files changed

+50
-13
lines changed

MODULE.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ local_path_override(
1313

1414
# see https://registry.bazel.build/ for a list of available packages
1515

16-
bazel_dep(name = "platforms", version = "0.0.8")
16+
bazel_dep(name = "apple_support", version = "1.15.1")
17+
bazel_dep(name = "platforms", version = "0.0.9")
1718
bazel_dep(name = "rules_go", version = "0.47.0")
1819
bazel_dep(name = "rules_pkg", version = "0.10.1")
1920
bazel_dep(name = "rules_nodejs", version = "6.0.3")

go/BUILD.bazel

Whitespace-only changes.

go/extractor/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
load("@rules_go//go:def.bzl", "go_library")
22

33
# gazelle:prefix github.com/github/codeql-go/extractor
4+
# gazelle:map_kind go_binary codeql_go_binary //go:rules.bzl
45

56
go_library(
67
name = "extractor",

go/extractor/cli/go-autobuilder/BUILD.bazel

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/extractor/cli/go-bootstrap/BUILD.bazel

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/extractor/cli/go-build-runner/BUILD.bazel

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/extractor/cli/go-extractor/BUILD.bazel

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/extractor/cli/go-gen-dbscheme/BUILD.bazel

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/extractor/cli/go-tokenizer/BUILD.bazel

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/rules.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
load("@rules_go//go:def.bzl", "go_binary")
2+
load("//misc/bazel:universal_binary.bzl", "wrap_as_universal_binary")
3+
4+
def codeql_go_binary(**kwargs):
5+
wrap_as_universal_binary(go_binary, **kwargs)

misc/bazel/universal_binary.bzl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
load("@apple_support//rules:universal_binary.bzl", _universal_binary = "universal_binary")
2+
3+
def wrap_as_universal_binary(rule, *, name, visibility = None, **kwargs):
4+
internal_name = "internal/%s" % name
5+
universal_name = "universal/%s" % name
6+
rule(
7+
name = internal_name,
8+
visibility = ["//visibility:private"],
9+
**kwargs
10+
)
11+
_universal_binary(
12+
name = universal_name,
13+
target_compatible_with = ["@platforms//os:macos"],
14+
binary = internal_name,
15+
visibility = ["//visibility:private"],
16+
)
17+
native.alias(
18+
name = name,
19+
actual = select({
20+
"@platforms//os:macos": universal_name,
21+
"//conditions:default": internal_name,
22+
}),
23+
visibility = visibility,
24+
)

0 commit comments

Comments
 (0)