Skip to content

Commit

Permalink
Added copts_ list
Browse files Browse the repository at this point in the history
`copts_` list contains `-Werror` option in order to turn all warnings into the
errors. `-Wno-error=deprecated-declarations` option turns `syscall` warning
into a warning even if -Werror is specified.
  • Loading branch information
ArthurBandaryk committed Oct 19, 2021
1 parent 79acd4f commit 668f6fc
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
6 changes: 1 addition & 5 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

build --enable_platform_specific_config

build:windows --compiler="clang-cl" --cxxopt="/std:c++17"

build:macos --cxxopt=-std=c++17

build:linux --cxxopt=-std=c++17
build:windows --compiler="clang-cl"

build:clang --action_env=CC=clang
7 changes: 6 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//bazel:copts.bzl", "copts")

cc_library(
name = "eventuals-base",
Expand All @@ -12,6 +13,7 @@ cc_library(
"stout/closure.h",
"stout/collect.h",
"stout/compose.h",
"stout/concurrent.h",
"stout/conditional.h",
"stout/context.h",
"stout/eventual.h",
Expand Down Expand Up @@ -44,8 +46,8 @@ cc_library(
"stout/type-traits.h",
"stout/undefined.h",
"stout/until.h",
"stout/concurrent.h",
],
copts = copts(),
visibility = ["//visibility:private"],
deps = [
"@com_github_google_glog//:glog",
Expand All @@ -64,6 +66,7 @@ cc_library(
"stout/signal.h",
"stout/timer.h",
],
copts = copts(),
visibility = ["//visibility:private"],
deps = [
":eventuals-base",
Expand All @@ -79,6 +82,7 @@ cc_library(
hdrs = [
"stout/http.h",
],
copts = copts(),
defines = [
# Windows build fails without this define.
"GLOG_NO_ABBREVIATED_SEVERITIES",
Expand All @@ -99,6 +103,7 @@ cc_library(

cc_library(
name = "eventuals",
copts = copts(),
visibility = ["//visibility:public"],
deps = [
":eventuals-base",
Expand Down
27 changes: 27 additions & 0 deletions bazel/copts.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Get compiler options for the specific OS."""

# Common compiler options for macOS, Linux and Windows.
copts_common = [
"-Werror",
]

# Get the final list of options composed with common options for the specific
# OS.
def copts():
return copts_common + select({
"@bazel_tools//src/conditions:windows": [
"\"/std:c++17\"",
"-Wno-error=microsoft-cast",
"-Wno-error=invalid-noreturn",
"-Wno-error=microsoft-include",
],
"@bazel_tools//src/conditions:darwin": [
"-std=c++17",
# We do not want to treat `syscall` warning as an error.
# Future update of glog lib will fix this warning.
"-Wno-error=deprecated-declarations",
],
"//conditions:default": [
"-std=c++17",
],
})
2 changes: 2 additions & 0 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_test")
load("//bazel:copts.bzl", "copts")

eventuals_base_sources = [
"eventual.cc",
Expand Down Expand Up @@ -37,6 +38,7 @@ eventuals_http_sources = [
cc_test(
name = "eventuals",
srcs = eventuals_base_sources + eventuals_events_sources + eventuals_http_sources,
copts = copts(),
deps = [
"//:eventuals",
"@com_github_google_googletest//:gtest_main",
Expand Down

0 comments on commit 668f6fc

Please sign in to comment.