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

Commit 15175f1

Browse files
authored
Use buildifier to format bazel files. (#204)
1 parent bd2b668 commit 15175f1

8 files changed

Lines changed: 30 additions & 23 deletions

File tree

WORKSPACE

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,19 @@ http_archive(
3333
# Only needed for benchmarks, not to build the OpenCensus library.
3434
http_archive(
3535
name = "com_github_google_benchmark",
36-
urls = ["https://github.com/google/benchmark/archive/master.zip"],
3736
strip_prefix = "benchmark-master",
37+
urls = ["https://github.com/google/benchmark/archive/master.zip"],
3838
)
3939

4040
# gRPC
4141
http_archive(
4242
name = "com_github_grpc_grpc",
43+
strip_prefix = "grpc-master",
4344
urls = ["https://github.com/grpc/grpc/archive/master.tar.gz"],
44-
strip_prefix = "grpc-master"
4545
)
4646

4747
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
48+
4849
grpc_deps()
4950

5051
# These bind()s are needed for the cc_grpc_library() rule to work.
@@ -73,10 +74,8 @@ load_civetweb()
7374
# Curl library - used by zipkin exporter.
7475
new_http_archive(
7576
name = "com_github_curl",
76-
urls = ["https://github.com/curl/curl/archive/master.zip"],
77-
strip_prefix = "curl-master",
7877
build_file_content =
79-
"""
78+
"""
8079
load("@io_opencensus_cpp//opencensus:curl.bzl", "CURL_COPTS")
8180
package(features = ['no_copts_tokenization'])
8281
@@ -108,16 +107,16 @@ cc_library(
108107
],
109108
visibility = ["//visibility:public"],
110109
)
111-
"""
110+
""",
111+
strip_prefix = "curl-master",
112+
urls = ["https://github.com/curl/curl/archive/master.zip"],
112113
)
113114

114115
# Rapidjson library - used by zipkin exporter.
115116
new_http_archive(
116117
name = "com_github_rapidjson",
117-
urls = ["https://github.com/Tencent/rapidjson/archive/master.zip"],
118-
strip_prefix = "rapidjson-master",
119118
build_file_content =
120-
"""
119+
"""
121120
cc_library(
122121
name = "rapidjson",
123122
srcs = [],
@@ -130,5 +129,7 @@ cc_library(
130129
defines = ["RAPIDJSON_HAS_STDSTRING=1",],
131130
visibility = ["//visibility:public"],
132131
)
133-
"""
132+
""",
133+
strip_prefix = "rapidjson-master",
134+
urls = ["https://github.com/Tencent/rapidjson/archive/master.zip"],
134135
)

opencensus/curl.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
BASE_CURL_COPTS = [
1818
# Disable everything else except HTTP protocol.
1919
"-DHTTP_ONLY=1",
20-
2120
"-DENABLE_IPV6=1",
2221
"-DGETHOSTNAME_TYPE_ARG2=size_t",
2322
"-DGETSERVBYPORT_R_ARGS=6",

opencensus/exporters/trace/zipkin/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ cc_library(
3232
copts = DEFAULT_COPTS,
3333
deps = [
3434
"//opencensus/trace",
35+
"@com_github_curl//:curl",
36+
"@com_github_rapidjson//:rapidjson",
3537
"@com_google_absl//absl/base:core_headers",
3638
"@com_google_absl//absl/memory",
3739
"@com_google_absl//absl/strings",
38-
"@com_github_curl//:curl",
39-
"@com_github_rapidjson//:rapidjson",
4040
],
4141
)
4242

opencensus/stats/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ cc_binary(
241241
deps = [
242242
":core",
243243
":recording",
244+
"@com_github_google_benchmark//:benchmark",
244245
"@com_google_absl//absl/memory",
245246
"@com_google_absl//absl/strings",
246247
"@com_google_absl//absl/time",
247-
"@com_github_google_benchmark//:benchmark",
248248
],
249249
)

opencensus/tags/BUILD

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ package(default_visibility = ["//visibility:private"])
2323
# The public tags API.
2424
cc_library(
2525
name = "tags",
26-
hdrs = [
27-
"tag_map.h",
28-
"tag_key.h",
29-
],
3026
srcs = [
31-
"internal/tag_key.cc",
32-
"internal/tag_map.cc",
27+
"internal/tag_key.cc",
28+
"internal/tag_map.cc",
29+
],
30+
hdrs = [
31+
"tag_key.h",
32+
"tag_map.h",
3333
],
3434
copts = DEFAULT_COPTS,
3535
visibility = ["//visibility:public"],

opencensus/trace/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ cc_library(
8181
copts = DEFAULT_COPTS,
8282
visibility = ["//visibility:public"],
8383
deps = [
84+
"//opencensus/common/internal:random_lib",
8485
"@com_google_absl//absl/base:core_headers",
8586
"@com_google_absl//absl/base:endian",
8687
"@com_google_absl//absl/memory",
8788
"@com_google_absl//absl/strings",
8889
"@com_google_absl//absl/synchronization",
8990
"@com_google_absl//absl/time",
9091
"@com_google_absl//absl/types:span",
91-
"//opencensus/common/internal:random_lib",
9292
],
9393
)
9494

opencensus/trace/examples/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ cc_test(
3131
srcs = ["span_example.cc"],
3232
copts = TEST_COPTS,
3333
deps = [
34+
"//opencensus/trace",
3435
"@com_google_absl//absl/memory",
3536
"@com_google_absl//absl/strings",
36-
"//opencensus/trace",
3737
"@com_google_googletest//:gtest_main",
3838
],
3939
)

tools/format.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
# Formats code under opencensus/, exits with 0 if there were no changes.
16+
# Formats code, exits with 0 if there were no changes.
1717
if [[ ! -e tools/format.sh ]]; then
1818
echo "This tool must be run from the topmost OpenCensus directory." >&2
1919
exit 1
@@ -28,6 +28,13 @@ sed -i 's/ \+$//' $(find * -type f)
2828
CMD=clang-format
2929
$CMD -version
3030
$CMD -i -style=Google $(find . -name '*.cc' -or -name '*.h')
31+
if which buildifier >/dev/null; then
32+
echo "Running buildifier."
33+
buildifier WORKSPACE $(find . -name BUILD -o -name \*.bzl)
34+
else
35+
echo "Can't find buildifier. It can be installed with:"
36+
echo " go get github.com/bazelbuild/buildtools/buildifier"
37+
fi
3138
CHANGED="$(git ls-files --modified)"
3239
if [[ ! -z "$CHANGED" ]]; then
3340
echo "The following files have changes:"

0 commit comments

Comments
 (0)