Skip to content

Commit 5e57f1b

Browse files
committed
[bazel][NFC] Replace @bazel_tools//src/conditions with equivalent @platforms rules
Followup to D147354. Using src/conditions is discouraged in favor of using rules from the `@platforms` repository directly. This replaces three conditions: * `@bazel_tools//src/conditions:windows` -> `@platforms//os:windows` * `@bazel_tools//src/conditions:darwin` -> `@platforms//os:macos` * `@bazel_tools//src/conditions:freebsd` -> `@platforms//os:freebsd` `llvm/config.bzl` has a non-trivial OS+CPU selection config, so that is omitted from this patch. There is intentionally no equivalent for that in `@platforms` because every project will have their own opinions about what a platform is, and it is not feasible for the bazel selection list to include every possible combination. The recommended idiom there is for projects to define their own supported platforms list, e.g. in a separate BUILD file or platform mapping. Reviewed By: GMNGeoffrey Differential Revision: https://reviews.llvm.org/D147948
1 parent 6de3afe commit 5e57f1b

File tree

6 files changed

+29
-29
lines changed

6 files changed

+29
-29
lines changed

utils/bazel/llvm-project-overlay/clang/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,7 @@ cc_library(
13781378
"lib/Driver",
13791379
],
13801380
linkopts = select({
1381-
"@bazel_tools//src/conditions:windows": ["version.lib"],
1381+
"@platforms//os:windows": ["version.lib"],
13821382
"//conditions:default": [],
13831383
}),
13841384
textual_hdrs = glob([
@@ -1881,7 +1881,7 @@ cc_plugin_library(
18811881
]),
18821882
hdrs = glob(["include/clang-c/*.h"]),
18831883
copts = select({
1884-
"@bazel_tools//src/conditions:windows": ["-D_CINDEX_LIB_"],
1884+
"@platforms//os:windows": ["-D_CINDEX_LIB_"],
18851885
"//conditions:default": [],
18861886
}),
18871887
strip_include_prefix = "include",
@@ -1970,7 +1970,7 @@ cc_binary(
19701970
testonly = 1,
19711971
srcs = ["tools/c-arcmt-test/c-arcmt-test.c"],
19721972
copts = select({
1973-
"@bazel_tools//src/conditions:windows": [],
1973+
"@platforms//os:windows": [],
19741974
"//conditions:default": ["-std=gnu99"],
19751975
}),
19761976
stamp = 0,

utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ cc_test(
531531
"libclang/TestUtils.h",
532532
],
533533
args = select({
534-
"@bazel_tools//src/conditions:windows": [
534+
"@platforms//os:windows": [
535535
# Need to disable the VFS tests that don't use Windows friendly
536536
# paths. These are also disabled on Windows in the CMake build.
537537
"--gtest_filter=-*VirtualFileOverlay*",

utils/bazel/llvm-project-overlay/llvm/BUILD.bazel

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ cc_library(
191191
# To avoid a dependency cycle.
192192
"include/llvm/Option/*.h",
193193
]) + select({
194-
"@bazel_tools//src/conditions:windows": glob([
194+
"@platforms//os:windows": glob([
195195
"lib/Support/Windows/*.h",
196196
"lib/Support/Windows/*.inc",
197197
]),
@@ -255,8 +255,8 @@ cc_library(
255255
}),
256256
includes = ["include"],
257257
linkopts = select({
258-
"@bazel_tools//src/conditions:windows": [],
259-
"@bazel_tools//src/conditions:freebsd": [
258+
"@platforms//os:windows": [],
259+
"@platforms//os:freebsd": [
260260
"-pthread",
261261
"-lexecinfo",
262262
"-ldl",
@@ -1124,7 +1124,7 @@ cc_library(
11241124
"lib/TargetParser/*.cpp",
11251125
"lib/TargetParser/*.h",
11261126
]) + select({
1127-
"@bazel_tools//src/conditions:windows": glob([
1127+
"@platforms//os:windows": glob([
11281128
"lib/TargetParser/Windows/*.h",
11291129
"lib/TargetParser/Windows/*.inc",
11301130
]),
@@ -2105,7 +2105,7 @@ gentbl(
21052105
# MSVC isn't happy with long string literals, while other compilers
21062106
# which support them get significant compile time improvements with
21072107
# them enabled. Ideally this flag would only be enabled on Windows via
2108-
# a select() on `@bazel_tools//src/conditions:windows,`, but that would
2108+
# a select() on `@platforms//os:windows,`, but that would
21092109
# require refactoring gentbl from a macro into a rule.
21102110
# TODO(#92): Refactor gentbl to support this use
21112111
tblgen_args = "--long-string-literals=0",
@@ -2581,9 +2581,9 @@ cc_library(
25812581
copts = llvm_copts,
25822582
linkopts = select({
25832583
"@platforms//os:android": [],
2584-
"@bazel_tools//src/conditions:windows": [],
2585-
"@bazel_tools//src/conditions:freebsd": [],
2586-
"@bazel_tools//src/conditions:darwin": [],
2584+
"@platforms//os:windows": [],
2585+
"@platforms//os:freebsd": [],
2586+
"@platforms//os:macos": [],
25872587
"//conditions:default": [
25882588
"-lrt",
25892589
],
@@ -2647,9 +2647,9 @@ cc_library(
26472647
copts = llvm_copts,
26482648
linkopts = select({
26492649
"@platforms//os:android": [],
2650-
"@bazel_tools//src/conditions:windows": [],
2651-
"@bazel_tools//src/conditions:freebsd": [],
2652-
"@bazel_tools//src/conditions:darwin": [],
2650+
"@platforms//os:windows": [],
2651+
"@platforms//os:freebsd": [],
2652+
"@platforms//os:macos": [],
26532653
"//conditions:default": [
26542654
"-lrt",
26552655
],
@@ -3012,8 +3012,8 @@ cc_binary(
30123012
# ll scripts rely on symbols from dependent
30133013
# libraries being resolvable.
30143014
linkopts = select({
3015-
"@bazel_tools//src/conditions:windows": [],
3016-
"@bazel_tools//src/conditions:darwin": [],
3015+
"@platforms//os:windows": [],
3016+
"@platforms//os:macos": [],
30173017
"//conditions:default": [
30183018
"-Wl,--undefined=_ZTIi",
30193019
"-Wl,--export-dynamic-symbol=_ZTIi",
@@ -3521,8 +3521,8 @@ cc_binary(
35213521
copts = llvm_copts,
35223522
# Make symbols from the standard library dynamically resolvable.
35233523
linkopts = select({
3524-
"@bazel_tools//src/conditions:windows": [],
3525-
"@bazel_tools//src/conditions:darwin": [],
3524+
"@platforms//os:windows": [],
3525+
"@platforms//os:macos": [],
35263526
"//conditions:default": [
35273527
"-Wl,--undefined=_ZTIi",
35283528
"-Wl,--export-dynamic-symbol=_ZTIi",
@@ -4471,8 +4471,8 @@ cc_binary(
44714471
]),
44724472
copts = llvm_copts,
44734473
linkopts = select({
4474-
"@bazel_tools//src/conditions:windows": [],
4475-
"@bazel_tools//src/conditions:darwin": [],
4474+
"@platforms//os:windows": [],
4475+
"@platforms//os:macos": [],
44764476
"//conditions:default": ["-Wl,--export-dynamic"],
44774477
}),
44784478
stamp = 0,
@@ -4701,8 +4701,8 @@ cc_binary(
47014701
# isn't even used in the main binary, so we also need to force it
47024702
# to be included.
47034703
linkopts = select({
4704-
"@bazel_tools//src/conditions:windows": [],
4705-
"@bazel_tools//src/conditions:darwin": [],
4704+
"@platforms//os:windows": [],
4705+
"@platforms//os:macos": [],
47064706
"//conditions:default": [
47074707
"-rdynamic",
47084708
"-u_ZTIi",

utils/bazel/llvm-project-overlay/llvm/cc_plugin_library.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def cc_plugin_library(name, srcs, hdrs, include_prefix = None, strip_include_pre
4343
native.filegroup(
4444
name = interface_output_name,
4545
srcs = select({
46-
"@bazel_tools//src/conditions:windows": [":" + dll_name],
47-
"@bazel_tools//src/conditions:darwin": [":" + dylib_name],
46+
"@platforms//os:windows": [":" + dll_name],
47+
"@platforms//os:macos": [":" + dylib_name],
4848
"//conditions:default": [":" + so_name],
4949
}),
5050
output_group = "interface_library",
@@ -53,8 +53,8 @@ def cc_plugin_library(name, srcs, hdrs, include_prefix = None, strip_include_pre
5353
name = import_name,
5454
interface_library = ":" + interface_output_name,
5555
shared_library = select({
56-
"@bazel_tools//src/conditions:windows": ":" + dll_name,
57-
"@bazel_tools//src/conditions:darwin": ":" + dylib_name,
56+
"@platforms//os:windows": ":" + dll_name,
57+
"@platforms//os:macos": ":" + dylib_name,
5858
"//conditions:default": ":" + so_name,
5959
}),
6060
alwayslink = alwayslink,

utils/bazel/llvm-project-overlay/third-party/unittest/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ cc_library(
5858
"__STDC_LIMIT_MACROS",
5959
"__STDC_CONSTANT_MACROS",
6060
] + select({
61-
"@bazel_tools//src/conditions:windows": ["GTEST_USE_OWN_TR1_TUPLE=0"],
61+
"@platforms//os:windows": ["GTEST_USE_OWN_TR1_TUPLE=0"],
6262
"//conditions:default": ["GTEST_USE_OWN_TR1_TUPLE=1"],
6363
}),
6464
includes = [

utils/bazel/vulkan_sdk.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def _impl(repository_ctx):
1919
cc_library(
2020
name = "sdk",
2121
srcs = select({
22-
"@bazel_tools//src/conditions:windows": [
22+
"@platforms//os:windows": [
2323
"vulkan-sdk/Lib/vulkan-1.lib"
2424
],
2525
"//conditions:default": [

0 commit comments

Comments
 (0)