bazel: define common platforms for multi-platform builds

Default platform for targeting Constellation OS images with nix and cgo:
//bazel/platforms:constellation_os

Other target platforms with nix and cgo:
//bazel/platforms:aarch64-darwin_nix
//bazel/platforms:aarch64-linux_nix
//bazel/platforms:x86_64-darwin_nix
//bazel/platforms:x86_64-linux_nix

Pure go platforms (no cgo, statically linked)
//bazel/platforms:go-pure_aarch64-darwin
//bazel/platforms:go-pure_aarch64-linux
//bazel/platforms:go-pure_x86_64-darwin
//bazel/platforms:go-pure_x86_64-linux
This commit is contained in:
Malte Poll 2023-11-23 17:00:13 +01:00
parent 581ae0f92a
commit a9d298890c

View File

@ -0,0 +1,65 @@
alias(
name = "constellation_os",
actual = ":x86_64-linux_nix",
visibility = ["//visibility:public"],
)
platform(
name = "aarch64-linux_nix",
constraint_values = [
"@platforms//cpu:aarch64",
"@platforms//os:linux",
"@rules_nixpkgs_core//constraints:support_nix",
],
)
platform(
name = "aarch64-darwin_nix",
constraint_values = [
"@platforms//cpu:aarch64",
"@platforms//os:macos",
"@rules_nixpkgs_core//constraints:support_nix",
],
)
platform(
name = "x86_64-linux_nix",
constraint_values = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
"@rules_nixpkgs_core//constraints:support_nix",
],
)
platform(
name = "x86_64-darwin_nix",
constraint_values = [
"@platforms//cpu:x86_64",
"@platforms//os:macos",
"@rules_nixpkgs_core//constraints:support_nix",
],
)
alias(
name = "go-pure_aarch64-linux",
actual = "@io_bazel_rules_go//go/toolchain:linux_arm64",
visibility = ["//visibility:public"],
)
alias(
name = "go-pure_aarch64-darwin",
actual = "@io_bazel_rules_go//go/toolchain:darwin_arm64",
visibility = ["//visibility:public"],
)
alias(
name = "go-pure_x86_64-linux",
actual = "@io_bazel_rules_go//go/toolchain:linux_amd64",
visibility = ["//visibility:public"],
)
alias(
name = "go-pure_x86_64-darwin",
actual = "@io_bazel_rules_go//go/toolchain:darwin_amd64",
visibility = ["//visibility:public"],
)