Переглянути джерело

Restrict visibility and add target for C++ benchmark

Yannic Bonenberger 4 роки тому
батько
коміт
ef70abad8a
4 змінених файлів з 54 додано та 10 видалено
  1. 9 0
      WORKSPACE
  2. 18 6
      benchmarks/BUILD
  3. 15 0
      benchmarks/cpp/BUILD
  4. 12 4
      benchmarks/datasets/BUILD

+ 9 - 0
WORKSPACE

@@ -17,6 +17,15 @@ http_archive(
     ],
 )
 
+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")
 

+ 18 - 6
benchmarks/BUILD

@@ -8,12 +8,16 @@ proto_library(
         "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 @@ cc_proto_library(
 
 java_proto_library(
     name = "benchmarks_java_proto",
-    visibility = ["//visibility:public"],
+    visibility = [
+        "//benchmarks:__subpackages__",
+    ],
     deps = [
         "benchmarks_proto",
     ],
@@ -33,12 +39,16 @@ proto_library(
         "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 @@ cc_proto_library(
 
 java_proto_library(
     name = "google_size_java_proto",
-    visibility = ["//visibility:public"],
+    visibility = [
+        "//benchmarks:__subpackages__",
+    ],
     deps = [
         "google_size_proto",
     ],

+ 15 - 0
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",
+    ],
+)

+ 12 - 4
benchmarks/datasets/BUILD

@@ -11,12 +11,16 @@ filegroup(
         "//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 @@ proto_library(
 
 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 @@ cc_library(
 
 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",