example transitions only change platforms, leave toolchains for WORKSPACE
This commit is contained in:
parent
a53170cf82
commit
418b589ed2
12
WORKSPACE
12
WORKSPACE
@ -50,17 +50,19 @@ load(
|
||||
zig_toolchains()
|
||||
|
||||
register_toolchains(
|
||||
# if no `--platform` is selected, these toolchains will be used.
|
||||
# if no `--platform` is specified, these toolchains will be used for
|
||||
# (linux,darwin)x(amd64,arm64)
|
||||
"@zig_sdk//toolchain:linux_amd64_gnu.2.19",
|
||||
"@zig_sdk//toolchain:linux_arm64_gnu.2.28",
|
||||
"@zig_sdk//toolchain:darwin_amd64",
|
||||
"@zig_sdk//toolchain:darwin_arm64",
|
||||
|
||||
# when a libc-aware platform is selected, these will be used. arm64:
|
||||
"@zig_sdk//libc_aware/toolchain:linux_arm64_gnu.2.28",
|
||||
"@zig_sdk//libc_aware/toolchain:linux_arm64_musl",
|
||||
# ditto, amd64:
|
||||
# amd64 toolchains for libc-aware platforms:
|
||||
"@zig_sdk//libc_aware/toolchain:linux_amd64_gnu.2.19",
|
||||
"@zig_sdk//libc_aware/toolchain:linux_amd64_gnu.2.28",
|
||||
"@zig_sdk//libc_aware/toolchain:linux_amd64_gnu.2.31",
|
||||
"@zig_sdk//libc_aware/toolchain:linux_amd64_musl",
|
||||
# arm64 toolchains for libc-aware platforms:
|
||||
"@zig_sdk//libc_aware/toolchain:linux_arm64_gnu.2.28",
|
||||
"@zig_sdk//libc_aware/toolchain:linux_arm64_musl",
|
||||
)
|
||||
|
@ -2,7 +2,6 @@ def _platform_transition_impl(settings, attr):
|
||||
_ignore = settings
|
||||
return {
|
||||
"//command_line_option:platforms": "@zig_sdk{}".format(attr.platform),
|
||||
"//command_line_option:extra_toolchains": ["@zig_sdk{}".format(tc) for tc in attr.extra_toolchains],
|
||||
}
|
||||
|
||||
_platform_transition = transition(
|
||||
@ -10,7 +9,6 @@ _platform_transition = transition(
|
||||
inputs = [],
|
||||
outputs = [
|
||||
"//command_line_option:platforms",
|
||||
"//command_line_option:extra_toolchains",
|
||||
],
|
||||
)
|
||||
|
||||
@ -40,16 +38,12 @@ _attrs = {
|
||||
"platform": attr.string(
|
||||
doc = "The platform to build the target for.",
|
||||
),
|
||||
"extra_toolchains": attr.string_list(
|
||||
doc = "The toolchains to provide as extra_toolchains.",
|
||||
),
|
||||
"_allowlist_function_transition": attr.label(
|
||||
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
|
||||
),
|
||||
}
|
||||
|
||||
# wrap a single exectable and build it for the specified platform passing in
|
||||
# the extra_toolchains.
|
||||
# wrap a single exectable and build it for the specified platform.
|
||||
platform_binary = rule(
|
||||
implementation = _platform_binary_impl,
|
||||
cfg = _platform_transition,
|
||||
@ -57,8 +51,7 @@ platform_binary = rule(
|
||||
executable = True,
|
||||
)
|
||||
|
||||
# wrap a single test target and build it for the specified platform passing in
|
||||
# the extra_toolchains.
|
||||
# wrap a single test target and build it for the specified platform.
|
||||
platform_test = rule(
|
||||
implementation = _platform_binary_impl,
|
||||
cfg = _platform_transition,
|
||||
|
10
test/c/BUILD
10
test/c/BUILD
@ -13,16 +13,6 @@ cc_binary(
|
||||
platform_binary(
|
||||
name = "which_libc_{}".format(name),
|
||||
src = "which_libc",
|
||||
extra_toolchains = [
|
||||
# toolchains for specific libc versions
|
||||
"//libc_aware/toolchain:linux_amd64_gnu.2.19",
|
||||
"//libc_aware/toolchain:linux_amd64_gnu.2.28",
|
||||
"//libc_aware/toolchain:linux_amd64_gnu.2.31",
|
||||
"//libc_aware/toolchain:linux_amd64_musl",
|
||||
# fallback toolchains
|
||||
"//toolchain:linux_amd64_gnu.2.19",
|
||||
"//toolchain:linux_arm64_gnu.2.28",
|
||||
],
|
||||
platform = platform,
|
||||
),
|
||||
sh_test(
|
||||
|
@ -24,31 +24,29 @@ go_test(
|
||||
|
||||
[
|
||||
platform_binary(
|
||||
name = "go_{}".format(toolchain),
|
||||
name = "go_{}".format(name),
|
||||
src = "go",
|
||||
extra_toolchains = ["//toolchain:{}".format(toolchain)],
|
||||
platform = "//platform:{}".format(platform),
|
||||
platform = platform,
|
||||
)
|
||||
for platform, toolchain in [
|
||||
("linux_amd64", "linux_amd64_musl"),
|
||||
("linux_amd64", "linux_amd64_gnu.2.19"),
|
||||
("linux_arm64", "linux_arm64_musl"),
|
||||
("linux_arm64", "linux_arm64_gnu.2.28"),
|
||||
("darwin_amd64", "darwin_amd64"),
|
||||
for name, platform in [
|
||||
("linux_amd64_musl", "//libc_aware/platform:linux_amd64_musl"),
|
||||
("linux_amd64_gnu.2.19", "//libc_aware/platform:linux_amd64_gnu.2.19"),
|
||||
("linux_arm64_musl", "//libc_aware/platform:linux_arm64_musl"),
|
||||
("linux_arm64_gnu.2.28", "//libc_aware/platform:linux_arm64_gnu.2.28"),
|
||||
("darwin_amd64", "//platform:darwin_amd64"),
|
||||
]
|
||||
]
|
||||
|
||||
[
|
||||
platform_test(
|
||||
name = "go_test_{}".format(toolchain),
|
||||
name = "go_test_{}".format(name),
|
||||
src = "go_test",
|
||||
extra_toolchains = ["//toolchain:{}".format(toolchain)],
|
||||
platform = "//platform:{}".format(platform),
|
||||
platform = platform,
|
||||
)
|
||||
for platform, toolchain in [
|
||||
("linux_amd64", "linux_amd64_musl"),
|
||||
("linux_amd64", "linux_amd64_gnu.2.19"),
|
||||
("linux_arm64", "linux_arm64_musl"),
|
||||
("linux_arm64", "linux_arm64_gnu.2.28"),
|
||||
for name, platform in [
|
||||
("linux_amd64_musl", "//libc_aware/platform:linux_amd64_musl"),
|
||||
("linux_amd64_gnu.2.19", "//libc_aware/platform:linux_amd64_gnu.2.19"),
|
||||
("linux_arm64_musl", "//libc_aware/platform:linux_arm64_musl"),
|
||||
("linux_arm64_gnu.2.28", "//libc_aware/platform:linux_arm64_gnu.2.28"),
|
||||
]
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user