Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit f0a2bc6

Browse files
authored
Use the same copts as ABSL. (#11)
In particular, -Wno-sign-compare as Google style does not use unsigned integers.
1 parent 870fa67 commit f0a2bc6

10 files changed

Lines changed: 135 additions & 12 deletions

File tree

opencensus/BUILD

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2018, OpenCensus Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
licenses(["notice"]) # Apache 2.0
16+
17+
config_setting(
18+
name = "llvm_compiler",
19+
values = {
20+
"compiler": "llvm",
21+
},
22+
visibility = [":__subpackages__"],
23+
)

opencensus/common/internal/BUILD

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
load("//opencensus:copts.bzl", "DEFAULT_COPTS", "TEST_COPTS")
18+
1719
licenses(["notice"]) # Apache 2.0
1820

1921
package(default_visibility = ["//opencensus:__subpackages__"])
2022

2123
cc_library(
2224
name = "random_lib",
2325
srcs = ["random.cc"],
26+
copts = DEFAULT_COPTS,
2427
hdrs = ["random.h"],
2528
deps = [
2629
"@com_google_absl//absl/synchronization",
@@ -31,6 +34,7 @@ cc_library(
3134
cc_library(
3235
name = "stats_object",
3336
hdrs = ["stats_object.h"],
37+
copts = DEFAULT_COPTS,
3438
deps = [
3539
"@com_google_absl//absl/base:core_headers",
3640
"@com_google_absl//absl/memory",
@@ -43,6 +47,7 @@ cc_library(
4347
cc_library(
4448
name = "string_vector_hash",
4549
hdrs = ["string_vector_hash.h"],
50+
copts = DEFAULT_COPTS,
4651
)
4752

4853
# Tests
@@ -51,6 +56,7 @@ cc_library(
5156
cc_test(
5257
name = "random_test",
5358
srcs = ["random_test.cc"],
59+
copts = TEST_COPTS,
5460
deps = [
5561
":random_lib",
5662
"@com_google_googletest//:gtest_main",
@@ -61,6 +67,7 @@ cc_binary(
6167
name = "random_benchmark",
6268
testonly = 1,
6369
srcs = ["random_benchmark.cc"],
70+
copts = TEST_COPTS,
6471
linkopts = ["-pthread"], # Required for absl/synchronization bits.
6572
linkstatic = 1,
6673
deps = [
@@ -72,6 +79,7 @@ cc_binary(
7279
cc_test(
7380
name = "stats_object_test",
7481
srcs = ["stats_object_test.cc"],
82+
copts = TEST_COPTS,
7583
deps = [
7684
":stats_object",
7785
"@com_google_absl//absl/strings",

opencensus/copts.bzl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2018, OpenCensus Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Compiler options for OpenCensus.
16+
17+
Flags specified here must not impact ABI. Code compiled with and without these
18+
opts will be linked together, and in some cases headers compiled with and
19+
without these options will be part of the same program.
20+
21+
We use the same flags as absl.
22+
"""
23+
24+
load(
25+
"@com_google_absl//absl:copts.bzl",
26+
"GCC_FLAGS",
27+
"GCC_TEST_FLAGS",
28+
"LLVM_FLAGS",
29+
"LLVM_TEST_FLAGS",
30+
)
31+
32+
DEFAULT_COPTS = select({
33+
"//opencensus:llvm_compiler": LLVM_FLAGS,
34+
"//conditions:default": GCC_FLAGS,
35+
})
36+
37+
TEST_COPTS = DEFAULT_COPTS + select({
38+
"//opencensus:llvm_compiler": LLVM_TEST_FLAGS,
39+
"//conditions:default": GCC_TEST_FLAGS,
40+
})

opencensus/stats/BUILD

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
load("//opencensus:copts.bzl", "DEFAULT_COPTS", "TEST_COPTS")
18+
1719
licenses(["notice"]) # Apache License 2.0
1820

1921
package(default_visibility = ["//visibility:private"])
@@ -22,6 +24,7 @@ package(default_visibility = ["//visibility:private"])
2224
cc_library(
2325
name = "stats",
2426
hdrs = ["stats.h"],
27+
copts = DEFAULT_COPTS,
2528
visibility = ["//visibility:public"],
2629
deps = [
2730
":core",
@@ -36,6 +39,7 @@ cc_library(
3639
testonly = 1,
3740
srcs = ["testing/test_utils.cc"],
3841
hdrs = ["testing/test_utils.h"],
42+
copts = DEFAULT_COPTS,
3943
visibility = ["//visibility:public"],
4044
deps = [
4145
":core",
@@ -74,6 +78,7 @@ cc_library(
7478
"view_data.h",
7579
"view_descriptor.h",
7680
],
81+
copts = DEFAULT_COPTS,
7782
deps = [
7883
"@com_google_absl//absl/base:core_headers",
7984
"@com_google_absl//absl/memory",
@@ -91,6 +96,7 @@ cc_library(
9196
name = "recording",
9297
srcs = ["internal/recording.cc"],
9398
hdrs = ["recording.h"],
99+
copts = DEFAULT_COPTS,
94100
deps = [
95101
":core",
96102
"@com_google_absl//absl/strings",
@@ -107,6 +113,7 @@ cc_library(
107113
"stats_exporter.h",
108114
"view.h",
109115
],
116+
copts = DEFAULT_COPTS,
110117
deps = [
111118
":core",
112119
"@com_google_absl//absl/base:core_headers",
@@ -123,6 +130,7 @@ cc_library(
123130
cc_test(
124131
name = "debug_string_test",
125132
srcs = ["internal/debug_string_test.cc"],
133+
copts = TEST_COPTS,
126134
deps = [
127135
":core",
128136
"@com_google_absl//absl/time",
@@ -133,6 +141,7 @@ cc_test(
133141
cc_test(
134142
name = "distribution_test",
135143
srcs = ["internal/distribution_test.cc"],
144+
copts = TEST_COPTS,
136145
deps = [
137146
":core",
138147
"@com_google_googletest//:gtest_main",
@@ -142,6 +151,7 @@ cc_test(
142151
cc_test(
143152
name = "bucket_boundaries_test",
144153
srcs = ["internal/bucket_boundaries_test.cc"],
154+
copts = TEST_COPTS,
145155
deps = [
146156
":core",
147157
"@com_google_googletest//:gtest_main",
@@ -151,6 +161,7 @@ cc_test(
151161
cc_test(
152162
name = "measure_registry_test",
153163
srcs = ["internal/measure_registry_test.cc"],
164+
copts = TEST_COPTS,
154165
deps = [
155166
":core",
156167
"@com_google_absl//absl/strings",
@@ -161,6 +172,7 @@ cc_test(
161172
cc_test(
162173
name = "stats_exporter_test",
163174
srcs = ["internal/stats_exporter_test.cc"],
175+
copts = TEST_COPTS,
164176
deps = [
165177
":core",
166178
":export",
@@ -173,6 +185,7 @@ cc_test(
173185
cc_test(
174186
name = "stats_manager_test",
175187
srcs = ["internal/stats_manager_test.cc"],
188+
copts = TEST_COPTS,
176189
deps = [
177190
":core",
178191
":export",
@@ -185,6 +198,7 @@ cc_test(
185198
cc_test(
186199
name = "view_data_impl_test",
187200
srcs = ["internal/view_data_impl_test.cc"],
201+
copts = TEST_COPTS,
188202
deps = [
189203
":core",
190204
"@com_google_absl//absl/time",

opencensus/stats/examples/BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
load("//opencensus:copts.bzl", "TEST_COPTS")
18+
1719
licenses(["notice"]) # Apache 2.0
1820

1921
package(
@@ -27,6 +29,7 @@ package(
2729
cc_test(
2830
name = "view_and_recording_example",
2931
srcs = ["view_and_recording_example.cc"],
32+
copts = TEST_COPTS,
3033
deps = [
3134
"//opencensus/stats",
3235
"@com_google_googletest//:gtest_main",
@@ -36,6 +39,7 @@ cc_test(
3639
cc_test(
3740
name = "exporter_example",
3841
srcs = ["exporter_example.cc"],
42+
copts = TEST_COPTS,
3943
deps = [
4044
"@com_google_absl//absl/memory",
4145
"@com_google_absl//absl/strings",

opencensus/stats/measure_descriptor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class MeasureDescriptor final {
3636
const std::string& name() const { return name_; }
3737
const std::string& units() const { return units_; }
3838
const std::string& description() const { return description_; }
39-
const Type type() const { return type_; }
39+
Type type() const { return type_; }
4040

4141
std::string DebugString() const;
4242

0 commit comments

Comments
 (0)