Skip to content

Commit

Permalink
Go: introduce universal binaries on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
redsun82 committed Apr 25, 2024
1 parent 393f6b7 commit 4ca8faa
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 13 deletions.
3 changes: 2 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ local_path_override(

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

bazel_dep(name = "platforms", version = "0.0.8")
bazel_dep(name = "apple_support", version = "1.15.1")
bazel_dep(name = "platforms", version = "0.0.9")
bazel_dep(name = "rules_go", version = "0.47.0")
bazel_dep(name = "rules_pkg", version = "0.10.1")
bazel_dep(name = "rules_nodejs", version = "6.0.3")
Expand Down
Empty file added go/BUILD.bazel
Empty file.
1 change: 1 addition & 0 deletions go/extractor/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("@rules_go//go:def.bzl", "go_library")

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

go_library(
name = "extractor",
Expand Down
5 changes: 3 additions & 2 deletions go/extractor/cli/go-autobuilder/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions go/extractor/cli/go-bootstrap/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions go/extractor/cli/go-build-runner/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions go/extractor/cli/go-extractor/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions go/extractor/cli/go-gen-dbscheme/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions go/extractor/cli/go-tokenizer/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions go/rules.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
load("@rules_go//go:def.bzl", "go_binary")
load("//misc/bazel:universal_binary.bzl", "wrap_as_universal_binary")

def codeql_go_binary(**kwargs):
wrap_as_universal_binary(go_binary, **kwargs)
24 changes: 24 additions & 0 deletions misc/bazel/universal_binary.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
load("@apple_support//rules:universal_binary.bzl", _universal_binary = "universal_binary")

def wrap_as_universal_binary(rule, *, name, visibility = None, **kwargs):
internal_name = "internal/%s" % name
universal_name = "universal/%s" % name
rule(
name = internal_name,
visibility = ["//visibility:private"],
**kwargs
)
_universal_binary(
name = universal_name,
target_compatible_with = ["@platforms//os:macos"],
binary = internal_name,
visibility = ["//visibility:private"],
)
native.alias(
name = name,
actual = select({
"@platforms//os:macos": universal_name,
"//conditions:default": internal_name,
}),
visibility = visibility,
)

0 comments on commit 4ca8faa

Please sign in to comment.