From 86291752ee1c96ce040905fadb8963a8dc678310 Mon Sep 17 00:00:00 2001 From: Sam Chen Date: Thu, 29 Aug 2019 13:44:14 +0800 Subject: [PATCH] Infra: warning flags for common/errors and cclient/http. --- cclient/http/BUILD | 12 ++++++++++++ cclient/http/tests/BUILD | 14 ++++++++++++++ common/BUILD | 12 ++++++++++++ tools/bazel.rc | 6 ------ tools/compiler_flags.bzl | 7 +++++++ 5 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 tools/compiler_flags.bzl diff --git a/cclient/http/BUILD b/cclient/http/BUILD index 954bc26606..aac47aed35 100644 --- a/cclient/http/BUILD +++ b/cclient/http/BUILD @@ -1,3 +1,9 @@ +load( + "//tools:compiler_flags.bzl", + "MSVC_WARNING_FLAGS", + "POSIX_WARNING_FLAGS", +) + cc_library( name = "shared", hdrs = ["http.h"], @@ -10,6 +16,12 @@ cc_library( srcs = [ "http.c", ], + copts = select( + { + "@bazel_tools//src/conditions:windows_msvc": MSVC_WARNING_FLAGS, + "//conditions:default": POSIX_WARNING_FLAGS, + }, + ), visibility = ["//visibility:public"], deps = [ ":shared", diff --git a/cclient/http/tests/BUILD b/cclient/http/tests/BUILD index 1c4ab9d44a..ee1a7f7549 100644 --- a/cclient/http/tests/BUILD +++ b/cclient/http/tests/BUILD @@ -1,9 +1,23 @@ +load( + "//tools:compiler_flags.bzl", + "MSVC_DEBUG_FLAGS", + "MSVC_WARNING_FLAGS", + "POSIX_DEBUG_FLAGS", + "POSIX_WARNING_FLAGS", +) + cc_test( name = "test_http", timeout = "short", srcs = [ "test_http.c", ], + copts = select( + { + "@bazel_tools//src/conditions:windows_msvc": MSVC_WARNING_FLAGS + MSVC_DEBUG_FLAGS, + "//conditions:default": POSIX_WARNING_FLAGS + POSIX_DEBUG_FLAGS, + }, + ), flaky = True, deps = [ "//cclient/http", diff --git a/common/BUILD b/common/BUILD index 4302cdbfd1..c3b114c6ff 100644 --- a/common/BUILD +++ b/common/BUILD @@ -1,5 +1,11 @@ package(default_visibility = ["//visibility:public"]) +load( + "//tools:compiler_flags.bzl", + "MSVC_WARNING_FLAGS", + "POSIX_WARNING_FLAGS", +) + cc_library( name = "defs", hdrs = ["defs.h"], @@ -13,6 +19,12 @@ cc_library( "errors.h", ], hdrs = ["errors.h"], + copts = select( + { + "@bazel_tools//src/conditions:windows_msvc": MSVC_WARNING_FLAGS, + "//conditions:default": POSIX_WARNING_FLAGS, + }, + ), ) cc_library( diff --git a/tools/bazel.rc b/tools/bazel.rc index a68ec7d3aa..2dc7ad6147 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -1,14 +1,8 @@ build --cxxopt='-std=c++1z' -build --copt -W -build --copt -Wall -build --copt -Wextra - build --fat_apk_cpu='armeabi-v7a,arm64-v8a,x86,x86_64' build --output_filter='^//((?!external:).)*$' -test --copt='-ggdb3' - # --config asan: Address sanitizer build:asan --strip=never build:asan --copt -DADDRESS_SANITIZER diff --git a/tools/compiler_flags.bzl b/tools/compiler_flags.bzl new file mode 100644 index 0000000000..72c02c3605 --- /dev/null +++ b/tools/compiler_flags.bzl @@ -0,0 +1,7 @@ +# global compile flags + +POSIX_WARNING_FLAGS = ["-W", "-Werror", "-Wextra"] +POSIX_DEBUG_FLAGS = ["-ggdb3"] + +MSVC_WARNING_FLAGS = ["/Wall", "/WX"] +MSVC_DEBUG_FLAGS = ["/Od", "/Z7", "/DDEBUG"]