| 1 |
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library", "cc_test") |
| 2 |
load("@rules_proto//proto:defs.bzl", "proto_library") |
| 3 |
|
| 4 |
MSVC_C_OPTS = [ |
| 5 |
"-WX", |
| 6 |
"-DWIN32", |
| 7 |
"-DWIN32_LEAN_AND_MEAN", |
| 8 |
] |
| 9 |
|
| 10 |
POSIX_C_OPTS = [ |
| 11 |
"-Wall", |
| 12 |
"-Wextra", |
| 13 |
"-Werror", |
| 14 |
"-Wnon-virtual-dtor", |
| 15 |
"-Woverloaded-virtual", |
| 16 |
"-Wold-style-cast", |
| 17 |
"-std=c++14", |
| 18 |
] |
| 19 |
|
| 20 |
config_setting( |
| 21 |
name = "windows_x86_64", |
| 22 |
values = {"cpu": "x64_windows"}, |
| 23 |
) |
| 24 |
|
| 25 |
cc_binary( |
| 26 |
name = "cc-harness", |
| 27 |
srcs = ["harness.cc"], |
| 28 |
# These ensure that we are at least compatible with what Envoy is expecting. |
| 29 |
copts = select({ |
| 30 |
":windows_x86_64": MSVC_C_OPTS, |
| 31 |
"//conditions:default": POSIX_C_OPTS, |
| 32 |
}), |
| 33 |
visibility = ["//visibility:public"], |
| 34 |
deps = [ |
| 35 |
"//tests/harness:harness_cc_proto", |
| 36 |
"//tests/harness/cases:cc", |
| 37 |
], |
| 38 |
) |
| 39 |
|
| 40 |
proto_library( |
| 41 |
name = "other_proto", |
| 42 |
srcs = ["other.proto"], |
| 43 |
) |
| 44 |
|
| 45 |
cc_proto_library( |
| 46 |
name = "other_cc_proto", |
| 47 |
deps = ["other_proto"], |
| 48 |
) |
| 49 |
|
| 50 |
cc_test( |
| 51 |
name = "polymorphic_test", |
| 52 |
srcs = ["polymorphic_test.cc"], |
| 53 |
copts = select({ |
| 54 |
":windows_x86_64": MSVC_C_OPTS, |
| 55 |
"//conditions:default": POSIX_C_OPTS, |
| 56 |
}), |
| 57 |
deps = [ |
| 58 |
":other_cc_proto", |
| 59 |
"//tests/harness/cases:cc", |
| 60 |
], |
| 61 |
) |
| 62 |
|
| 63 |
# Ensure that if the headers are included in multiple libraries, those libraries |
| 64 |
# can be linked without conflicts. |
| 65 |
cc_test( |
| 66 |
name = "cc_diamond_test", |
| 67 |
srcs = ["diamond_test.cc"], |
| 68 |
copts = select({ |
| 69 |
":windows_x86_64": MSVC_C_OPTS, |
| 70 |
"//conditions:default": POSIX_C_OPTS, |
| 71 |
}), |
| 72 |
linkstatic = 1, # Forces both libraries to be linked in. DO NOT REMOVE THIS |
| 73 |
deps = [ |
| 74 |
"cc_diamond_0", |
| 75 |
"cc_diamond_1", |
| 76 |
], |
| 77 |
) |
| 78 |
|
| 79 |
cc_library( |
| 80 |
name = "cc_diamond_0", |
| 81 |
srcs = ["diamond_lib.cc"], |
| 82 |
copts = select({ |
| 83 |
":windows_x86_64": MSVC_C_OPTS, |
| 84 |
"//conditions:default": POSIX_C_OPTS, |
| 85 |
}), |
| 86 |
deps = ["//tests/harness/cases:cc"], |
| 87 |
alwayslink = 1, |
| 88 |
) |
| 89 |
|
| 90 |
cc_library( |
| 91 |
name = "cc_diamond_1", |
| 92 |
srcs = ["diamond_lib.cc"], |
| 93 |
copts = select({ |
| 94 |
":windows_x86_64": MSVC_C_OPTS, |
| 95 |
"//conditions:default": POSIX_C_OPTS, |
| 96 |
}), |
| 97 |
deps = ["//tests/harness/cases:cc"], |
| 98 |
alwayslink = 1, |
| 99 |
) |