2
0
Fork 0
mirror of https://github.com/bazel-contrib/bazel-lib synced 2024-11-30 01:41:21 +00:00
bazel-lib/lib/tests/transitions/BUILD.bazel
2022-04-29 00:36:41 -07:00

93 lines
1.8 KiB
Python

load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("//lib:transitions.bzl", "platform_transition_filegroup")
load("//lib:diff_test.bzl", "diff_test")
platform(
name = "armv7_linux",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:armv7",
],
)
platform(
name = "x86_64_linux",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
)
config_setting(
name = "is_x86",
constraint_values = [
"@platforms//cpu:x86_64",
],
)
# Simple test fixture that produces something different depending on the
# target platform.
filegroup(
name = "platform_description",
srcs = select({
":is_x86": ["linux_x86.txt"],
"//conditions:default": ["linux_arm.txt"],
}),
)
platform_transition_filegroup(
name = "for_x86",
srcs = ["platform_description"],
target_platform = ":x86_64_linux",
)
platform_transition_filegroup(
name = "for_arm",
srcs = ["platform_description"],
target_platform = ":armv7_linux",
)
genrule(
name = "for_x86_path",
srcs = [":for_x86"],
outs = ["for_x86_path.txt"],
cmd = "echo $(rootpath :for_x86) > $@",
)
genrule(
name = "for_arm_path",
srcs = [":for_arm"],
outs = ["for_arm_path.txt"],
cmd = "echo $(rootpath :for_arm) > $@",
)
write_file(
name = "expected_x86_path",
out = "expected_x86_path.txt",
content = [
"lib/tests/transitions/linux_x86.txt",
"",
],
)
write_file(
name = "expected_arm_path",
out = "expected_arm_path.txt",
content = [
"lib/tests/transitions/linux_arm.txt",
"",
],
)
diff_test(
name = "test_x86",
file1 = ":for_x86_path",
file2 = ":expected_x86_path",
)
diff_test(
name = "test_arm",
file1 = ":for_arm_path",
file2 = ":expected_arm_path",
)