Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions examples/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
load("@rules_python//python/pip_install:requirements.bzl", "compile_pip_requirements")

# TODO: This should not be necessary but there appears to be some inconsistent
# behavior with the use of `constraint_value`s in `select` statements. A support
# thread was started at the end of https://github.com/bazelbuild/bazel/pull/12071
# Once it is possible to replace `:windows` with `@platforms//os:windows` that
# should be done for this file. Note actioning on this will set the minimum
# supported version of Bazel to 4.0.0 for these examples.
config_setting(
name = "windows",
constraint_values = ["@platforms//os:windows"],
visibility = ["//visibility:public"],
)

config_setting(
name = "macos",
constraint_values = ["@platforms//os:macos"],
visibility = ["//visibility:public"],
)

test_suite(
name = "third_party_examples_linux_tests",
tags = ["manual"],
Expand All @@ -32,13 +14,13 @@ test_suite(

test_suite(
name = "third_party_examples_macos_tests",
tags = ["manual"],
target_compatible_with = ["@platforms//os:macos"],
tests = ["@rules_foreign_cc_examples_third_party//:macos_tests"],
)

test_suite(
name = "third_party_examples_windows_tests",
tags = ["manual"],
target_compatible_with = ["@platforms//os:windows"],
tests = ["@rules_foreign_cc_examples_third_party//:windows_tests"],
)

Expand Down
6 changes: 3 additions & 3 deletions examples/cmake_crosstool/static/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ cc_binary(
# includes just hello.h, include directory: "include/version123"
srcs = ["hello_client.c"],
deps = select({
"//:windows": [":libhello_win"],
"@platforms//os:windows": [":libhello_win"],
"//conditions:default": [":libhello"],
}),
)
Expand All @@ -65,7 +65,7 @@ cc_binary(
# includes just hello.h, include directory: "include/version123"
srcs = ["hello_client.c"],
deps = select({
"//:windows": [":libhello_win_ninja"],
"@platforms//os:windows": [":libhello_win_ninja"],
"//conditions:default": [":libhello"],
}),
)
Expand All @@ -75,7 +75,7 @@ cc_binary(
# includes just hello.h, include directory: "include/version123"
srcs = ["hello_client.c"],
deps = select({
"//:windows": [":libhello_win_nmake"],
"@platforms//os:windows": [":libhello_win_nmake"],
"//conditions:default": [":libhello"],
}),
)
Expand Down
4 changes: 2 additions & 2 deletions examples/cmake_defines/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake(
name = "lib_a",
lib_source = ":lib_a_sources",
out_static_libs = select({
"//:windows": ["lib_a.lib"],
"@platforms//os:windows": ["lib_a.lib"],
"//conditions:default": ["liblib_a.a"],
}),
deps = [":lib_b"],
Expand All @@ -15,7 +15,7 @@ cmake(
defines = ["FOO"],
lib_source = ":lib_b_sources",
out_static_libs = select({
"//:windows": ["lib_b.lib"],
"@platforms//os:windows": ["lib_b.lib"],
"//conditions:default": ["liblib_b.a"],
}),
)
Expand Down
4 changes: 2 additions & 2 deletions examples/cmake_defines/nocrosstool/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cmake(
generate_crosstool_file = False,
lib_source = "//cmake_defines:lib_a_sources",
out_static_libs = select({
"//:windows": ["lib_a.lib"],
"@platforms//os:windows": ["lib_a.lib"],
"//conditions:default": ["liblib_a.a"],
}),
deps = [":lib_b"],
Expand All @@ -17,7 +17,7 @@ cmake(
generate_crosstool_file = False,
lib_source = "//cmake_defines:lib_b_sources",
out_static_libs = select({
"//:windows": ["lib_b.lib"],
"@platforms//os:windows": ["lib_b.lib"],
"//conditions:default": ["liblib_b.a"],
}),
)
4 changes: 2 additions & 2 deletions examples/cmake_hello_world_lib/binary/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ cmake(
},
lib_source = ":srcs",
out_binaries = select({
"//:windows": ["hello.exe"],
"@platforms//os:windows": ["hello.exe"],
"//conditions:default": ["hello"],
}),
)
Expand All @@ -27,7 +27,7 @@ filegroup(
name = "binary",
srcs = [":libhello"],
output_group = select({
"//:windows": "hello.exe",
"@platforms//os:windows": "hello.exe",
"//conditions:default": "hello",
}),
)
Expand Down
6 changes: 3 additions & 3 deletions examples/cmake_hello_world_lib/shared/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ cmake(
},
lib_source = ":srcs",
out_interface_libs = select({
"//:windows": ["libhello.lib"],
"@platforms//os:windows": ["libhello.lib"],
"//conditions:default": [],
}),
out_shared_libs = select({
"//:macos": ["libhello.dylib"],
"//:windows": ["libhello.dll"],
"@platforms//os:macos": ["libhello.dylib"],
"@platforms//os:windows": ["libhello.dll"],
"//conditions:default": ["libhello.so"],
}),
)
Expand Down
6 changes: 3 additions & 3 deletions examples/cmake_hello_world_lib/static/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ filegroup(
cmake(
name = "libhello",
generate_args = select({
"//:windows": [
"@platforms//os:windows": [
"-G \"Visual Studio 15 2017\"",
"-A x64",
],
Expand Down Expand Up @@ -51,7 +51,7 @@ cmake(
# pass include/version123 to C/C++ provider as include directory
out_include_dir = "include/version123",
out_static_libs = select({
"//:windows": ["libhello.lib"],
"@platforms//os:windows": ["libhello.lib"],
"//conditions:default": ["libhello.a"],
}),
)
Expand Down Expand Up @@ -120,7 +120,7 @@ cmake(
out_include_dir = "include",
# the name of the static library != <name>.a, put it explicitly
out_static_libs = select({
"//:windows": ["libhello.lib"],
"@platforms//os:windows": ["libhello.lib"],
"//conditions:default": ["libhello.a"],
}),
)
Expand Down
2 changes: 1 addition & 1 deletion examples/cmake_with_bazel_transitive/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cmake(
generate_args = ["-GNinja"],
lib_source = "//cmake_with_bazel_transitive/libb:b_srcs",
out_static_libs = select({
"//:windows": ["libb.lib"],
"@platforms//os:windows": ["libb.lib"],
"//conditions:default": ["libb.a"],
}),
# This library is with public visibility, we can reuse it here.
Expand Down
2 changes: 1 addition & 1 deletion examples/meson_simple/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ meson(
name = "meson_lib",
build_data = ["//meson_simple/code:clang_wrapper.sh"],
env = select({
"//:windows": {
"@platforms//os:windows": {
"CLANG_WRAPPER": "$(execpath //meson_simple/code:clang_wrapper.sh)",
"CXX_FLAGS": "/MD",
},
Expand Down
2 changes: 1 addition & 1 deletion examples/ninja_simple/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ninja(
name = "ninja_lib",
build_data = ["//ninja_simple/code:clang_wrapper.sh"],
env = select({
"//:windows": {
"@platforms//os:windows": {
"CLANG_WRAPPER": "$(execpath //ninja_simple/code:clang_wrapper.sh)",
"CXX_FLAGS": "/MD",
},
Expand Down