From 60805ba0ec117651c7cb5160f704962cbea93476 Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Sat, 5 Feb 2022 15:53:19 +0000 Subject: [PATCH 1/4] fix: correct uses of `target_compatible_with` Perhaps misleadingly, the list of constraints provided to `target_compatible_with` form a conjunction: all these constraints must be satisfied for the rule to be compatible: > A list of constraint_values that **must** be present https://docs.bazel.build/versions/main/be/common-definitions.html#common.target_compatible_with What wanted to do in all cases was to exclude one platform, and fortunately Bazel provides `@platforms//:incompatible` for that purpose. --- google/cloud/asset/BUILD.bazel | 15 +++++---------- google/cloud/assuredworkloads/BUILD.bazel | 10 +++++----- google/cloud/channel/BUILD.bazel | 10 +++++----- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/google/cloud/asset/BUILD.bazel b/google/cloud/asset/BUILD.bazel index 882d09c16aeb0..a8742ac2cce5a 100644 --- a/google/cloud/asset/BUILD.bazel +++ b/google/cloud/asset/BUILD.bazel @@ -34,11 +34,11 @@ cc_library( include = [HEADER_GLOB], exclude = [MOCK_HEADER_GLOB], ), - # TODO(8145): Enable on macOS. - target_compatible_with = [ - "@platforms//os:linux", - "@platforms//os:windows", - ], + # TODO(#8145): Enable on macOS. + target_compatible_with = select({ + "@platforms//os:macos": ["@platforms//:incompatible"], + "//conditions:default": [], + }), visibility = ["//:__pkg__"], deps = [ "//google/cloud:google_cloud_cpp_common", @@ -55,11 +55,6 @@ cc_library( hdrs = glob( include = [MOCK_HEADER_GLOB], ), - # TODO(8145): Enable on macOS. - target_compatible_with = [ - "@platforms//os:linux", - "@platforms//os:windows", - ], visibility = ["//:__pkg__"], deps = [ ":google_cloud_cpp_asset", diff --git a/google/cloud/assuredworkloads/BUILD.bazel b/google/cloud/assuredworkloads/BUILD.bazel index df94a39ec7d2d..fe1568697e77d 100644 --- a/google/cloud/assuredworkloads/BUILD.bazel +++ b/google/cloud/assuredworkloads/BUILD.bazel @@ -34,11 +34,11 @@ cc_library( include = [HEADER_GLOB], exclude = [MOCK_HEADER_GLOB], ), - # TODO(#8198): Re-enable the macos build. - target_compatible_with = [ - "@platforms//os:linux", - "@platforms//os:macos", - ], + # TODO(#8198): Re-enable the Windows build. + target_compatible_with = select({ + "@platforms//os:windows": ["@platforms//:incompatible"], + "//conditions:default": [], + }), visibility = ["//:__pkg__"], deps = [ "//google/cloud:google_cloud_cpp_common", diff --git a/google/cloud/channel/BUILD.bazel b/google/cloud/channel/BUILD.bazel index caf219f0b5903..04ec2645b4934 100644 --- a/google/cloud/channel/BUILD.bazel +++ b/google/cloud/channel/BUILD.bazel @@ -34,11 +34,11 @@ cc_library( include = [HEADER_GLOB], exclude = [MOCK_HEADER_GLOB], ), - # TODO(8125): Re-enable the macos build. - target_compatible_with = [ - "@platforms//os:linux", - "@platforms//os:windows", - ], + # TODO(#8125): Re-enable the macos build. + target_compatible_with = select({ + "@platforms//os:macos": ["@platforms//:incompatible"], + "//conditions:default": [], + }), visibility = ["//:__pkg__"], deps = [ "//google/cloud:google_cloud_cpp_common", From 63eebd778d46ebc7c2cac788142f392396bff3f4 Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Sat, 5 Feb 2022 17:40:29 +0000 Subject: [PATCH 2/4] Use latest platforms package --- bazel/google_cloud_cpp_deps.bzl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bazel/google_cloud_cpp_deps.bzl b/bazel/google_cloud_cpp_deps.bzl index 8620218173002..6bb7f59bc3640 100644 --- a/bazel/google_cloud_cpp_deps.bzl +++ b/bazel/google_cloud_cpp_deps.bzl @@ -26,6 +26,17 @@ def google_cloud_cpp_deps(): override the version of the dependencies they want to use. """ + # Load platforms, we use it directly + if "platforms" not in native.existing_rules(): + http_archive( + name = "platforms", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.4/platforms-0.0.4.tar.gz", + "https://github.com/bazelbuild/platforms/releases/download/0.0.4/platforms-0.0.4.tar.gz", + ], + sha256 = "079945598e4b6cc075846f7fd6a9d0857c33a7afc0de868c2ccb96405225135d", + ) + # Load rules_cc, used by googletest if "rules_cc" not in native.existing_rules(): http_archive( From ad142018ff61b35400e2cfa2c707ad2472528152 Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Sat, 5 Feb 2022 18:18:24 +0000 Subject: [PATCH 3/4] Also disable google/cloud/channel for Windows --- google/cloud/channel/BUILD.bazel | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/google/cloud/channel/BUILD.bazel b/google/cloud/channel/BUILD.bazel index 04ec2645b4934..11e308e7558ee 100644 --- a/google/cloud/channel/BUILD.bazel +++ b/google/cloud/channel/BUILD.bazel @@ -34,9 +34,10 @@ cc_library( include = [HEADER_GLOB], exclude = [MOCK_HEADER_GLOB], ), - # TODO(#8125): Re-enable the macos build. + # TODO(#8125): Re-enable the macos and Windows builds. target_compatible_with = select({ "@platforms//os:macos": ["@platforms//:incompatible"], + "@platforms//os:windows": ["@platforms//:incompatible"], "//conditions:default": [], }), visibility = ["//:__pkg__"], From 2daac2a0721e6bf4c07f059644092a1fa84988ef Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Sat, 5 Feb 2022 18:39:29 +0000 Subject: [PATCH 4/4] Also disable asset for windows --- google/cloud/asset/BUILD.bazel | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/google/cloud/asset/BUILD.bazel b/google/cloud/asset/BUILD.bazel index a8742ac2cce5a..975e3f381eab7 100644 --- a/google/cloud/asset/BUILD.bazel +++ b/google/cloud/asset/BUILD.bazel @@ -34,9 +34,10 @@ cc_library( include = [HEADER_GLOB], exclude = [MOCK_HEADER_GLOB], ), - # TODO(#8145): Enable on macOS. + # TODO(#8145): Enable on macOS and windows. target_compatible_with = select({ "@platforms//os:macos": ["@platforms//:incompatible"], + "@platforms//os:windows": ["@platforms//:incompatible"], "//conditions:default": [], }), visibility = ["//:__pkg__"],