diff --git a/MODULE.bazel b/MODULE.bazel index 2dc9dd0a7bb5b..7a85ab51a96ce 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -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") diff --git a/go/BUILD.bazel b/go/BUILD.bazel new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/go/extractor/BUILD.bazel b/go/extractor/BUILD.bazel index ea99340e7d751..040b422731403 100644 --- a/go/extractor/BUILD.bazel +++ b/go/extractor/BUILD.bazel @@ -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", diff --git a/go/extractor/cli/go-autobuilder/BUILD.bazel b/go/extractor/cli/go-autobuilder/BUILD.bazel index b53227b9f1bb8..bf1235b33aa0f 100644 --- a/go/extractor/cli/go-autobuilder/BUILD.bazel +++ b/go/extractor/cli/go-autobuilder/BUILD.bazel @@ -1,4 +1,5 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("@rules_go//go:def.bzl", "go_library") +load("//go:rules.bzl", "codeql_go_binary") go_library( name = "go-autobuilder_lib", @@ -15,7 +16,7 @@ go_library( ], ) -go_binary( +codeql_go_binary( name = "go-autobuilder", embed = [":go-autobuilder_lib"], visibility = ["//visibility:public"], diff --git a/go/extractor/cli/go-bootstrap/BUILD.bazel b/go/extractor/cli/go-bootstrap/BUILD.bazel index 15255227f9a43..7bdd6d6e70f97 100644 --- a/go/extractor/cli/go-bootstrap/BUILD.bazel +++ b/go/extractor/cli/go-bootstrap/BUILD.bazel @@ -1,4 +1,5 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("@rules_go//go:def.bzl", "go_library") +load("//go:rules.bzl", "codeql_go_binary") go_library( name = "go-bootstrap_lib", @@ -7,7 +8,7 @@ go_library( visibility = ["//visibility:private"], ) -go_binary( +codeql_go_binary( name = "go-bootstrap", embed = [":go-bootstrap_lib"], visibility = ["//visibility:public"], diff --git a/go/extractor/cli/go-build-runner/BUILD.bazel b/go/extractor/cli/go-build-runner/BUILD.bazel index fc407c3e1724b..15557d751cf4f 100644 --- a/go/extractor/cli/go-build-runner/BUILD.bazel +++ b/go/extractor/cli/go-build-runner/BUILD.bazel @@ -1,4 +1,5 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("@rules_go//go:def.bzl", "go_library") +load("//go:rules.bzl", "codeql_go_binary") go_library( name = "go-build-runner_lib", @@ -11,7 +12,7 @@ go_library( ], ) -go_binary( +codeql_go_binary( name = "go-build-runner", embed = [":go-build-runner_lib"], visibility = ["//visibility:public"], diff --git a/go/extractor/cli/go-extractor/BUILD.bazel b/go/extractor/cli/go-extractor/BUILD.bazel index 9419c6f8ba93b..be426331868c7 100644 --- a/go/extractor/cli/go-extractor/BUILD.bazel +++ b/go/extractor/cli/go-extractor/BUILD.bazel @@ -1,4 +1,5 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("@rules_go//go:def.bzl", "go_library") +load("//go:rules.bzl", "codeql_go_binary") go_library( name = "go-extractor_lib", @@ -11,7 +12,7 @@ go_library( ], ) -go_binary( +codeql_go_binary( name = "go-extractor", embed = [":go-extractor_lib"], visibility = ["//visibility:public"], diff --git a/go/extractor/cli/go-gen-dbscheme/BUILD.bazel b/go/extractor/cli/go-gen-dbscheme/BUILD.bazel index 1fbd75998c23f..06c0d0f61f187 100644 --- a/go/extractor/cli/go-gen-dbscheme/BUILD.bazel +++ b/go/extractor/cli/go-gen-dbscheme/BUILD.bazel @@ -1,4 +1,5 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("@rules_go//go:def.bzl", "go_library") +load("//go:rules.bzl", "codeql_go_binary") go_library( name = "go-gen-dbscheme_lib", @@ -8,7 +9,7 @@ go_library( deps = ["//go/extractor/dbscheme"], ) -go_binary( +codeql_go_binary( name = "go-gen-dbscheme", embed = [":go-gen-dbscheme_lib"], visibility = ["//visibility:public"], diff --git a/go/extractor/cli/go-tokenizer/BUILD.bazel b/go/extractor/cli/go-tokenizer/BUILD.bazel index f55baecc69f37..3fc5b464c7c59 100644 --- a/go/extractor/cli/go-tokenizer/BUILD.bazel +++ b/go/extractor/cli/go-tokenizer/BUILD.bazel @@ -1,4 +1,5 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("@rules_go//go:def.bzl", "go_library") +load("//go:rules.bzl", "codeql_go_binary") go_library( name = "go-tokenizer_lib", @@ -7,7 +8,7 @@ go_library( visibility = ["//visibility:private"], ) -go_binary( +codeql_go_binary( name = "go-tokenizer", embed = [":go-tokenizer_lib"], visibility = ["//visibility:public"], diff --git a/go/rules.bzl b/go/rules.bzl index e69de29bb2d1d..ddf0369b710ef 100644 --- a/go/rules.bzl +++ b/go/rules.bzl @@ -0,0 +1,23 @@ +load("@rules_go//go:def.bzl", "go_binary") +load("@apple_support//rules:universal_binary.bzl", "universal_binary") + +def codeql_go_binary(*, name, visibility = None, **kwargs): + internal_name = "internal/%s" % name + universal_name = "universal/%s" % name + go_binary( + name = internal_name, + **kwargs + ) + universal_binary( + name = universal_name, + target_compatible_with = ["@platforms//os:macos"], + binary = internal_name, + ) + native.alias( + actual = select({ + "@platforms//os:macos": universal_name, + "//conditions:default": internal_name, + }), + name = name, + visibility = visibility, + )