Fix "'GLOG_EXPORT' macro redefined" on clang-cl
The previous approach used --incompatible_enable_cc_toolchain_resolution, which is recommended by the docs, but a Bazel developer told me it's obsolete. The new, old approach is simpler and should stop the warning from being user-visible.
This commit is contained in:
parent
d153e294b8
commit
5addeedc0a
@ -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:
|
||||
- "//..."
|
||||
|
||||
@ -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"],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user