diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index eaf889fd6..9065173d2 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -47,18 +47,12 @@ tasks: environment: BAZEL_VC: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC" build_flags: - - "--incompatible_enable_cc_toolchain_resolution" - - "--extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl" - - "--extra_execution_platforms=//:x64_windows-clang-cl" + - "--compiler=clang-cl" - "--features=layering_check" - - "--copt=-Wno-macro-redefined" build_targets: - "//..." test_flags: - - "--incompatible_enable_cc_toolchain_resolution" - - "--extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl" - - "--extra_execution_platforms=//:x64_windows-clang-cl" + - "--compiler=clang-cl" - "--features=layering_check" - - "--copt=-Wno-macro-redefined" test_targets: - "//..." diff --git a/bazel/glog.bzl b/bazel/glog.bzl index dcf6f4152..4208d9e2f 100644 --- a/bazel/glog.bzl +++ b/bazel/glog.bzl @@ -46,6 +46,12 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs): values = {"cpu": "wasm"}, ) + # Detect when building with clang-cl on Windows. + native.config_setting( + name = "clang-cl", + values = {"compiler": "clang-cl"}, + ) + common_copts = [ "-DGLOG_BAZEL_BUILD", # Inject a C++ namespace. @@ -100,12 +106,18 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs): ] windows_only_copts = [ + # Override -DGLOG_EXPORT= from the cc_library's defines. "-DGLOG_EXPORT=__declspec(dllexport)", "-DGLOG_NO_ABBREVIATED_SEVERITIES", "-DHAVE_SNPRINTF", "-I" + src_windows, ] + clang_cl_only_copts = [ + # Allow the override of -DGLOG_EXPORT. + "-Wno-macro-redefined", + ] + windows_only_srcs = [ "src/glog/log_severity.h", "src/windows/dirent.h", @@ -173,6 +185,10 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs): "@bazel_tools//src/conditions:freebsd": common_copts + linux_or_darwin_copts + freebsd_only_copts, ":wasm": common_copts + wasm_copts, "//conditions:default": common_copts + linux_or_darwin_copts, + }) + + select({ + ":clang-cl": clang_cl_only_copts, + "//conditions:default": [] }), deps = gflags_deps + select({ "@bazel_tools//src/conditions:windows": [":strip_include_prefix_hack"],