Restrict visibility and add target for C++ benchmark
diff --git a/WORKSPACE b/WORKSPACE
index d9ed7c8..4346dbd 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -17,6 +17,15 @@
],
)
+http_archive(
+ name = "com_github_google_benchmark",
+ sha256 = "2a778d821997df7d8646c9c59b8edb9a573a6e04c534c01892a40aa524a7b68c",
+ strip_prefix = "benchmark-bf585a2789e30585b4e3ce6baf11ef2750b54677",
+ urls = [
+ "https://github.com/google/benchmark/archive/bf585a2789e30585b4e3ce6baf11ef2750b54677.zip",
+ ],
+)
+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//:protobuf_deps.bzl", "protobuf_deps")
diff --git a/benchmarks/BUILD b/benchmarks/BUILD
index 0ac35c3..8e6063b 100644
--- a/benchmarks/BUILD
+++ b/benchmarks/BUILD
@@ -8,12 +8,16 @@
"benchmarks.proto",
],
strip_import_prefix = "/benchmarks",
- visibility = ["//visibility:public"],
+ visibility = [
+ "//benchmarks:__subpackages__",
+ ],
)
cc_proto_library(
name = "benchmarks_cc_proto",
- visibility = ["//visibility:public"],
+ visibility = [
+ "//benchmarks:__subpackages__",
+ ],
deps = [
"benchmarks_proto",
],
@@ -21,7 +25,9 @@
java_proto_library(
name = "benchmarks_java_proto",
- visibility = ["//visibility:public"],
+ visibility = [
+ "//benchmarks:__subpackages__",
+ ],
deps = [
"benchmarks_proto",
],
@@ -33,12 +39,16 @@
"google_size.proto",
],
strip_import_prefix = "/benchmarks",
- visibility = ["//visibility:public"],
+ visibility = [
+ "//benchmarks:__subpackages__",
+ ],
)
cc_proto_library(
name = "google_size_cc_proto",
- visibility = ["//visibility:public"],
+ visibility = [
+ "//benchmarks:__subpackages__",
+ ],
deps = [
"google_size_proto",
],
@@ -46,7 +56,9 @@
java_proto_library(
name = "google_size_java_proto",
- visibility = ["//visibility:public"],
+ visibility = [
+ "//benchmarks:__subpackages__",
+ ],
deps = [
"google_size_proto",
],
diff --git a/benchmarks/cpp/BUILD b/benchmarks/cpp/BUILD
new file mode 100644
index 0000000..b744f89
--- /dev/null
+++ b/benchmarks/cpp/BUILD
@@ -0,0 +1,15 @@
+load("@rules_cc//cc:defs.bzl", "cc_binary")
+
+cc_binary(
+ name = "cpp",
+ srcs = [
+ "cpp_benchmark.cc",
+ ],
+ tags = ["benchmark"],
+ deps = [
+ "//:protobuf",
+ "//benchmarks:benchmarks_cc_proto",
+ "//benchmarks/datasets:cc_protos",
+ "@com_github_google_benchmark//:benchmark_main",
+ ],
+)
diff --git a/benchmarks/datasets/BUILD b/benchmarks/datasets/BUILD
index c34e303..f29a276 100644
--- a/benchmarks/datasets/BUILD
+++ b/benchmarks/datasets/BUILD
@@ -11,12 +11,16 @@
"//benchmarks/datasets/google_message3:datasets",
"//benchmarks/datasets/google_message4:datasets",
],
- visibility = ["//visibility:public"],
+ visibility = [
+ "//benchmarks:__subpackages__",
+ ],
)
proto_library(
name = "protos",
- visibility = ["//visibility:public"],
+ visibility = [
+ "//benchmarks:__subpackages__",
+ ],
deps = [
"//benchmarks/datasets/google_message1/proto2:benchmark_message1_proto2_proto",
"//benchmarks/datasets/google_message1/proto3:benchmark_message1_proto3_proto",
@@ -28,7 +32,9 @@
cc_library(
name = "cc_protos",
- visibility = ["//visibility:public"],
+ visibility = [
+ "//benchmarks:__subpackages__",
+ ],
deps = [
"//benchmarks/datasets/google_message1/proto2:benchmark_message1_proto2_cc_proto",
"//benchmarks/datasets/google_message1/proto3:benchmark_message1_proto3_cc_proto",
@@ -40,7 +46,9 @@
java_library(
name = "java_protos",
- visibility = ["//visibility:public"],
+ visibility = [
+ "//benchmarks:__subpackages__",
+ ],
exports = [
"//benchmarks/datasets/google_message1/proto2:benchmark_message1_proto2_java_proto",
"//benchmarks/datasets/google_message1/proto3:benchmark_message1_proto3_java_proto",